avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stephen McConnell <mcconn...@apache.org>
Subject Re: cvs commit: jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/component/servlet AbstractServiceManagerServlet.java
Date Sat, 09 Nov 2002 09:01:35 GMT


Peter Donald wrote:

>hmmm. Read the commit again. It is not against fortress.
>

:-)

Yep - that explains it ... sorry for interuption.

Steve.

>
>On Sat, 9 Nov 2002 19:56, Stephen McConnell wrote:
>  
>
>>Pete:
>>
>>You retract the dependecies declared in the Fortrss build (and related
>>defaults) on the excalibur container package which includes the
>>lifecycle extension interfaces. Seems to me that this will break the
>>build.  Have you changed something else that I havn't noticed?
>>
>>Steve.
>>
>>donaldp@apache.org wrote:
>>    
>>
>>>donaldp     2002/11/09 00:41:04
>>>
>>> Modified:    component build.xml default.properties
>>>              component/src/java/org/apache/avalon/excalibur/component
>>>                       DefaultComponentFactory.java
>>>             
>>>component/src/java/org/apache/avalon/excalibur/component/servlet
>>>AbstractServiceManagerServlet.java
>>> Added:       component/src/java/org/apache/avalon/excalibur/component
>>>                       ComponentProxyGenerator.java
>>> Log:
>>> Move ComponentPorxyGenerator into component package. This results in a
>>>decoupling from container.
>>>
>>> Revision  Changes    Path
>>> 1.27      +6 -8      jakarta-avalon-excalibur/component/build.xml
>>>
>>> Index: build.xml
>>> ===================================================================
>>> RCS file: /home/cvs/jakarta-avalon-excalibur/component/build.xml,v
>>> retrieving revision 1.26
>>> retrieving revision 1.27
>>> diff -u -r1.26 -r1.27
>>> --- build.xml	24 Sep 2002 20:39:52 -0000	1.26
>>> +++ build.xml	9 Nov 2002 08:41:03 -0000	1.27
>>> @@ -16,7 +16,6 @@
>>>          <pathelement location="${logkit.jar}"/>
>>>          <pathelement location="${avalon-framework.jar}"/>
>>>          <pathelement location="${excalibur-collections.jar}"/>
>>> -        <pathelement location="${excalibur-container.jar}"/>
>>>          <pathelement location="${excalibur-logger.jar}"/>
>>>          <pathelement location="${excalibur-instrument.jar}"/>
>>>          <pathelement location="${excalibur-instrument-manager.jar}"/>
>>> @@ -26,7 +25,7 @@
>>>
>>>          <!-- Optional jars -->
>>>          <pathelement location="${servlet.jar}"/>
>>> -
>>> +
>>>          <pathelement path="${java.class.path}"/>
>>>      </path>
>>>
>>> @@ -58,7 +57,7 @@
>>>              <classpath refid="project.class.path"/>
>>>          </available>
>>>      </target>
>>> -
>>> +
>>>      <!-- Check that if we want servlet logging support, our logkit.jar
>>>has it enabled too --> <target name="dependencies.servlet"
>>>if="servlet.present">
>>>              <ant antfile="${depchecker.prefix}/depchecker.xml"
>>>target="checkRequiredClass"> @@ -76,7 +75,6 @@
>>>      <target name="dependencies" depends="dependencies.optional"
>>>description="Check dependencies" unless="skip.dependencies"> <ant
>>>antfile="${depchecker.prefix}/depchecker.xml" target="checkCommon"/> <ant
>>>antfile="${depchecker.prefix}/depchecker.xml" target="checkLogkit"/> -   
>>>    <ant antfile="${depchecker.prefix}/depchecker.xml"
>>>target="checkContainer"/> <ant
>>>antfile="${depchecker.prefix}/depchecker.xml" target="checkFramework"/>
>>><ant antfile="${depchecker.prefix}/depchecker.xml"
>>>target="checkInstrument"/> <ant
>>>antfile="${depchecker.prefix}/depchecker.xml"
>>>target="checkInstrumentManager"/> @@ -94,7 +92,7 @@
>>>          <ant antfile="${depchecker.prefix}/depchecker.xml"
>>>target="checkTestcase"/> <ant
>>>antfile="${depchecker.prefix}/depchecker.xml" target="checkInstrument"/>
>>></target>
>>> -
>>> +
>>>      <target name="servlet-warn" unless="servlet.present"
>>>          description="Outputs a warning if javax.servlet.* classes are
>>>missing during compilation">
>>><echo>*******************************************************************
>>>**************</echo> @@ -204,7 +202,7 @@
>>>              </zipfileset>
>>>          </jar>
>>>      </target>
>>> -
>>> +
>>>      <!-- Creates all the .jar file -->
>>>      <target name="jar" depends="compile, prepare-conf, jar-servlet"
>>>description="Generates the jar files">
>>>
>>> @@ -447,10 +445,10 @@
>>>          <fileset dir="${build.docs}">
>>>            <include name="**"/>
>>>          </fileset>
>>> -      </copy>
>>> +      </copy>
>>>
>>>      </target>
>>> -
>>> +
>>>      <target name="site" depends="javadocs, docs" description=" Places
>>>Docs ready for hosting on website">
>>>
>>>        <mkdir dir="../site/dist/docs/${dir-name}"/>
>>>
>>>
>>>
>>> 1.15      +0 -5     
>>>jakarta-avalon-excalibur/component/default.properties
>>>
>>> Index: default.properties
>>> ===================================================================
>>> RCS file:
>>>/home/cvs/jakarta-avalon-excalibur/component/default.properties,v
>>>retrieving revision 1.14
>>> retrieving revision 1.15
>>> diff -u -r1.14 -r1.15
>>> --- default.properties	24 Sep 2002 20:39:52 -0000	1.14
>>> +++ default.properties	9 Nov 2002 08:41:03 -0000	1.15
>>> @@ -38,11 +38,6 @@
>>>  excalibur-collections.lib=${excalibur-collections.home}
>>> 
>>>excalibur-collections.jar=${excalibur-collections.lib}/excalibur-collecti
>>>ons-1.0.jar
>>>
>>> -# ----- Excalibur Container -----
>>> -excalibur-container.home=${basedir}/../container
>>> -excalibur-container.lib=${excalibur-container.home}/build/lib
>>>
>>>-excalibur-container.jar=${excalibur-container.lib}/excalibur-container-1
>>>.0.jar -
>>>  # ----- Excalibur logger, version 1.0 or later -----
>>>  excalibur-logger.home=${basedir}/../logger/dist
>>>  excalibur-logger.lib=${excalibur-logger.home}
>>>
>>>
>>>
>>> 1.16      +1 -2     
>>>jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/c
>>>omponent/DefaultComponentFactory.java
>>>
>>> Index: DefaultComponentFactory.java
>>> ===================================================================
>>> RCS file:
>>>/home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/e
>>>xcalibur/component/DefaultComponentFactory.java,v retrieving revision 1.15
>>> retrieving revision 1.16
>>> diff -u -r1.15 -r1.16
>>> --- DefaultComponentFactory.java	9 Nov 2002 08:36:27 -0000	1.15
>>> +++ DefaultComponentFactory.java	9 Nov 2002 08:41:03 -0000	1.16
>>> @@ -29,7 +29,6 @@
>>>  import org.apache.avalon.framework.service.Serviceable;
>>>  import org.apache.avalon.framework.service.WrapperServiceManager;
>>>  import org.apache.avalon.framework.thread.ThreadSafe;
>>> -import org.apache.excalibur.container.legacy.ComponentProxyGenerator;
>>>  import org.apache.excalibur.instrument.InstrumentManageable;
>>>  import org.apache.excalibur.instrument.InstrumentManager;
>>>  import org.apache.excalibur.instrument.Instrumentable;
>>>
>>>
>>>
>>> 1.1                 
>>>jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/c
>>>omponent/ComponentProxyGenerator.java
>>>
>>> Index: ComponentProxyGenerator.java
>>> ===================================================================
>>> /* ====================================================================
>>>  * The Apache Software License, Version 1.1
>>>  *
>>>  * Copyright (c) 2002 The Apache Software Foundation. All rights
>>>  * reserved.
>>>  *
>>>  * Redistribution and use in source and binary forms, with or without
>>>  * modification, are permitted provided that the following conditions
>>>  * are met:
>>>  *
>>>  * 1. Redistributions of source code must retain the above copyright
>>>  *    notice, this list of conditions and the following disclaimer.
>>>  *
>>>  * 2. Redistributions in binary form must reproduce the above copyright
>>>  *    notice, this list of conditions and the following disclaimer in
>>>  *    the documentation and/or other materials provided with the
>>>  *    distribution.
>>>  *
>>>  * 3. The end-user documentation included with the redistribution,
>>>  *    if any, must include the following acknowledgment:
>>>  *    "This product includes software developed by the
>>>  *    Apache Software Foundation (http://www.apache.org/)."
>>>  *    Alternately, this acknowledgment may appear in the software
>>>  *    itself, if and wherever such third-party acknowledgments
>>>  *    normally appear.
>>>  *
>>>  * 4. The names "Jakarta", "Avalon", and "Apache Software Foundation"
>>>  *    must not be used to endorse or promote products derived from this
>>>  *    software without prior written permission. For written
>>>  *    permission, please contact apache@apache.org.
>>>  *
>>>  * 5. Products derived from this software may not be called "Apache",
>>>  *    nor may "Apache" appear in their name, without prior written
>>>  *    permission of the Apache Software Foundation.
>>>  *
>>>  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
>>>  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
>>>  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
>>>  * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
>>>  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
>>>  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
>>>  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
>>>  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
>>>  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
>>>  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
>>>  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
>>>  * SUCH DAMAGE.
>>>  * ====================================================================
>>>  *
>>>  * This software consists of voluntary contributions made by many
>>>  * individuals on behalf of the Apache Software Foundation. For more
>>>  * information on the Apache Software Foundation, please see
>>>  * <http://www.apache.org/>.
>>>  */
>>>
>>> package org.apache.avalon.excalibur.component;
>>>
>>> import java.lang.reflect.InvocationHandler;
>>> import java.lang.reflect.Method;
>>> import java.lang.reflect.Proxy;
>>> import java.lang.reflect.InvocationTargetException;
>>> import org.apache.avalon.framework.component.Component;
>>>
>>> /**
>>>  * Create a Component proxy.  Requires JDK 1.3+
>>>  *
>>>  * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
>>>  */
>>> public final class ComponentProxyGenerator
>>> {
>>>     private final ClassLoader m_classLoader;
>>>
>>>     /**
>>>      * Initialize the ComponentProxyGenerator with the default
>>>classloader. * The default classloader is the Thread context classloader.
>>>*/
>>>     public ComponentProxyGenerator()
>>>     {
>>>         this( Thread.currentThread().getContextClassLoader() );
>>>     }
>>>
>>>     /**
>>>      * Initialize the ComponentProxyGenerator with the supplied
>>>classloader. * If the supplied class loader is null, we use the Thread
>>>context class * loader.  If that is null, we use this class's
>>>classloader. */
>>>     public ComponentProxyGenerator( final ClassLoader parentClassLoader
>>>) {
>>>         m_classLoader = ( null == parentClassLoader ) ?
>>>             ( ( null == Thread.currentThread().getContextClassLoader() )
>>>? getClass().getClassLoader()
>>>
>>>             : Thread.currentThread().getContextClassLoader() )
>>>             : parentClassLoader;
>>>
>>>     }
>>>
>>>     /**
>>>      * Get the Component wrapped in the proxy.  The role must be the
>>>service * interface's fully qualified classname to work.
>>>      */
>>>     public Component getProxy( String role, Object service ) throws
>>>Exception {
>>>         Class serviceInterface = m_classLoader.loadClass( role );
>>>
>>>         return (Component)Proxy.newProxyInstance( m_classLoader,
>>>                                                   new
>>>Class[]{Component.class, serviceInterface}, new
>>>ComponentInvocationHandler( service ) ); }
>>>
>>>     /**
>>>      * Internal class to handle the wrapping with Component
>>>      */
>>>     private final static class ComponentInvocationHandler
>>>         implements InvocationHandler
>>>     {
>>>         private final Object m_delagate;
>>>
>>>         public ComponentInvocationHandler( final Object delegate )
>>>         {
>>>             if( null == delegate )
>>>             {
>>>                 throw new NullPointerException( "delegate" );
>>>             }
>>>
>>>             m_delagate = delegate;
>>>         }
>>>
>>>         public Object invoke( final Object proxy,
>>>                               final Method meth,
>>>                               final Object[] args )
>>>             throws Throwable
>>>         {
>>>             try
>>>             {
>>>                 return meth.invoke( m_delagate, args );
>>>             }
>>>             catch( final InvocationTargetException ite )
>>>             {
>>>                 throw ite.getTargetException();
>>>             }
>>>         }
>>>     }
>>> }
>>>
>>>
>>>
>>> 1.2       +29 -33   
>>>jakarta-avalon-excalibur/component/src/java/org/apache/avalon/excalibur/c
>>>omponent/servlet/AbstractServiceManagerServlet.java
>>>
>>> Index: AbstractServiceManagerServlet.java
>>> ===================================================================
>>> RCS file:
>>>/home/cvs/jakarta-avalon-excalibur/component/src/java/org/apache/avalon/e
>>>xcalibur/component/servlet/AbstractServiceManagerServlet.java,v retrieving
>>>revision 1.1
>>> retrieving revision 1.2
>>> diff -u -r1.1 -r1.2
>>> --- AbstractServiceManagerServlet.java	7 Nov 2002 09:50:41 -0000	1.1
>>> +++ AbstractServiceManagerServlet.java	9 Nov 2002 08:41:04 -0000	1.2
>>> @@ -9,23 +9,19 @@
>>>
>>>  import java.io.IOException;
>>>  import java.util.ArrayList;
>>> -
>>>  import javax.servlet.ServletConfig;
>>>  import javax.servlet.ServletContext;
>>>  import javax.servlet.ServletException;
>>>  import javax.servlet.http.HttpServlet;
>>>  import javax.servlet.http.HttpServletRequest;
>>>  import javax.servlet.http.HttpServletResponse;
>>> -
>>>  import org.apache.avalon.excalibur.logger.LoggerManager;
>>> -
>>> -import org.apache.avalon.framework.service.ServiceManager;
>>>  import org.apache.avalon.framework.logger.Logger;
>>> -
>>> +import org.apache.avalon.framework.service.ServiceManager;
>>>  import org.apache.excalibur.instrument.CounterInstrument;
>>>  import org.apache.excalibur.instrument.Instrument;
>>> -import org.apache.excalibur.instrument.Instrumentable;
>>>  import org.apache.excalibur.instrument.InstrumentManager;
>>> +import org.apache.excalibur.instrument.Instrumentable;
>>>  import org.apache.excalibur.instrument.ValueInstrument;
>>>
>>>  /**
>>> @@ -44,7 +40,7 @@
>>>      private String m_referenceName;
>>>      private ServiceManager m_serviceManager;
>>>      private Logger m_logger;
>>> -
>>> +
>>>      /** Instrumentable Name assigned to this Instrumentable */
>>>      private String m_instrumentableName;
>>>
>>> @@ -56,13 +52,13 @@
>>>
>>>      /** Flag which is to used to keep track of when the Instrumentable
>>>has been registered. */ private boolean m_registered;
>>> -
>>> +
>>>      /** Counts the number of times the service is requested. */
>>>      private CounterInstrument m_instrumentRequests;
>>> -
>>> +
>>>      /** Records the amount of time execute takes to be processed. */
>>>      private ValueInstrument m_instrumentTime;
>>> -
>>> +
>>>      /*---------------------------------------------------------------
>>>       * Constructors
>>>       *-------------------------------------------------------------*/
>>> @@ -77,18 +73,18 @@
>>>      {
>>>          //System.out.println( "AbstractServiceManagerServlet( " +
>>>referenceName + " )" ); m_referenceName = referenceName;
>>> -
>>> +
>>>          // Set up Instrumentable like AbstractInstrumentable
>>>          m_registered = false;
>>>          m_instrumentList = new ArrayList();
>>>          m_childList = new ArrayList();
>>> -
>>> +
>>>          // Create the instruments
>>>          setInstrumentableName( referenceName );
>>>          addInstrument( m_instrumentRequests = new CounterInstrument(
>>>"requests" ) ); addInstrument( m_instrumentTime = new ValueInstrument(
>>>"time" ) ); }
>>> -
>>> +
>>>      /*---------------------------------------------------------------
>>>       * HttpServlet Methods
>>>       *-------------------------------------------------------------*/
>>> @@ -115,12 +111,12 @@
>>>          }
>>>          Logger logger = loggerManager.getLoggerForCategory( "servlet"
>>>); m_logger = logger.getChildLogger( m_referenceName );
>>> -
>>> +
>>>          if ( getLogger().isDebugEnabled() )
>>>          {
>>>              getLogger().debug( "servlet.init( config )" );
>>>          }
>>> -
>>> +
>>>          // Obtain a reference to the ServiceManager
>>>          m_serviceManager =
>>>              (ServiceManager)context.getAttribute(
>>>ServiceManager.class.getName() ); @@ -129,7 +125,7 @@
>>>              throw new IllegalStateException(
>>>                  "The ExcaliburComponentManagerServlet servlet was not
>>>correctly initialized." ); }
>>> -
>>> +
>>>          // Register this servlet with the InstrumentManager if it
>>>exists. InstrumentManager instrumentManager =
>>>              (InstrumentManager)context.getAttribute(
>>>InstrumentManager.class.getName() ); @@ -146,12 +142,12 @@
>>>                      "Unable to register the servlet with the instrument
>>>manager.", e ); }
>>>          }
>>> -
>>> +
>>>          // Do this last so the subclasses will be able to access these
>>>objects in their //  init method.
>>>          super.init( config );
>>>      }
>>> -
>>> +
>>>      /**
>>>       * Called by the servlet container to indicate to a servlet that
>>>the servlet *  is being taken out of service.
>>> @@ -162,15 +158,15 @@
>>>          {
>>>              getLogger().debug( "servlet.destroy()" );
>>>          }
>>> -
>>> +
>>>          // Release the ServiceManager by removing its reference.
>>>          m_serviceManager = null;
>>> -
>>> +
>>>          super.destroy();
>>> -
>>> +
>>>          // Make sure that the component manager gets collected.
>>>          System.gc();
>>> -
>>> +
>>>          // Give the system time for the Gc to complete.  This is
>>>necessary to make sure that //  the ECMServlet has time to dispose all of
>>>its managers before the Tomcat server //  invalidates the current class
>>>loader.
>>> @@ -182,7 +178,7 @@
>>>          {
>>>          }
>>>      }
>>> -
>>> +
>>>      /**
>>>       * Receives standard HTTP requests from the public service method
>>>and dispatches *  them to the doXXX methods defined in this class.
>>> @@ -205,24 +201,24 @@
>>>                  sb.append( "?" );
>>>                  sb.append( query );
>>>              }
>>> -
>>> +
>>>              getLogger().debug( "Request: " + sb.toString() );
>>>          }
>>> -
>>> +
>>>          long start = System.currentTimeMillis();
>>> -
>>> +
>>>          // Notify the Instrument Manager
>>>          m_instrumentRequests.increment();
>>> -
>>> +
>>>          super.service( request, response );
>>> -
>>> +
>>>          // Notify the Instrument Manager how long the service took.
>>>          if ( m_instrumentTime.isActive() )
>>>          {
>>>              m_instrumentTime.setValue( (int)(
>>>System.currentTimeMillis() - start ) ); }
>>>      }
>>> -
>>> +
>>>      /*---------------------------------------------------------------
>>>       * Instrumentable Methods
>>>       *-------------------------------------------------------------*/
>>> @@ -303,7 +299,7 @@
>>>              return instruments;
>>>          }
>>>      }
>>> -
>>> +
>>>      /*---------------------------------------------------------------
>>>       * Methods
>>>       *-------------------------------------------------------------*/
>>> @@ -343,7 +339,7 @@
>>>          }
>>>          m_childList.add( child );
>>>      }
>>> -
>>> +
>>>      /**
>>>       * Obtain a reference to the servlet's logger.
>>>       *
>>> @@ -353,7 +349,7 @@
>>>      {
>>>          return m_logger;
>>>      }
>>> -
>>> +
>>>      /**
>>>       * Returns the current ServiceManager.
>>>       *
>>>
>>>
>>>
>>>
>>>--
>>>To unsubscribe, e-mail:  
>>><mailto:avalon-cvs-unsubscribe@jakarta.apache.org> For additional
>>>commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>
>>>      
>>>
>
>  
>

-- 

Stephen J. McConnell

OSM SARL
digital products for a global economy
mailto:mcconnell@osm.net
http://www.osm.net




--
To unsubscribe, e-mail:   <mailto:avalon-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-dev-help@jakarta.apache.org>


Mime
View raw message