Given an implementation of a custom valve that extends PicketLinkAuthenticator, which (eventually) extends ValveBase, I would expect that the various lifecycle hooks should be called when the custom valve is loaded. According to the Javadoc for WebValve:
protected void initInternal() throws LifecycleExceptionDescription copied from class:
LifecycleMBeanBaseSub-classes wishing to perform additional initialization should override this method, ensuring that super.initInternal() is the first call in the overriding method.
initInternal in class LifecycleMBeanBaseLifecycleException
And the implementation looking like:
package org.apache.catalina.valves;
...
@Override
protected void initInternal() throws LifecycleException {
super.initInternal();
containerLog = getContainer().getLogger();
}
/**
* Start this component and implement the requirements
* of {@link LifecycleBase#startInternal()}.
*
* @exception LifecycleException if this component detects a fatal error
* that prevents this component from being used
*/
@Override
protected synchronized void startInternal() throws LifecycleException {
setState(LifecycleState.STARTING);
}
I expect that I could override initInternal in my valve to hook into the initialization phase. However, when a custom valve is invoked by reflection, the lifecycle hooks are not invoked:
CustomAuthenticator.<init>() line: 31
NativeConstructorAccessorImpl.newInstance0(Constructor<?>, Object[]) line: not available [native method]
NativeConstructorAccessorImpl.newInstance(Object[]) line: 62
DelegatingConstructorAccessorImpl.newInstance(Object[]) line: 45
Constructor<T>.newInstance(Object...) line: 423
Class<T>.newInstance() line: 442
WebValve.createValve(String, ModuleClassLoader) line: 36
WebValveService.start(StartContext) line: 90
Is this an oversight of the WebValveService implementation or by design? In either case, is there an available init hook that AS will call, so I can add behaviours to my custom module?