1 package org.apache.fulcrum; 2 3 56 57 import org.apache.commons.configuration.Configuration; 58 import org.apache.log4j.Category; 59 60 71 public abstract class BaseService implements Service 72 { 73 76 protected boolean isInitialized = false; 77 78 81 protected ServiceBroker serviceBroker; 82 83 86 protected Configuration configuration; 87 88 91 protected String name; 92 93 101 public abstract void init() throws InitializationException; 102 103 109 public void shutdown() 110 { 111 setInit(false); 112 } 113 114 121 public boolean getInit() 122 { 123 return isInitialized(); 124 } 125 126 133 public String getStatus() throws ServiceException 134 { 135 return (isInitialized() ? "Initialized" : "Uninitialized"); 136 } 137 138 141 public boolean isInitialized() 142 { 143 return isInitialized; 144 } 145 146 151 protected void setInit(boolean value) 152 { 153 this.isInitialized = value; 154 } 155 156 161 public void setName(String name) 162 { 163 this.name = name; 164 } 165 166 171 public String getName() 172 { 173 return name; 174 } 175 176 183 public void setServiceBroker(ServiceBroker broker) 184 { 185 this.serviceBroker = broker; 186 } 187 188 193 public ServiceBroker getServiceBroker() 194 { 195 return serviceBroker; 196 } 197 198 203 public Configuration getConfiguration() 204 { 205 if (name == null) 206 { 207 return null; 208 } 209 210 if (configuration == null) 211 { 212 configuration = getServiceBroker().getConfiguration(name); 213 } 214 215 return configuration; 216 } 217 218 221 public Object getServiceObject(String name) 222 { 223 return getServiceBroker().getServiceObject(name); 224 } 225 226 229 public String getRealPath(String path) 230 { 231 return getServiceBroker().getRealPath(path); 232 } 233 234 237 public Category getCategory() 238 { 239 return getServiceBroker().getCategory(); 240 } 241 } 242 | Popular Tags |