InstanceSupportpublic final class InstanceSupport extends Object Support class to assist in firing InstanceEvent notifications to
registered InstanceListeners. |
Fields Summary |
---|
private ReadWriteLock | listenersLock | private Lock | listenersReadLock | private Lock | listenersWriteLock | private org.apache.catalina.InstanceListener[] | listenersThe set of registered InstanceListeners for event notifications. | private org.apache.catalina.Wrapper | wrapperThe source component for instance events that we will fire. |
Constructors Summary |
---|
public InstanceSupport(org.apache.catalina.Wrapper wrapper)Construct a new InstanceSupport object associated with the specified
Instance component.
super();
this.wrapper = wrapper;
|
Methods Summary |
---|
public void | addInstanceListener(org.apache.catalina.InstanceListener listener)Add a lifecycle event listener to this component.
/* SJSAS 6374619
synchronized (listeners) {
InstanceListener results[] =
new InstanceListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
}
*/
// START SJSAS 6374619
listenersWriteLock.lock();
try {
InstanceListener results[] =
new InstanceListener[listeners.length + 1];
for (int i = 0; i < listeners.length; i++)
results[i] = listeners[i];
results[listeners.length] = listener;
listeners = results;
} finally {
listenersWriteLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
request, response);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Servlet servlet, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.Throwable exception)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
request, response, exception);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Filter filter)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.
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();
}
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Filter filter, java.lang.Throwable exception)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, filter, type,
exception);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Filter filter, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, filter, type,
request, response);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Filter filter, javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, java.lang.Throwable exception)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, filter, type,
request, response, exception);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Servlet servlet)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, servlet, type);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public void | fireInstanceEvent(java.lang.String type, javax.servlet.Servlet servlet, java.lang.Throwable exception)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.
if (listeners.length == 0)
return;
InstanceEvent event = new InstanceEvent(wrapper, servlet, type,
exception);
/* SJSAS 6374619
InstanceListener interested[] = null;
synchronized (listeners) {
interested = (InstanceListener[]) listeners.clone();
}
for (int i = 0; i < interested.length; i++)
interested[i].instanceEvent(event);
*/
// START SJSAS 6374619
listenersReadLock.lock();
try {
for (int i = 0; i < listeners.length; i++)
listeners[i].instanceEvent(event);
} finally {
listenersReadLock.unlock();
}
// END SJSAS 6374619
| public org.apache.catalina.Wrapper | getWrapper()Return the Wrapper with which we are associated.
// ------------------------------------------------------------- Properties
return (this.wrapper);
| public void | removeInstanceListener(org.apache.catalina.InstanceListener listener)Remove a lifecycle event listener from this component.
/* SJSAS 6374619
synchronized (listeners) {
int n = -1;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
n = i;
break;
}
}
if (n < 0)
return;
InstanceListener results[] =
new InstanceListener[listeners.length - 1];
int j = 0;
for (int i = 0; i < listeners.length; i++) {
if (i != n)
results[j++] = listeners[i];
}
listeners = results;
}
*/
// START SJSAS 6374619
listenersWriteLock.lock();
try {
int n = -1;
for (int i = 0; i < listeners.length; i++) {
if (listeners[i] == listener) {
n = i;
break;
}
}
if (n < 0)
return;
InstanceListener results[] =
new InstanceListener[listeners.length - 1];
int j = 0;
for (int i = 0; i < listeners.length; i++) {
if (i != n)
results[j++] = listeners[i];
}
listeners = results;
} finally {
listenersWriteLock.unlock();
}
// END SJSAS 6374619
|
|