1

x I have overriden the LifecycleBase.start() method like the following. but in Catalina 8.x this method has become final. Could anyone tell me how to solve this Problem please. Here is the sourcecode

 public void start() throws LifecycleException
{       
    super.start();

    if(condition)
    {
        File checkDataFile = new File(DataFilePath);
        if(containerLog.isDebugEnabled())
            containerLog.debug("checking secureDataFile: " + checkDataFile.getAbsolutePath());

        another code ...
    }
    else
    {
        throw new LifecycleException("illegal arguments");
    }
}

public void stop() throws LifecycleException
{
    // sync via realm-object -> so the stop-event has to wait for active threads finishing their operations
    synchronized(this)
    {
        super.stop();
    }
}
Hasan
  • 296
  • 1
  • 8
  • 23

1 Answers1

2

You may use startInternal() and stopInternal(), both methods are abstract protected and are called respectively by start() and stop() .

Of course don't call super.start() and super.stop() or you are in for a StackOverflowError, since start() and stop()are already calling your custom "internal" methods.

Also read carefully the contract from these two methods :

startInternal()

Sub-classes must ensure that the state is changed to org.apache.catalina.LifecycleState.STARTING during the execution of this method. Changing state will trigger the org.apache.catalina.Lifecycle.START_EVENT event. If a component fails to start it may either throw a org.apache.catalina.LifecycleException which will cause it's parent to fail to start or it can place itself in the error state in which case stop() will be called on the failed component but the parent component will continue to start normally

and

stopInternal()

Sub-classes must ensure that the state is changed to org.apache.catalina.LifecycleState.STOPPING during the execution of this method. Changing state will trigger the org.apache.catalina.Lifecycle.STOP_EVENT event.

If you want to see what happens with more details, look at the code of one of the latest versions of org.apache.catalina.util.LifecycleBase .

Arnaud
  • 17,229
  • 3
  • 31
  • 44