1 package org.apache.turbine.services; 2 3 18 19 import java.rmi.RemoteException ; 20 import java.rmi.server.UnicastRemoteObject ; 21 import java.util.Properties ; 22 import javax.servlet.ServletConfig ; 23 24 import org.apache.commons.configuration.Configuration; 25 import org.apache.commons.configuration.ConfigurationConverter; 26 27 34 public class BaseUnicastRemoteService extends UnicastRemoteObject 35 implements Service 36 { 37 protected Configuration configuration; 38 private boolean isInitialized; 39 private InitableBroker initableBroker; 40 private String name; 41 private ServiceBroker serviceBroker; 42 43 public BaseUnicastRemoteService() 44 throws RemoteException 45 { 46 isInitialized = false; 47 initableBroker = null; 48 name = null; 49 serviceBroker = null; 50 } 51 52 57 public Configuration getConfiguration() 58 { 59 if (name == null) 60 { 61 return null; 62 } 63 else 64 { 65 if (configuration == null) 66 { 67 configuration = getServiceBroker().getConfiguration(name); 68 } 69 return configuration; 70 } 71 } 72 73 public void init(ServletConfig config) 74 throws InitializationException 75 { 76 setInit(true); 77 } 78 79 public void setInitableBroker(InitableBroker broker) 80 { 81 this.initableBroker = broker; 82 } 83 84 public InitableBroker getInitableBroker() 85 { 86 return initableBroker; 87 } 88 89 public void init(Object data) 90 throws InitializationException 91 { 92 init((ServletConfig ) data); 93 } 94 95 public void init() throws InitializationException 96 { 97 setInit(true); 98 } 99 100 protected void setInit(boolean value) 101 { 102 isInitialized = value; 103 } 104 105 public boolean getInit() 106 { 107 return isInitialized; 108 } 109 110 113 public void shutdown() 114 { 115 setInit(false); 116 } 117 118 public Properties getProperties() 119 { 120 return ConfigurationConverter.getProperties(getConfiguration()); 121 } 122 123 public void setName(String name) 124 { 125 this.name = name; 126 } 127 128 public String getName() 129 { 130 return name; 131 } 132 133 public ServiceBroker getServiceBroker() 134 { 135 return serviceBroker; 136 } 137 138 public void setServiceBroker(ServiceBroker broker) 139 { 140 this.serviceBroker = broker; 141 } 142 } 143 | Popular Tags |