2015-07-19 9:26 GMT+03:00 Manuri Amaya Perera <amaya....@gmail.com>:
> Hi,
>
> I am using tomcat 7.0.34. I've written a simple Lifecycle listener
> implementing org.apache.catalina.LifecycleListener.
>
> I am simply overriding the lifecycleEvent method and printing the event
> type. When a web application is being deployed, the first event I can see
> is before_start.
> But there should be several events before that such as before_init.
>
> Is this the expected behavior?

Reproducible with the current 7.0.63.

This is an expected behaviour.  Context itself is configured by a listener.

The listeners are added by
org.apache.catalina.startup.ContextConfig#processContextConfig() -
parses context.xml files (the global ones and the one for the web
application)
- called from o.a.c.startup.ContextConfig#contextConfig()
- called from o.a.c.startup.ContextConfig#init()
- called from o.a.c.startup.lifecycleEvent() on Lifecycle.AFTER_INIT_EVENT

At the time of the "after_init" event the "before_init" event has
already happened.


For reference, reproduction source code
a sample listener class, to be put into catalina.base/lib/test
[[[
package test;

import org.apache.catalina.LifecycleEvent;
import org.apache.catalina.LifecycleListener;
import org.apache.juli.logging.Log;
import org.apache.juli.logging.LogFactory;

public class TestListener implements LifecycleListener {
    private final Log log = LogFactory.getLog(getClass());
    @Override
    public void lifecycleEvent(LifecycleEvent event) {
        log.info("Event: [" + event.getType() + "]");
    }
}
]]]

configuration, catalina.base/webapps/examples/META-INF/context.xml
[[[
<Context>
<Listener className="test.TestListener" />
</Context>
]]]

Best regards,
Konstantin Kolinko

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to