use of org.apache.catalina.InstanceListener in project Payara by payara.
the class InstanceSupport method fireInstanceEvent.
/**
* 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 filter The relevant Filter for this event
*/
public void fireInstanceEvent(InstanceEvent.EventType type, Filter filter) {
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, filter, type);
InstanceListener[] interested = null;
/* SJSAS XXX
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS XXX
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++) listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
}
use of org.apache.catalina.InstanceListener in project Payara by payara.
the class StandardContext method createWrapper.
/**
* Factory method to create and return a new Wrapper instance, of
* the Java implementation class appropriate for this Context
* implementation. The constructor of the instantiated Wrapper
* will have been called, but no properties will have been set.
* @return
*/
@Override
public Wrapper createWrapper() {
Wrapper wrapper = new StandardWrapper();
synchronized (instanceListeners) {
for (String instanceListener : instanceListeners) {
try {
Class clazz = Class.forName(instanceListener);
wrapper.addInstanceListener((InstanceListener) clazz.newInstance());
} catch (Throwable t) {
String msg = MessageFormat.format(rb.getString(LogFacade.CREATING_INSTANCE_LISTENER_EXCEPTION), instanceListener);
log.log(Level.SEVERE, msg, t);
return (null);
}
}
}
synchronized (instanceListenerInstances) {
for (InstanceListener instanceListenerInstance : instanceListenerInstances) {
wrapper.addInstanceListener(instanceListenerInstance);
}
}
Iterator<String> i = wrapperLifecycles.iterator();
while (i.hasNext()) {
String wrapperLifecycle = i.next();
try {
Class clazz = Class.forName(wrapperLifecycle);
if (wrapper instanceof Lifecycle) {
((Lifecycle) wrapper).addLifecycleListener((LifecycleListener) clazz.newInstance());
}
} catch (Throwable t) {
String msg = MessageFormat.format(rb.getString(LogFacade.CREATING_LIFECYCLE_LISTENER_EXCEPTION), wrapperLifecycle);
log.log(Level.SEVERE, msg, t);
return (null);
}
}
i = wrapperListeners.iterator();
while (i.hasNext()) {
String wrapperListener = i.next();
try {
Class clazz = Class.forName(wrapperListener);
wrapper.addContainerListener((ContainerListener) clazz.newInstance());
} catch (Throwable t) {
String msg = MessageFormat.format(rb.getString(LogFacade.CREATING_CONTAINER_LISTENER_EXCEPTION), wrapperListener);
log.log(Level.SEVERE, msg, t);
return (null);
}
}
return (wrapper);
}
Aggregations