blob: 25d7f9e43418137349486ef94809bafc790a256a [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>BaseService.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Turbine</a> &gt; <a href="index.source.html" class="el_package">org.apache.turbine.services</a> &gt; <span class="el_source">BaseService.java</span></div><h1>BaseService.java</h1><pre class="source lang-java linenums">package org.apache.turbine.services;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* &quot;License&quot;); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* &quot;AS IS&quot; BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.util.Properties;
import org.apache.commons.configuration2.Configuration;
import org.apache.commons.configuration2.ConfigurationConverter;
/**
* This class is a generic implementation of &lt;code&gt;Service&lt;/code&gt;.
*
* @author &lt;a href=&quot;mailto:burton@apache.org&quot;&gt;Kevin Burton&lt;/a&gt;
* @author &lt;a href=&quot;mailto:krzewski@e-point.pl&quot;&gt;Rafal Krzewski&lt;/a&gt;
* @author &lt;a href=&quot;mailto:hps@intermeta.de&quot;&gt;Henning P. Schmiedehausen&lt;/a&gt;
* @version $Id$
*/
<span class="fc" id="L37">public class BaseService</span>
extends BaseInitable
implements Service
{
/** A reference to the ServiceBroker that instantiated this object. */
protected ServiceBroker serviceBroker;
/** The configuration for this service */
protected Configuration configuration;
/** The name of this Service. */
protected String name;
/**
* Saves a reference to the ServiceBroker that instantiated this
* object, so that it can ask for its properties and access other
* Services.
*
* @param broker The ServiceBroker that instantiated this object.
*/
@Override
public void setServiceBroker(ServiceBroker broker)
{
<span class="fc" id="L60"> this.serviceBroker = broker;</span>
<span class="fc" id="L61"> }</span>
/**
* ServiceBroker uses this method to pass a Service its name.
*
* @param name The name of this Service.
*/
@Override
public void setName(String name)
{
<span class="fc" id="L71"> this.name = name;</span>
<span class="fc" id="L72"> }</span>
/**
* Returns the name of this service.
*
* @return The name of this Service.
*/
@Override
public String getName()
{
<span class="nc" id="L82"> return name;</span>
}
/**
* Returns a ServiceBroker reference.
*
* @return The ServiceBroker that instantiated this object.
*/
public ServiceBroker getServiceBroker()
{
<span class="fc" id="L92"> return serviceBroker;</span>
}
/**
* Returns the properties of this Service.
*
* @return The Properties of this Service.
*/
@Override
public Properties getProperties()
{
<span class="nc" id="L103"> return ConfigurationConverter.getProperties(getConfiguration());</span>
}
/**
* Returns the configuration of this Service.
*
* @return The Configuration of this Service.
*/
@Override
public Configuration getConfiguration()
{
<span class="pc bpc" id="L114" title="1 of 2 branches missed."> if (name == null)</span>
{
<span class="nc" id="L116"> return null;</span>
}
<span class="fc bfc" id="L119" title="All 2 branches covered."> if (configuration == null)</span>
{
<span class="fc" id="L121"> configuration = getServiceBroker().getConfiguration(name);</span>
}
<span class="fc" id="L123"> return configuration;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>