Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Licensed to the Apache Software Foundation (ASF) under one or more
   * contributor license agreements.  See the NOTICE file distributed with
   * this work for additional information regarding copyright ownership.
   * The ASF licenses this file to You under the Apache License, Version 2.0
   * (the "License"); you may not use this file except in compliance with
   * the License.  You may obtain a copy of the License at
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
  * 
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 
 package org.apache.catalina.util;
 
 
Support class to assist in firing InstanceEvent notifications to registered InstanceListeners.

Author(s):
Craig R. McClanahan
Version:
$Id: InstanceSupport.java 1468 2010-05-07 12:38:52Z remy.maucherat@jboss.com $
 
 
 public final class InstanceSupport {
 
 
     // ----------------------------------------------------------- Constructors
 

    
Construct a new InstanceSupport object associated with the specified Instance component.

Parameters:
wrapper The component that will be the source of events that we fire
 
     public InstanceSupport(Wrapper wrapper) {
 
         super();
         this. = wrapper;
 
     }
 
 
     // ----------------------------------------------------- Instance Variables
 

    
The set of registered InstanceListeners for event notifications.
 
     private InstanceListener listeners[] = new InstanceListener[0];


    
The source component for instance events that we will fire.
 
     private Wrapper wrapper = null;
 
 
     // ------------------------------------------------------------- Properties
 

    
Return the Wrapper with which we are associated.
 
     public Wrapper getWrapper() {
 
         return (this.);
 
     }
 
 
     // --------------------------------------------------------- Public Methods
 

    
Add a lifecycle event listener to this component.

Parameters:
listener The listener to add
 
     public synchronized void addInstanceListener(InstanceListener listener) {
 
         InstanceListener results[] =
            new InstanceListener[. + 1];
        for (int i = 0; i < .i++)
            results[i] = [i];
        results[.] = listener;
         = results;
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
    public void fireInstanceEvent(String typeFilter filter) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
exception Exception that occurred
    public void fireInstanceEvent(String typeFilter filter,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype,
                                                exception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
request The servlet request we are processing
response The servlet response we are processing
    public void fireInstanceEvent(String typeFilter filter,
                                  ServletRequest request,
                                  ServletResponse response) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype,
                                                requestresponse);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
request The servlet request we are processing
response The servlet response we are processing
exception Exception that occurred
    public void fireInstanceEvent(String typeFilter filter,
                                  ServletRequest request,
                                  ServletResponse response,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype,
                                                requestresponseexception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
    public void fireInstanceEvent(String typeServlet servlet) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
exception Exception that occurred
    public void fireInstanceEvent(String typeServlet servlet,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype,
                                                exception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
request The servlet request we are processing
response The servlet response we are processing
    public void fireInstanceEvent(String typeServlet servlet,
                                  ServletRequest request,
                                  ServletResponse response) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype,
                                                requestresponse);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
request The servlet request we are processing
response The servlet response we are processing
exception Exception that occurred
    public void fireInstanceEvent(String typeServlet servlet,
                                  ServletRequest request,
                                  ServletResponse response,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype,
                                                requestresponseexception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
httpEvent The HTTP event we are processing
exception Exception that occurred
    public void fireInstanceEvent(String typeServlet servlet,
                                  HttpEvent httpEvent,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype,
                httpEventexception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
servlet The relevant Servlet for this event
httpEvent The HTTP event we are processing
    public void fireInstanceEvent(String typeServlet servlet,
                                  HttpEvent httpEvent) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(servlettype,
                httpEvent);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
httpEvent The HTTP event we are processing
exception Exception that occurred
    public void fireInstanceEvent(String typeFilter filter,
                                  HttpEvent httpEvent,
                                  Throwable exception) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype,
                httpEventexception);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
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.

Parameters:
type Event type
filter The relevant Filter for this event
httpEvent The HTTP event we are processing
    public void fireInstanceEvent(String typeFilter filter,
                                  HttpEvent httpEvent) {
        if (. == 0)
            return;
        InstanceEvent event = new InstanceEvent(filtertype,
                httpEvent);
        InstanceListener interested[] = ;
        for (int i = 0; i < interested.lengthi++)
            interested[i].instanceEvent(event);
    }


    
Remove a lifecycle event listener from this component.

Parameters:
listener The listener to remove
    public synchronized void removeInstanceListener(InstanceListener listener) {
        int n = -1;
        for (int i = 0; i < .i++) {
            if ([i] == listener) {
                n = i;
                break;
            }
        }
        if (n < 0)
            return;
        InstanceListener results[] =
            new InstanceListener[. - 1];
        int j = 0;
        for (int i = 0; i < .i++) {
            if (i != n)
                results[j++] = [i];
        }
         = results;
    }
New to GrepCode? Check out our FAQ X