Base implementation of the {@link Lifecycle} interface that implements the state transition rules for {@link Lifecycle#start()} and {@link Lifecycle#stop()}
if (log.isDebugEnabled()) { log.debug(sm.getString("lifecycleBase.setState", this, state)); }
if (check) { // Must have been triggered by one of the abstract methods (assume // code in this class is correct) // null is never a valid state if (state == null) { invalidTransition("null"); // Unreachable code - here to stop eclipse complaining about // a possible NPE further down the method return; }
// Any method can transition to failed // startInternal() permits STARTING_PREP to STARTING // stopInternal() permits STOPPING_PREP to STOPPING and FAILED to // STOPPING if (!(state == LifecycleState.FAILED || (this.state == LifecycleState.STARTING_PREP && state == LifecycleState.STARTING) || (this.state == LifecycleState.STOPPING_PREP && state == LifecycleState.STOPPING) || (this.state == LifecycleState.FAILED && state == LifecycleState.STOPPING))) { // No other transition permitted invalidTransition(state.name()); } }
/** * @return the domain under which this component will be / has been * registered. */ String getDomain();
/** * Specify the domain under which this component should be registered. Used * with components that cannot (easily) navigate the component hierarchy to * determine the correct domain to use. * * @param domain The name of the domain under which this component should be * registered */ voidsetDomain(String domain);
/** * @return the name under which this component has been registered with JMX. */ ObjectName getObjectName(); }
// org.apache.catalina.util.LifecycleMBeanBase#initInternal /** * Sub-classes wishing to perform additional initialization should override * this method, ensuring that super.initInternal() is the first call in the * overriding method. */ @Override protectedvoidinitInternal()throws LifecycleException {
// If oname is not null then registration has already happened via // preRegister(). if (oname == null) { mserver = Registry.getRegistry(null, null).getMBeanServer();
// org.apache.catalina.util.LifecycleMBeanBase#destroyInternal /** * Sub-classes wishing to perform additional clean-up should override this * method, ensuring that super.destroyInternal() is the last call in the * overriding method. */ @Override protectedvoiddestroyInternal()throws LifecycleException { unregister(oname); }
// Construct an object name with the right domain StringBuilder name = new StringBuilder(getDomain()); name.append(':'); name.append(objectNameKeyProperties);