use of org.apache.catalina.LifecycleEvent in project sonarqube by SonarSource.
the class TomcatAccessLogTest method log_when_started_and_stopped.
@Test
public void log_when_started_and_stopped() {
Logger logger = mock(Logger.class);
TomcatAccessLog.LifecycleLogger listener = new TomcatAccessLog.LifecycleLogger(logger);
LifecycleEvent event = new LifecycleEvent(mock(Lifecycle.class), "before_init", null);
listener.lifecycleEvent(event);
verifyZeroInteractions(logger);
event = new LifecycleEvent(mock(Lifecycle.class), "after_start", null);
listener.lifecycleEvent(event);
verify(logger).debug("Tomcat is started");
event = new LifecycleEvent(mock(Lifecycle.class), "after_destroy", null);
listener.lifecycleEvent(event);
verify(logger).debug("Tomcat is stopped");
}
use of org.apache.catalina.LifecycleEvent in project tomee by apache.
the class TomEEUndeployTest method tomcatLifecycle.
@Test
public void tomcatLifecycle() throws Exception {
container.start();
assertEquals(0, webapps().length);
final StandardHost standardHost = StandardHost.class.cast(TomcatHelper.getServer().findService("Tomcat").getContainer().findChild("localhost"));
// not done in embedded but that's the way autodeploy works in normal tomcat
final HostConfig listener = new HostConfig();
standardHost.addLifecycleListener(listener);
createWebapp(new File(WORK_DIR, "tomee/webapps/my-webapp"));
listener.lifecycleEvent(new LifecycleEvent(standardHost, Lifecycle.START_EVENT, standardHost));
assertEquals(1, webapps().length);
}
use of org.apache.catalina.LifecycleEvent in project Payara by payara.
the class LifecycleSupport method fireLifecycleEvent.
/**
* Notify all lifecycle event listeners that a particular event has
* occurred for this Container. The default implementation performs
* this notification synchronously using the calling thread.
*
* @param type Event type
* @param data Event data
*/
public void fireLifecycleEvent(String type, Object data) throws LifecycleException {
LifecycleListener[] listenersArray = null;
synchronized (listeners) {
if (listeners.isEmpty()) {
return;
}
listenersArray = listeners.toArray(new LifecycleListener[listeners.size()]);
}
LifecycleEvent event = new LifecycleEvent(lifecycle, type, data);
for (LifecycleListener listenersArray1 : listenersArray) {
listenersArray1.lifecycleEvent(event);
}
}
Aggregations