Coverage Report - org.apache.turbine.services.BaseUnicastRemoteService
 
Classes in this File Line Coverage Branch Coverage Complexity
BaseUnicastRemoteService
0%
0/30
0%
0/4
1,214
 
 1  
 package org.apache.turbine.services;
 2  
 
 3  
 
 4  
 /*
 5  
  * Licensed to the Apache Software Foundation (ASF) under one
 6  
  * or more contributor license agreements.  See the NOTICE file
 7  
  * distributed with this work for additional information
 8  
  * regarding copyright ownership.  The ASF licenses this file
 9  
  * to you under the Apache License, Version 2.0 (the
 10  
  * "License"); you may not use this file except in compliance
 11  
  * with the License.  You may obtain a copy of the License at
 12  
  *
 13  
  *   http://www.apache.org/licenses/LICENSE-2.0
 14  
  *
 15  
  * Unless required by applicable law or agreed to in writing,
 16  
  * software distributed under the License is distributed on an
 17  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 18  
  * KIND, either express or implied.  See the License for the
 19  
  * specific language governing permissions and limitations
 20  
  * under the License.
 21  
  */
 22  
 
 23  
 
 24  
 import java.rmi.RemoteException;
 25  
 import java.rmi.server.UnicastRemoteObject;
 26  
 import java.util.Properties;
 27  
 
 28  
 import org.apache.commons.configuration.Configuration;
 29  
 import org.apache.commons.configuration.ConfigurationConverter;
 30  
 
 31  
 /**
 32  
  * A base implementation of an {@link java.rmi.server.UnicastRemoteObject}
 33  
  * as a Turbine {@link org.apache.turbine.services.Service}.
 34  
  *
 35  
  * @author <a href="mailto:dlr@collab.net">Daniel Rall</a>
 36  
  */
 37  
 public class BaseUnicastRemoteService extends UnicastRemoteObject
 38  
         implements Service
 39  
 {
 40  
     /**
 41  
      * Serial version.
 42  
      */
 43  
     private static final long serialVersionUID = -7775459623190960297L;
 44  
 
 45  
     protected Configuration configuration;
 46  
     private boolean isInitialized;
 47  
     private InitableBroker initableBroker;
 48  
     private String name;
 49  
     private ServiceBroker serviceBroker;
 50  
 
 51  
     /**
 52  
      * Default constructor
 53  
      * @throws RemoteException if the remote object cannot be created
 54  
      */
 55  
     public BaseUnicastRemoteService()
 56  
             throws RemoteException
 57  0
     {
 58  0
         isInitialized = false;
 59  0
         initableBroker = null;
 60  0
         name = null;
 61  0
         serviceBroker = null;
 62  0
     }
 63  
 
 64  
     /**
 65  
      * Returns the configuration of this service.
 66  
      *
 67  
      * @return The configuration of this service.
 68  
      */
 69  
     @Override
 70  
     public Configuration getConfiguration()
 71  
     {
 72  0
         if (name == null)
 73  
         {
 74  0
             return null;
 75  
         }
 76  
         else
 77  
         {
 78  0
             if (configuration == null)
 79  
             {
 80  0
                 configuration = getServiceBroker().getConfiguration(name);
 81  
             }
 82  0
             return configuration;
 83  
         }
 84  
     }
 85  
 
 86  
     @Override
 87  
     public void setInitableBroker(InitableBroker broker)
 88  
     {
 89  0
         this.initableBroker = broker;
 90  0
     }
 91  
 
 92  
     /**
 93  
      * Get the {@link InitableBroker} instance
 94  
      * @return the broker instance
 95  
      */
 96  
     public InitableBroker getInitableBroker()
 97  
     {
 98  0
         return initableBroker;
 99  
     }
 100  
 
 101  
     @Override
 102  
     public void init(Object data)
 103  
             throws InitializationException
 104  
     {
 105  0
         init();
 106  0
     }
 107  
 
 108  
     @Override
 109  
     public void init() throws InitializationException
 110  
     {
 111  0
         setInit(true);
 112  0
     }
 113  
 
 114  
     protected void setInit(boolean value)
 115  
     {
 116  0
         isInitialized = value;
 117  0
     }
 118  
 
 119  
     @Override
 120  
     public boolean getInit()
 121  
     {
 122  0
         return isInitialized;
 123  
     }
 124  
 
 125  
     /**
 126  
      * Shuts down this service.
 127  
      */
 128  
     @Override
 129  
     public void shutdown()
 130  
     {
 131  0
         setInit(false);
 132  0
     }
 133  
 
 134  
     @Override
 135  
     public Properties getProperties()
 136  
     {
 137  0
         return ConfigurationConverter.getProperties(getConfiguration());
 138  
     }
 139  
 
 140  
     @Override
 141  
     public void setName(String name)
 142  
     {
 143  0
         this.name = name;
 144  0
     }
 145  
 
 146  
     @Override
 147  
     public String getName()
 148  
     {
 149  0
         return name;
 150  
     }
 151  
 
 152  
     /**
 153  
      * Get the {@link ServiceBroker} instance
 154  
      * @return the broker instance
 155  
      */
 156  
     public ServiceBroker getServiceBroker()
 157  
     {
 158  0
         return serviceBroker;
 159  
     }
 160  
 
 161  
     @Override
 162  
     public void setServiceBroker(ServiceBroker broker)
 163  
     {
 164  0
         this.serviceBroker = broker;
 165  0
     }
 166  
 }