*/
public boolean getLogEffectiveWebXml();
- /**
- * Has this context been initialized?
- */
- public boolean isInitialized();
-
// --------------------------------------------------------- Public Methods
* <br>
* The valid state transitions for components that support Lifecycle are:
* <pre>
- * --------------------<--------------------------
- * | |
- * start() | auto auto stop() |
- * NEW ------------->--- STARTING_PREP -->- STARTING -->- STARTED -->--- |
- * | | | |
- * | auto | | |
- * |stop() ---------<----- MUST_STOP --<--------------- | |
- * | | | |
- * | ---------------------------<-------------------------- ^
- * | | |
- * | | auto auto start() |
- * | STOPPING_PREP -->- STOPPING -->- STOPPED -------------->--------
- * | ^ ^
- * | |stop() |
- * | | |
- * | FAILED |
- * | |
- * --->------------------------------>-----------
+ * --------------------<-----------------------
+ * | |
+ * init() start() | auto auto stop() |
+ * NEW ->-- INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->--- |
+ * | | ^ | | |
+ * | | start() | | | |
+ * | ----------->-------------------- | | |
+ * | | | |
+ * | auto auto | | |
+ * |stop() ---------<----- MUST_STOP ---------------------<-- | |
+ * | | | |
+ * | ---------------------------<-------------------------------- ^
+ * | | |
+ * | | auto auto start() |
+ * | STOPPING_PREP --->-- STOPPING --->-- STOPPED ---------->------------
+ * | ^ | ^
+ * | |stop() | |
+ * | | destroy()| |
+ * | | destroy() | |
+ * | FAILED ---->------ DESTROYED ----<--- |
+ * | |
+ * --->------------------------------>-----------------
*
* Any state can transition to FAILED.
*
* Calling start() while a component is in states STARTING_PREP, STARTING or
* STARTED has no effect.
*
+ * Calling start() while a component is in state NEW will cause init() to be
+ * called immediately the start() method is entered.
+ *
* Calling stop() while a component is in states STOPPING_PREP, STOPPING or
* STOPPED has no effect.
*
* try to stop all sub-components - even those it didn't start.
*
* MUST_STOP is used to indicate that the {@link #stop()} should be called on
- * the component as soon as {@link #start()} exits.
+ * the component as soon as {@link #start()} exits. It is typically used when a
+ * component has failed to start.
+ *
+ * MUST_DESTROY is used to indicate that the {@link #stop()} should be called on
+ * the component as soon as {@link #stop()} exits. It is typically used when a
+ * component is not designed to be restarted.
*
* Attempting any other transition will throw {@link LifecycleException}.
*
/**
+ * Prepare the component for starting. This method should perform any
+ * initialization required post object creation. The following
+ * {@link LifecycleEvent}s will be fired in the following order:
+ * <ol>
+ * <li>INIT_EVENT: On the successful completion of component
+ * initialization.</li>
+ * </ol>
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents this component from being used
+ */
+ public void init() throws LifecycleException;
+
+ /**
* Prepare for the beginning of active use of the public methods of this
* component. This method should be called before any of the public
* methods of this component are utilized. The following
*/
public void stop() throws LifecycleException;
+ /**
+ * Prepare to discard the object. The following {@link LifecycleEvent}s will
+ * be fired in the following order:
+ * <ol>
+ * <li>DESTROY_EVENT: On the successful completion of component
+ * destruction.</li>
+ * </ol>
+ *
+ * @exception LifecycleException if this component detects a fatal error
+ * that prevents this component from being used
+ */
+ public void destroy() throws LifecycleException;
+
/**
* Obtain the current state of the source component.
*/
public enum LifecycleState {
NEW(false, null),
+ INITIALIZED(false, Lifecycle.INIT_EVENT),
STARTING_PREP(false, Lifecycle.BEFORE_START_EVENT),
STARTING(true, Lifecycle.START_EVENT),
STARTED(true, Lifecycle.AFTER_START_EVENT),
STOPPING_PREP(true, Lifecycle.BEFORE_STOP_EVENT),
STOPPING(false, Lifecycle.STOP_EVENT),
STOPPED(false, Lifecycle.AFTER_STOP_EVENT),
+ DESTROYED(false, Lifecycle.DESTROY_EVENT),
FAILED(false, null),
- MUST_STOP(true, null);
+ MUST_STOP(true, null),
+ MUST_DESTROY(true, null);
private final boolean available;
private final String lifecycleEvent;
* @param service The Service to be removed
*/
public void removeService(Service service);
-
- /**
- * Invoke a pre-startup initialization. This is used to allow connectors
- * to bind to restricted ports under Unix operating environments.
- *
- * @exception LifecycleException If this server was already initialized.
- */
- public void initialize()
- throws LifecycleException;
}
public void removeConnector(Connector connector);
/**
- * Invoke a pre-startup initialization. This is used to allow connectors
- * to bind to restricted ports under Unix operating environments.
- *
- * @exception LifecycleException If this server was already initialized.
- */
- public void initialize() throws LifecycleException;
-
- /**
* Adds a named executor to the service
* @param ex Executor
*/
/**
- * Has this component been initialized yet?
- */
- protected boolean initialized = false;
-
-
- /**
* The shutdown signal to our background thread
*/
protected boolean stopped = false;
return _oname;
}
- /**
- * Initialize this connector (create ServerSocket here!)
- */
- public void initialize()
- throws LifecycleException
- {
- if (initialized) {
- if(log.isInfoEnabled())
- log.info(sm.getString("coyoteConnector.alreadyInitialized"));
- return;
- }
-
- this.initialized = true;
-
- if (oname == null) {
- try {
- // we are loaded directly, via API - and no name was given to us
- // Engine name is used as domain name for MBeans
- oname = createObjectName(container.getName(), "Connector");
- Registry.getRegistry(null, null)
- .registerComponent(this, oname, null);
- controller=oname;
- } catch (Exception e) {
- log.error( "Error registering connector ", e);
- }
- if(log.isDebugEnabled())
- log.debug("Creating name for connector " + oname);
- }
-
- // Initializa adapter
- adapter = new CoyoteAdapter(this);
- protocolHandler.setAdapter(adapter);
-
- IntrospectionUtils.setProperty(protocolHandler, "jkHome",
- System.getProperty("catalina.base"));
-
- try {
- protocolHandler.init();
- } catch (Exception e) {
- throw new LifecycleException
- (sm.getString
- ("coyoteConnector.protocolHandlerInitializationFailed", e));
- }
- }
-
/**
* Pause the connector.
*/
@Override
protected void startInternal() throws LifecycleException {
- if( !initialized )
- initialize();
setState(LifecycleState.STARTING);
log.debug("Found engine " + obj + " " + obj.getClass());
container=(Container)obj;
- // Internal initialize - we now have the Engine
- initialize();
-
if(log.isDebugEnabled())
log.debug("Initialized");
// As a side effect we'll get the container field set
}
}
- public void init() throws Exception {
+ @Override
+ protected void initInternal() throws LifecycleException {
- if( this.getService() != null ) {
- if(log.isDebugEnabled())
- log.debug( "Already configured" );
- return;
- }
if( container==null ) {
findContainer();
}
+
+ if (oname == null) {
+ try {
+ // we are loaded directly, via API - and no name was given to us
+ // Engine name is used as domain name for MBeans
+ oname = createObjectName(container.getName(), "Connector");
+ Registry.getRegistry(null, null)
+ .registerComponent(this, oname, null);
+ controller=oname;
+ } catch (Exception e) {
+ log.error( "Error registering connector ", e);
+ }
+ if(log.isDebugEnabled())
+ log.debug("Creating name for connector " + oname);
+ }
+
+ // Initializa adapter
+ adapter = new CoyoteAdapter(this);
+ protocolHandler.setAdapter(adapter);
+
+ IntrospectionUtils.setProperty(protocolHandler, "jkHome",
+ System.getProperty("catalina.base"));
+
+ try {
+ protocolHandler.init();
+ } catch (Exception e) {
+ throw new LifecycleException
+ (sm.getString
+ ("coyoteConnector.protocolHandlerInitializationFailed", e));
+ }
+
}
- public void destroy() throws Exception {
+ @Override
+ protected void destroyInternal() {
if( oname!=null && controller==oname ) {
if(log.isDebugEnabled())
log.debug("Unregister itself " + oname );
#
# CoyoteConnector
#
-coyoteConnector.alreadyInitialized=The connector has already been initialized
coyoteConnector.cannotRegisterProtocol=Cannot register MBean for the Protocol
coyoteConnector.protocolHandlerDestroyFailed=Protocol handler destroy failed: {0}
coyoteConnector.protocolHandlerInitializationFailed=Protocol handler initialization failed: {0}
# limitations under the License.
#
# CoyoteConnector
-coyoteConnector.alreadyInitialized = Ya ha sido inicializado el conector
coyoteConnector.cannotRegisterProtocol = No puedo registrar MBean para el Protocolo
coyoteConnector.protocolHandlerDestroyFailed = Fall\u00F3 la destrucci\u00F3n del manejador de protocolo\: {0}
coyoteConnector.protocolHandlerInitializationFailed = Fall\u00F3 la inicializaci\u00F3n del manejador de protocolo\: {0}
# CoyoteConnector
#
-coyoteConnector.alreadyInitialized=Le connecteur a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9
coyoteConnector.cannotRegisterProtocol=Impossible d''enregistrer le MBean pour le Protocol
coyoteConnector.protocolHandlerDestroyFailed=La destruction du gestionnaire de protocole a \u00e9chou\u00e9: {0}
coyoteConnector.protocolHandlerInitializationFailed=L''initialisation du gestionnaire de protocole a \u00e9chou\u00e9: {0}
# CoyoteConnector
#
-coyoteConnector.alreadyInitialized=\u30b3\u30cd\u30af\u30bf\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059
coyoteConnector.cannotRegisterProtocol=\u305d\u306e\u30d7\u30ed\u30c8\u30b3\u30eb\u306bMBean\u3092\u767b\u9332\u3067\u304d\u307e\u305b\u3093
coyoteConnector.protocolHandlerDestroyFailed=\u30d7\u30ed\u30c8\u30b3\u30eb\u30cf\u30f3\u30c9\u30e9\u306e\u5ec3\u68c4\u306b\u5931\u6557\u3057\u307e\u3057\u305f: {0}
coyoteConnector.protocolHandlerInitializationFailed=\u30d7\u30ed\u30c8\u30b3\u30eb\u30cf\u30f3\u30c9\u30e9\u306e\u521d\u671f\u5316\u306b\u5931\u6557\u3057\u307e\u3057\u305f: {0}
import javax.servlet.ServletSecurityElement;
import org.apache.catalina.Context;
+import org.apache.catalina.LifecycleState;
import org.apache.catalina.Wrapper;
import org.apache.catalina.deploy.SecurityCollection;
import org.apache.catalina.deploy.SecurityConstraint;
getName(), context.getPath()));
}
- if (context.isInitialized()) {
+ if (!context.getState().equals(LifecycleState.STARTING_PREP)) {
throw new IllegalStateException(sm.getString(
"applicationServletRegistration.setServletSecurity.ise",
getName(), context.getPath()));
import java.util.Hashtable;
import java.util.Iterator;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanException;
import javax.management.MBeanRegistration;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
+import javax.management.ReflectionException;
import javax.naming.directory.DirContext;
import javax.servlet.ServletException;
/**
- * Has this component been initialized?
- */
- protected boolean initialized=false;
-
- /**
* Will children be started automatically when they are added.
*/
protected boolean startChildren = true;
*
* @throws Exception
*/
- public void init() throws Exception {
-
- if( this.getParent() == null ) {
- // "Life" update
- ObjectName parentName=getParentName();
-
- //log.info("Register " + parentName );
- if( parentName != null &&
- mserver.isRegistered(parentName))
- {
- mserver.invoke(parentName, "addChild", new Object[] { this },
- new String[] {"org.apache.catalina.Container"});
+ @Override
+ protected void initInternal() throws LifecycleException{
+
+ try {
+ if( this.getParent() == null ) {
+ // "Life" update
+ ObjectName parentName;
+ parentName = getParentName();
+
+ //log.info("Register " + parentName );
+ if( parentName != null &&
+ mserver.isRegistered(parentName))
+ {
+ mserver.invoke(parentName, "addChild", new Object[] { this },
+ new String[] {"org.apache.catalina.Container"});
+ }
}
+ } catch (MalformedObjectNameException e) {
+ throw new LifecycleException(e);
+ } catch (InstanceNotFoundException e) {
+ throw new LifecycleException(e);
+ } catch (ReflectionException e) {
+ throw new LifecycleException(e);
+ } catch (MBeanException e) {
+ throw new LifecycleException(e);
}
- initialized=true;
}
public ObjectName getParentName() throws MalformedObjectNameException {
return null;
}
- public void destroy() throws Exception {
- if (getState().isAvailable()) {
- stop();
- }
- initialized=false;
+ @Override
+ protected void destroyInternal() throws LifecycleException {
// unregister this component
if ( oname != null ) {
parent.removeChild(this);
}
- // Stop our child containers, if any
- Container children[] = findChildren();
- for (int i = 0; i < children.length; i++) {
- removeChild(children[i]);
- }
-
}
// ------------------------------------------------------- Pipeline Methods
standardHost.warURL=Invalid URL for web application archive: {0}
standardHost.validationEnabled=XML validation enabled
standardHost.validationDisabled=XML validation disabled
-standardServer.initialize.initialized=This server has already been initialized
standardServer.shutdownViaPort=A valid shutdown command was received via the shutdown port. Stopping the Server instance.
standardService.connector.failed=Failed to start connector [{0}]
-standardService.initialize.initialized=This service has already been initialized
standardService.initialize.failed=Service initializing at {0} failed
standardService.register.failed=Error registering Service at domain {0}
standardService.start.name=Starting service {0}
standardHost.warURL = URL inv\u00E1lida para archivo de aplicaci\u00F3n web\: {0}
standardHost.validationEnabled = Activada la validaci\u00F3n XML
standardHost.validationDisabled = Desactivada la validaci\u00F3n XML
-standardServer.initialize.initialized = Ya se ha inicializado este servidor
-standardService.initialize.initialized = Ya ha sido inicializado este servicio
standardService.initialize.failed = Servicio inicializando en {0} fall\u00F3
standardService.register.failed = Error registrando servicio en dominio {0}
standardService.start.name = Arrancando servicio {0}
standardHost.unfoundContext=Impossible de trouver un contexte pour l''URI {0} demand\u00e9e
standardHost.warRequired=Une URL vers l''archive d''application web (war) est n\u00e9cessaire
standardHost.warURL=URL vers l''archive d''application web (war) invalide: {0}
-standardServer.initialize.initialized=Ce serveur a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9
-standardService.initialize.initialized=Ce service a d\u00e9j\u00e0 \u00e9t\u00e9 initialis\u00e9
standardService.start.name=D\u00e9marrage du service {0}
standardService.stop.name=Arr\u00eat du service {0}
standardWrapper.allocate=Erreur d''allocation \u00e0 une instance de servlet
standardHost.warURL=Web\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u5bfe\u3059\u308b\u7121\u52b9\u306aURL\u3067\u3059: {0}
standardHost.validationEnabled=XML\u691c\u8a3c\u306f\u6709\u52b9\u3067\u3059
standardHost.validationDisabled=XML\u691c\u8a3c\u306f\u7121\u52b9\u3067\u3059
-standardServer.initialize.initialized=\u3053\u306e\u30b5\u30fc\u30d0\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059
-standardService.initialize.initialized=\u3053\u306e\u30b5\u30fc\u30d3\u30b9\u306f\u65e2\u306b\u521d\u671f\u5316\u3055\u308c\u3066\u3044\u307e\u3059
standardService.start.name=\u30b5\u30fc\u30d3\u30b9 {0} \u3092\u8d77\u52d5\u3057\u307e\u3059
standardService.stop.name=\u30b5\u30fc\u30d3\u30b9 {0} \u3092\u505c\u6b62\u3057\u307e\u3059
standardWrapper.allocate=\u30b5\u30fc\u30d6\u30ec\u30c3\u30c8\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3092\u5272\u308a\u5f53\u3066\u4e2d\u306e\u30a8\u30e9\u30fc\u3067\u3059
}
- /**
- * Has this context been initialized?
- */
- public boolean isInitialized() {
- return initialized;
- }
-
// -------------------------------------------------------- Context Methods
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( !initialized ) {
- try {
- init();
- } catch( Exception ex ) {
- throw new LifecycleException("Error initializaing ", ex);
- }
- }
if(log.isDebugEnabled())
log.debug("Starting " + ("".equals(getName()) ? "ROOT" : getName()));
*
*/
@Override
- public void destroy() throws Exception {
+ protected void destroyInternal() throws LifecycleException {
if( oname != null ) {
// Send j2ee.object.deleted notification
Notification notification =
sequenceNumber++);
broadcaster.sendNotification(notification);
}
- super.destroy();
+ super.destroyInternal();
// Notify our interested LifecycleListeners
fireLifecycleEvent(DESTROY_EVENT, null);
}
@Override
- public void init() throws Exception {
+ protected void initInternal() throws LifecycleException {
if( this.getParent() == null ) {
- ObjectName parentName=getParentName();
+ ObjectName parentName;
+ try {
+ parentName = getParentName();
+ } catch (MalformedObjectNameException e1) {
+ throw new LifecycleException(e1);
+ }
if( ! mserver.isRegistered(parentName)) {
if(log.isDebugEnabled())
StandardHost host=new StandardHost();
host.setName(hostName);
host.setAutoDeploy(false);
- Registry.getRegistry(null, null)
- .registerComponent(host, parentName, null);
+ try {
+ Registry.getRegistry(null, null)
+ .registerComponent(host, parentName, null);
+ } catch (Exception e) {
+ throw new LifecycleException(e);
+ }
// We could do it the hard way...
//mserver.invoke(parentName, "init", new Object[] {}, new String[] {} );
// or same thing easier:
}
} catch (Exception e) {
log.warn("Error creating ContextConfig for " + parentName, e);
- throw e;
+ throw new LifecycleException(e);
}
this.addLifecycleListener(config);
mserver.invoke(parentName, "addChild", new Object[] { this },
new String[] {"org.apache.catalina.Container"});
} catch (Exception e) {
- destroy();
- throw e;
- }
- // It's possible that addChild may have started us
- if( initialized ) {
- return;
+ throw new LifecycleException(e);
}
}
if (processTlds) {
this.addLifecycleListener(new TldConfig());
}
- super.init();
+ super.initInternal();
// Notify our interested LifecycleListeners
fireLifecycleEvent(INIT_EVENT, null);
}
- private boolean initialized=false;
-
@Override
- public void init() {
- if( initialized ) return;
- initialized=true;
+ protected void initInternal() {
if( oname==null ) {
// not registered in JMX yet - standalone mode
try {
service=new StandardService();
service.setContainer( this );
- service.initialize();
+ service.init();
} catch( Throwable t ) {
log.error(t);
}
}
@Override
- public void destroy() throws LifecycleException {
- if( ! initialized ) return;
- initialized=false;
+ protected void destroyInternal() throws LifecycleException {
// if we created it, make sure it's also destroyed
// this call implizit this.stop()
// registry - and stop using the static.
Registry.getRegistry(null, null).resetMetadata();
+ super.destroyInternal();
}
/**
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( !initialized ) {
- init();
- }
-
// Look for a realm - that may have been configured earlier.
// If the realm is added after context - it'll set itself.
if( realm == null ) {
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( ! initialized )
- init();
-
// Look for a realm - that may have been configured earlier.
// If the realm is added after context - it'll set itself.
if( realm == null ) {
}
}
- private boolean initialized=false;
-
@Override
- public void init() {
- if( initialized ) return;
- initialized=true;
+ protected void initInternal() {
// already registered.
if( getParent() == null ) {
}
@Override
- public void destroy() throws Exception {
+ public void destroyInternal() throws LifecycleException {
// destroy our child containers, if any
Container children[] = findChildren();
- super.destroy();
+ super.destroyInternal();
for (int i = 0; i < children.length; i++) {
if(children[i] instanceof StandardContext)
((StandardContext)children[i]).destroy();
}
+ @Override
+ protected void initInternal() {
+ // NOOP
+ }
+
+
/**
* Start {@link Valve}s) in this pipeline and implement the requirements
* of {@link LifecycleBase#startInternal()}.
}
+ @Override
+ protected void destroyInternal() {
+ // NOOP
+ }
+
+
/**
* Return a String representation of this component.
*/
/**
- * Has this component been initialized?
- */
- private boolean initialized = false;
-
-
- /**
* The property change support for this component.
*/
protected PropertyChangeSupport support = new PropertyChangeSupport(this);
results[services.length] = service;
services = results;
- if (initialized) {
- try {
- service.initialize();
- } catch (LifecycleException e) {
- log.error(e);
- }
- }
-
if (getState().isAvailable()) {
try {
service.start();
}
- public void init() throws Exception {
- initialize();
- }
-
/**
* Invoke a pre-startup initialization. This is used to allow connectors
* to bind to restricted ports under Unix operating environments.
*/
- public void initialize()
- throws LifecycleException
- {
- if (initialized) {
- log.info(sm.getString("standardServer.initialize.initialized"));
- return;
- }
- fireLifecycleEvent(INIT_EVENT, null);
- initialized = true;
+ @Override
+ protected void initInternal() throws LifecycleException {
if( oname==null ) {
try {
// Initialize our defined Services
for (int i = 0; i < services.length; i++) {
- services[i].initialize();
+ services[i].init();
}
}
+ protected void destroyInternal() {
+ // NOOP
+ }
+
protected String type;
protected String domain;
protected String suffix;
protected Container container = null;
- /**
- * Has this component been initialized?
- */
- protected boolean initialized = false;
-
-
// ------------------------------------------------------------- Properties
results[connectors.length] = connector;
connectors = results;
- if (initialized) {
- try {
- connector.initialize();
- } catch (LifecycleException e) {
- log.error("Connector.initialize", e);
- }
- }
-
if (getState().isAvailable()) {
try {
((Lifecycle) connector).start();
@Override
protected void startInternal() throws LifecycleException {
- if( ! initialized )
- init();
-
if(log.isInfoEnabled())
log.info(sm.getString("standardService.start.name", this.name));
setState(LifecycleState.STARTING);
* Invoke a pre-startup initialization. This is used to allow connectors
* to bind to restricted ports under Unix operating environments.
*/
- public void initialize()
- throws LifecycleException
- {
- // Service shouldn't be used with embedded, so it doesn't matter
- if (initialized) {
- if(log.isInfoEnabled())
- log.info(sm.getString("standardService.initialize.initialized"));
- return;
- }
- initialized = true;
+ @Override
+ protected void initInternal() throws LifecycleException {
if( oname==null ) {
try {
// Hack - Server should be deprecated...
Container engine=this.getContainer();
- domain=engine.getName();
+
+ if (engine == null) {
+ // TODO - Get this form elsewhere
+ domain = "Catalina";
+ } else {
+ domain = engine.getName();
+ }
oname=new ObjectName(domain + ":type=Service,serviceName="+name);
this.controller=oname;
Registry.getRegistry(null, null)
synchronized (connectors) {
for (int i = 0; i < connectors.length; i++) {
try {
- connectors[i].initialize();
+ connectors[i].init();
} catch (Exception e) {
log.error(sm.getString(
"standardService.connector.failed",
}
}
- public void destroy() throws LifecycleException {
- if(getState().isAvailable()) stop();
+ @Override
+ protected void destroyInternal() {
// FIXME unregister should be here probably -- stop doing that ?
}
- public void init() {
- try {
- initialize();
- } catch( Throwable t ) {
- log.error(sm.getString("standardService.initialize.failed",domain),t);
- }
- }
-
protected String type;
protected String domain;
protected String suffix;
// ---------------------------------------------- Public Methods
+ @Override
+ protected void initInternal() {
+ // NOOP
+ }
+
+
/**
* Start the component and implement the requirements
* of {@link LifecycleBase#startInternal()}.
executor = null;
taskqueue = null;
}
+
+
+ @Override
+ protected void destroyInternal() {
+ // NOOP
+ }
+
public void execute(Runnable command, long timeout, TimeUnit unit) {
if ( executor != null ) {
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( !initialized ) {
- try {
- init();
- } catch( Exception ex ) {
- throw new LifecycleException("Error initializaing ", ex);
- }
- }
-
try {
CatalinaCluster catclust = (CatalinaCluster)this.getCluster();
if (this.context == null) this.context = new ReplApplContext(this);
@Override
protected synchronized void startInternal() throws LifecycleException {
- if (!initialized) init();
-
// Force initialization of the random number generator
generateSessionId();
cluster.removeManager(this);
this.random = null;
- if( initialized ) {
- destroy();
- }
+ setState(LifecycleState.MUST_DESTROY);
}
@Override
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
- if (!initialized) init();
// Force initialization of the random number generator
generateSessionId();
this.random = null;
getCluster().removeManager(this);
replicationValve = null;
- if (initialized) {
- destroy();
- }
+
+ setState(LifecycleState.MUST_DESTROY);
}
// ----------------------------------------- PropertyChangeListener Methods
// ------------------------------------------------------ public
+ @Override
+ protected void initInternal() {
+ // NOOP
+ }
+
+
/**
* Start Cluster and implement the requirements
* of {@link LifecycleBase#startInternal()}.
}
+ @Override
+ protected void destroyInternal() {
+ // NOOP
+ }
+
+
/**
* Return a String rendering of this object.
*/
}
+ @Override
+ public void init() {
+ // NOOP
+ }
+
+
/**
* Start the class loader.
*
}
+ @Override
+ public void destroy() {
+ // NOOP
+ }
+
+
/**
* Used to periodically signal to the classloader to release
* JAR resources.
}
- private boolean initialized=false;
-
- public void init() {
- initialized=true;
+ @Override
+ protected void initInternal() {
if( oname==null ) {
// not registered yet - standalone or API
}
}
- public void destroy() {
+ @Override
+ protected void destroyInternal() {
if( controller==oname ) {
// Self-registration, undo it
Registry.getRegistry(null, null).unregisterComponent(oname);
oname = null;
}
- initialized = false;
-
}
/**
@Override
protected void startInternal() throws LifecycleException {
- if( ! initialized ) init();
-
if (log.isDebugEnabled())
log.debug(sm.getString("webappLoader.starting"));
classLoader = null;
- destroy();
+ setState(LifecycleState.MUST_DESTROY);
}
@Override
protected void startInternal() throws LifecycleException {
- if( !initialized ) {
- init();
- }
-
// Create a MessageDigest instance for credentials, if desired
if (digest != null) {
try {
// Clean up allocated resources
md = null;
- destroy();
+ setState(LifecycleState.MUST_DESTROY);
}
}
- public void destroy() {
+ @Override
+ protected void destroyInternal() {
// unregister this realm
if ( oname!=null ) {
// NOOP in base class
}
- protected boolean initialized=false;
-
- public void init() {
- if( initialized && container != null ) return;
+ @Override
+ protected void initInternal() {
// We want logger as soon as possible
if (container != null) {
this.containerLog = container.getLogger();
}
- initialized=true;
if( container== null ) {
ObjectName parent=null;
// Register with the parent
// number of duplicated session ids - anything >0 means we have problems
protected int duplicates=0;
- protected boolean initialized=false;
-
/**
* Processing time during session expiration.
*/
}
- public void destroy() {
+ @Override
+ protected void destroyInternal() {
if( oname != null )
Registry.getRegistry(null, null).unregisterComponent(oname);
if (randomIS!=null) {
randomIS=null;
}
- initialized=false;
oname = null;
}
- public void init() {
- if( initialized ) return;
- initialized=true;
+ @Override
+ protected void initInternal() {
if( oname==null ) {
try {
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( ! initialized )
- init();
-
// Force initialization of the random number generator
if (log.isDebugEnabled())
log.debug("Force random number initialization starting");
// Require a new random number generator if we are restarted
this.random = null;
- if( initialized )
- destroy();
+ setState(LifecycleState.MUST_DESTROY);
}
@Override
protected synchronized void startInternal() throws LifecycleException {
- if( ! initialized )
- init();
-
// Force initialization of the random number generator
if (log.isDebugEnabled())
log.debug("Force random number initialization starting");
// Require a new random number generator if we are restarted
this.random = null;
- if( initialized ) {
- destroy();
- }
+ setState(LifecycleState.MUST_DESTROY);
}
}
+ @Override
+ protected void initInternal() {
+ // NOOP
+ }
+
+
/**
* Start this component and implement the requirements
* of {@link LifecycleBase#startInternal()}.
}
+ @Override
+ protected void destroyInternal() {
+ // NOOP
+ }
+
+
/**
* Return a String rendering of this object.
*/
// Start the new server
try {
- getServer().initialize();
+ getServer().init();
} catch (LifecycleException e) {
if (Boolean.getBoolean("org.apache.catalina.startup.EXIT_ON_INIT_FAILURE"))
throw new java.lang.Error(e);
}
@Override
- public void destroy() {
-
+ protected void destroyInternal() {
+ // NOOP
}
/**
setState(LifecycleState.STARTING);
lifecycle.fireLifecycleEvent(START_EVENT, null);
- initialized = true;
// Start our defined Engines first
for (int i = 0; i < engines.length; i++) {
// Start our defined Connectors second
for (int i = 0; i < connectors.length; i++) {
- connectors[i].initialize();
((Lifecycle) connectors[i]).start();
}
public void start() throws LifecycleException {
getServer();
getConnector();
- server.initialize();
server.start();
}
}
+ public synchronized final void init() throws LifecycleException {
+ if (!state.equals(LifecycleState.NEW)) {
+ invalidTransition(Lifecycle.INIT_EVENT);
+ }
+
+ // TODO - Check for JMX support and register if required
+
+ initInternal();
+
+ setState(LifecycleState.INITIALIZED);
+ }
+
+
+ protected abstract void initInternal() throws LifecycleException;
+
/**
* {@inheritDoc}
*/
@Override
- public final void start() throws LifecycleException {
+ public synchronized final void start() throws LifecycleException {
- synchronized (this) {
- if (LifecycleState.STARTING_PREP.equals(state) ||
- LifecycleState.STARTING.equals(state) ||
- LifecycleState.STARTED.equals(state)) {
-
- if (log.isDebugEnabled()) {
- Exception e = new LifecycleException();
- log.debug(sm.getString("lifecycleBase.alreadyStarted",
- toString()), e);
- } else if (log.isInfoEnabled()) {
- log.info(sm.getString("lifecycleBase.alreadyStarted",
- toString()));
- }
-
- return;
- }
+ if (LifecycleState.STARTING_PREP.equals(state) ||
+ LifecycleState.STARTING.equals(state) ||
+ LifecycleState.STARTED.equals(state)) {
- if (!state.equals(LifecycleState.NEW) &&
- !state.equals(LifecycleState.STOPPED)) {
- invalidTransition(Lifecycle.BEFORE_START_EVENT);
+ if (log.isDebugEnabled()) {
+ Exception e = new LifecycleException();
+ log.debug(sm.getString("lifecycleBase.alreadyStarted",
+ toString()), e);
+ } else if (log.isInfoEnabled()) {
+ log.info(sm.getString("lifecycleBase.alreadyStarted",
+ toString()));
}
-
- // Set state and fire event separately rather than via setState()
- // so event fires outside of sync boundary
- state = LifecycleState.STARTING_PREP;
+
+ return;
}
- lifecycle.fireLifecycleEvent(Lifecycle.BEFORE_START_EVENT, null);
+ if (state.equals(LifecycleState.NEW)) {
+ init();
+ } else if (!state.equals(LifecycleState.INITIALIZED) &&
+ !state.equals(LifecycleState.STOPPED)) {
+ invalidTransition(Lifecycle.BEFORE_START_EVENT);
+ }
+
+ setState(LifecycleState.STARTING_PREP);
startInternal();
* {@inheritDoc}
*/
@Override
- public final void stop() throws LifecycleException {
-
- synchronized (this) {
- if (LifecycleState.STOPPING_PREP.equals(state) ||
- LifecycleState.STOPPING.equals(state) ||
- LifecycleState.STOPPED.equals(state)) {
-
- if (log.isDebugEnabled()) {
- Exception e = new LifecycleException();
- log.debug(sm.getString("lifecycleBase.alreadyStopped",
- toString()), e);
- } else if (log.isInfoEnabled()) {
- log.info(sm.getString("lifecycleBase.alreadyStopped",
- toString()));
- }
-
- return;
+ public synchronized final void stop() throws LifecycleException {
+
+ if (LifecycleState.STOPPING_PREP.equals(state) ||
+ LifecycleState.STOPPING.equals(state) ||
+ LifecycleState.STOPPED.equals(state)) {
+
+ if (log.isDebugEnabled()) {
+ Exception e = new LifecycleException();
+ log.debug(sm.getString("lifecycleBase.alreadyStopped",
+ toString()), e);
+ } else if (log.isInfoEnabled()) {
+ log.info(sm.getString("lifecycleBase.alreadyStopped",
+ toString()));
}
- if (state.equals(LifecycleState.NEW)) {
- state = LifecycleState.STOPPED;
- return;
- }
+ return;
+ }
+
+ if (state.equals(LifecycleState.NEW)) {
+ state = LifecycleState.STOPPED;
+ return;
+ }
- if (!state.equals(LifecycleState.STARTED) &&
- !state.equals(LifecycleState.FAILED) &&
- !state.equals(LifecycleState.MUST_STOP)) {
- invalidTransition(Lifecycle.BEFORE_STOP_EVENT);
- }
-
- // Set state and fire event separately rather than via setState()
- // so event fires outside of sync boundary
- state = LifecycleState.STOPPING_PREP;
+ if (!state.equals(LifecycleState.STARTED) &&
+ !state.equals(LifecycleState.FAILED) &&
+ !state.equals(LifecycleState.MUST_STOP)) {
+ invalidTransition(Lifecycle.BEFORE_STOP_EVENT);
}
- lifecycle.fireLifecycleEvent(Lifecycle.BEFORE_STOP_EVENT, null);
+ setState(LifecycleState.STOPPING_PREP);
stopInternal();
- // Shouldn't be necessary but acts as a check that sub-classes are doing
- // what they are supposed to.
- if (!state.equals(LifecycleState.STOPPING)) {
- invalidTransition(Lifecycle.AFTER_STOP_EVENT);
- }
+ if (state.equals(LifecycleState.MUST_DESTROY)) {
+ // Complete stop process first
+ setState(LifecycleState.STOPPED);
- setState(LifecycleState.STOPPED);
+ destroy();
+ } else {
+ // Shouldn't be necessary but acts as a check that sub-classes are doing
+ // what they are supposed to.
+ if (!state.equals(LifecycleState.STOPPING)) {
+ invalidTransition(Lifecycle.AFTER_STOP_EVENT);
+ }
+
+ setState(LifecycleState.STOPPED);
+ }
}
protected abstract void stopInternal() throws LifecycleException;
+ public synchronized final void destroy() throws LifecycleException {
+ if (!state.equals(LifecycleState.STOPPED) &&
+ !state.equals(LifecycleState.FAILED)) {
+ invalidTransition(Lifecycle.DESTROY_EVENT);
+ }
+
+ // TODO - Check for JMX support and de-register if required
+
+ destroyInternal();
+
+ setState(LifecycleState.DESTROYED);
+ }
+
+
+ protected abstract void destroyInternal() throws LifecycleException;
+
/**
* {@inheritDoc}
*/
*
* @param state The new state for this component
*/
- protected void setState(LifecycleState state) {
+ protected synchronized void setState(LifecycleState state) {
setState(state, null);
}
}
+ protected void initInternal() {
+ // NOOP
+ }
+
/**
* Start this component and implement the requirements
* of {@link LifecycleBase#startInternal()}.
}
+ @Override
+ protected void destroyInternal() {
+ // NOOP
+ }
+
+
/**
* Return a String rendering of this object.
*/