[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jboss-cvs-commits
Subject:    [jboss-cvs] jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/jca CachedConnectionValve.java
From:       Adrian Brock <ejort () users ! sourceforge ! net>
Date:       2004-02-28 19:08:26
Message-ID: E1Ax9p4-0001Rl-9s () sc8-pr-cvs1 ! sourceforge ! net
[Download RAW message or body]

  User: ejort   
  Date: 04/02/28 11:08:26

  Added:       src/main/org/jboss/web/tomcat/tc5/jca
                        CachedConnectionValve.java
  Log:
  A CachedConnectionValve for Tomcat
  Allows tracking of unclosed connections from servlets/jsp
  
  Revision  Changes    Path
  1.1                  \
jboss-tomcat/src/main/org/jboss/web/tomcat/tc5/jca/CachedConnectionValve.java  
  Index: CachedConnectionValve.java
  ===================================================================
  /*
   * JBoss, the OpenSource WebOS
   *
   * Distributable under LGPL license.
   * See terms of license at gnu.org.
   */
  package org.jboss.web.tomcat.tc5.jca;
  
  import java.io.IOException;
  import java.util.HashSet;
  import java.util.Set;
  
  import javax.resource.ResourceException;
  import javax.servlet.ServletException;
  
  import org.apache.catalina.Lifecycle;
  import org.apache.catalina.LifecycleException;
  import org.apache.catalina.LifecycleListener;
  import org.apache.catalina.Request;
  import org.apache.catalina.Response;
  import org.apache.catalina.ValveContext;
  import org.apache.catalina.valves.ValveBase;
  import org.apache.catalina.util.LifecycleSupport;
  import org.jboss.resource.connectionmanager.CachedConnectionManager;
  
  /**
   * This valve checks for unclosed connections on a servlet request
   * 
   * @author <a href="mailto:adrian@jboss.com">Adrian Brock</a>
   * @version $Revision: 1.1 $
   */
  public class CachedConnectionValve extends ValveBase implements Lifecycle
  {
     /** The info string for this Valve */
     private static final String info = "CachedConnectionValve/1.0";
  
     /** Valve-lifecycle helper object */
     protected LifecycleSupport support = new LifecycleSupport(this);
  
     /** The cached connection manager */
     protected CachedConnectionManager ccm;
  
     /** The unshareable resources */
     protected Set unsharableResources = new HashSet();
     
     /**
      * Create a new valve
      * @param ccm the cached connection manager for the valve
      */
     public CachedConnectionValve(CachedConnectionManager ccm)
     {
        super();
        this.ccm = ccm;
     }
  
     /**
      * Get information about this Valve.
      */
     public String getInfo()
     {
        return info;
     }
  
     public void invoke(Request request, Response response, ValveContext context) \
throws IOException, ServletException  {
        try
        {
           ccm.pushMetaAwareObject(this, unsharableResources);
           try 
           {
              context.invokeNext(request, response);
           }
           finally
           {
              ccm.popMetaAwareObject(unsharableResources);
           }
        }
        catch (ResourceException e)
        {
           throw new ServletException("Error invoking cached connection manager", e);
        }
     }
  
     // Lifecycle-interface
     public void addLifecycleListener(LifecycleListener listener)
     {
        support.addLifecycleListener(listener);
     }
  
     public void removeLifecycleListener(LifecycleListener listener)
     {
        support.removeLifecycleListener(listener);
     }
  
     public LifecycleListener[] findLifecycleListeners()
     {
        return support.findLifecycleListeners();
     }
  
     public void start() throws LifecycleException
     {
        // TODO unshareable resources
        support.fireLifecycleEvent(START_EVENT, this);
     }
  
     public void stop() throws LifecycleException
     {
        support.fireLifecycleEvent(STOP_EVENT, this);
        unsharableResources.clear();
     }
  
  }
  
  
  


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
jboss-cvs-commits mailing list
jboss-cvs-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-cvs-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic