cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: xml-cocoon2/src/java/org/apache/cocoon/components/jsp JSPEngineImpl.java JSPEngineImplNamedDispatcherInclude.java JSPEngineImplWLS.java
Date Thu, 10 Jan 2002 15:27:37 GMT
cziegeler    02/01/10 07:27:37

  Modified:    src/java/org/apache/cocoon/components/hsqldb ServerImpl.java
               src/java/org/apache/cocoon/components/jsp JSPEngineImpl.java
                        JSPEngineImplNamedDispatcherInclude.java
                        JSPEngineImplWLS.java
  Log:
  Cleaning up lifecycle interfaces and using Parameterizable instead of Configurable
  
  Revision  Changes    Path
  1.2       +16 -13    xml-cocoon2/src/java/org/apache/cocoon/components/hsqldb/ServerImpl.java
  
  Index: ServerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/hsqldb/ServerImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ServerImpl.java	3 Jan 2002 12:31:09 -0000	1.1
  +++ ServerImpl.java	10 Jan 2002 15:27:37 -0000	1.2
  @@ -8,14 +8,12 @@
   package org.apache.cocoon.components.hsqldb;
   
   import org.apache.avalon.framework.activity.Startable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
   import org.apache.avalon.framework.context.Context;
   import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.thread.ThreadSafe;
   import org.apache.cocoon.Constants;
   
  @@ -28,11 +26,15 @@
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    */
  -public class ServerImpl extends AbstractLoggable implements Server, Configurable,
  -                                                                  Contextualizable,
  -                                                                  ThreadSafe,
  -                                                                  Runnable,
  -                                                                  Startable {
  +public class ServerImpl
  +extends AbstractLoggable
  +implements Server,
  +           Parameterizable,
  +           Contextualizable,
  +           ThreadSafe,
  +           Runnable,
  +           Startable {
  +
     /** Arguments for running the server */
     private String arguments[] = new String[8];
   
  @@ -48,17 +50,18 @@
      *  <LI>trace = print JDBC trace messages</LI>
      * </UL>
      */
  -  public void configure(Configuration conf) throws ConfigurationException {
  -    this.getLogger().debug("Configure ServerImpl");
  -
  -    Parameters params = Parameters.fromConfiguration(conf);
  -
  +  public void parameterize(Parameters params)  {
       arguments[0] = "-port";
       arguments[1] = params.getParameter("port","9002");
       arguments[2] = "-silent";
       arguments[3] = params.getParameter("silent","true");
       arguments[4] = "-trace";
       arguments[5] = params.getParameter("trace","false");
  +    if ( this.getLogger().isDebugEnabled() == true ) {
  +        this.getLogger().debug("Configure ServerImpl with port: " + arguments[1]
  +                              +", silent: " + arguments[3]
  +                              +", trace: " +arguments[5]);
  +    }
     }
   
     /** Contextualize this class */
  
  
  
  1.2       +4 -39     xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImpl.java
  
  Index: JSPEngineImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImpl.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JSPEngineImpl.java	3 Jan 2002 12:31:09 -0000	1.1
  +++ JSPEngineImpl.java	10 Jan 2002 15:27:37 -0000	1.2
  @@ -7,17 +7,8 @@
    *****************************************************************************/
   package org.apache.cocoon.components.jsp;
   
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
   
  @@ -41,10 +32,10 @@
    * functionality - overrides the output method and returns the byte(s).
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:09 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 15:27:37 $
    */
   public class JSPEngineImpl extends AbstractLoggable
  -    implements JSPEngine, Contextualizable, Composable, Configurable, ThreadSafe, Disposable
{
  +    implements JSPEngine, Parameterizable, ThreadSafe {
   
       /** The Servlet Include Path */
       public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
  @@ -55,35 +46,16 @@
       /** Servlet Class Name */
       public String jspServletClass = DEFAULT_SERVLET_CLASS;
   
  -    /** The component manager */
  -    protected ComponentManager manager = null;
  -
  -    /** Contextualize this class */
  -    public void contextualize(Context context) throws ContextException {
  -    }
  -
       /**
        * Set the sitemap-provided configuration.
        * @param conf The configuration information
        * @exception ConfigurationException
        */
  -    public void configure(Configuration conf) throws ConfigurationException {
  -        Parameters params = Parameters.fromConfiguration(conf);
  +    public void parameterize(Parameters params)  {
           this.jspServletClass = params.getParameter("servlet-class", DEFAULT_SERVLET_CLASS);
       }
   
       /**
  -     * Set the global component manager. This metod also sets the
  -     * <code>ComponentSelector</code> used as language factory for both markup
and programming languages.
  -     * @param manager The global component manager
  -     */
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        if ((this.manager == null) && (manager != null)) {
  -            this.manager = manager;
  -        }
  -    }
  -
  -    /**
        * execute the JSP and return the output
        *
        * @param context The Servlet Context
  @@ -114,13 +86,6 @@
           return bytes;
       }
   
  -
  -    /**
  -     *  dispose
  -     */
  -    public void dispose() {
  -
  -    }
   
       /**
        * Stub implementation of Servlet Config
  
  
  
  1.2       +15 -52    xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImplNamedDispatcherInclude.java
  
  Index: JSPEngineImplNamedDispatcherInclude.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImplNamedDispatcherInclude.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JSPEngineImplNamedDispatcherInclude.java	3 Jan 2002 12:31:09 -0000	1.1
  +++ JSPEngineImplNamedDispatcherInclude.java	10 Jan 2002 15:27:37 -0000	1.2
  @@ -7,20 +7,10 @@
    *****************************************************************************/
   package org.apache.cocoon.components.jsp;
   
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.parameters.Parameters;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.cocoon.components.parser.Parser;
   import org.xml.sax.SAXException;
   
   import javax.servlet.*;
  @@ -35,21 +25,21 @@
   
   /**
    * Allows JSP to be used as a generator.  Builds upon the JSP servlet
  - * functionality - overrides the output method and returns the byte(s). 
  + * functionality - overrides the output method and returns the byte(s).
    * This implementation includes via ServletContext.getNamedDispatcher() the
    * jsp-response. This a generic implementation.
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:09 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 15:27:37 $
    */
  -public class JSPEngineImplNamedDispatcherInclude extends AbstractLoggable 
  -    implements JSPEngine, Contextualizable, Composable, Configurable, ThreadSafe, Disposable
{
  +public class JSPEngineImplNamedDispatcherInclude extends AbstractLoggable
  +    implements JSPEngine, Parameterizable, ThreadSafe {
   
       /** The Servlet Include Path */
       public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
   
  -    /** config-parameter name for specifying the jsp servlet-name. 
  +    /** config-parameter name for specifying the jsp servlet-name.
         ie. servlet-name
       */
       public static final String CONFIG_SERVLET_NAME = "servlet-name";
  @@ -61,53 +51,33 @@
       */
       String servletName = DEFAULT_SERVLET_NAME;
   
  -    /** The component manager */
  -    protected ComponentManager manager = null;
  -
  -    /** Contextualize this class */
  -    public void contextualize(Context context) throws ContextException {
  -    }
  -
       /**
  -     * Set the sitemap-provided configuration. 
  +     * Set the sitemap-provided configuration.
        * @param conf The configuration information
  -     * @exception ConfigurationException 
  +     * @exception ConfigurationException
        */
  -    public void configure(Configuration conf) throws ConfigurationException {
  -        Parameters params = Parameters.fromConfiguration(conf);
  +    public void parameterize(Parameters params)  {
           this.servletName = params.getParameter(CONFIG_SERVLET_NAME, DEFAULT_SERVLET_NAME);
       }
   
       /**
  -     * Set the global component manager. This metod also sets the
  -     * <code>ComponentSelector</code> used as language factory for both markup
and programming languages.
  -     * @param manager The global component manager
  -     */
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        if ((this.manager == null) && (manager != null)) {
  -            this.manager = manager;
  -        }
  -    }
  -
  -    /**
        * execute the JSP and return the output
        *
        * @param context The Servlet Context
  -     * @exception IOException 
  -     * @exception ServletException 
  -     * @exception SAXException 
  -     * @exception Exception 
  +     * @exception IOException
  +     * @exception ServletException
  +     * @exception SAXException
  +     * @exception Exception
        */
  -    public byte[] executeJSP(String url, HttpServletRequest httpRequest, HttpServletResponse
httpResponse, ServletContext context) 
  +    public byte[] executeJSP(String url, HttpServletRequest httpRequest, HttpServletResponse
httpResponse, ServletContext context)
           throws IOException, ServletException, SAXException, Exception {
   
  -        Parser parser = null;
           byte[] bytes = null;
   
           MyServletRequest request = new MyServletRequest(httpRequest, url);
           MyServletResponse response = new MyServletResponse(httpResponse);
   
  -        // start JSPServlet. 
  +        // start JSPServlet.
           javax.servlet.RequestDispatcher rd = context.getNamedDispatcher( servletName );
           if (rd != null) {
             rd.include( request, response );
  @@ -121,13 +91,6 @@
       }
   
   
  -    /**
  -     *  dispose
  -     */
  -    public void dispose() {
  -
  -    }
  -    
       /**
        * Stub implementation of HttpServletRequest
        */
  
  
  
  1.2       +33 -70    xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImplWLS.java
  
  Index: JSPEngineImplWLS.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon2/src/java/org/apache/cocoon/components/jsp/JSPEngineImplWLS.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- JSPEngineImplWLS.java	3 Jan 2002 12:31:09 -0000	1.1
  +++ JSPEngineImplWLS.java	10 Jan 2002 15:27:37 -0000	1.2
  @@ -7,20 +7,10 @@
    *****************************************************************************/
   package org.apache.cocoon.components.jsp;
   
  -import org.apache.avalon.framework.activity.Disposable;
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentManager;
  -import org.apache.avalon.framework.component.Composable;
  -import org.apache.avalon.framework.configuration.Configurable;
  -import org.apache.avalon.framework.configuration.Configuration;
  -import org.apache.avalon.framework.configuration.ConfigurationException;
  -import org.apache.avalon.framework.context.Context;
  -import org.apache.avalon.framework.context.ContextException;
  -import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLoggable;
   import org.apache.avalon.framework.parameters.Parameters;
  +import org.apache.avalon.framework.parameters.Parameterizable;
   import org.apache.avalon.framework.thread.ThreadSafe;
  -import org.apache.cocoon.components.parser.Parser;
   import org.xml.sax.SAXException;
   
   import javax.servlet.ServletContext;
  @@ -37,19 +27,19 @@
    * functionality - overrides the output method and returns the byte(s).
    * This implementation includes via ServletContext.getNamedDispatcher() the
    * jsp-response. This a WLS-specific implementation.
  - * This code contain WLS 5.1 specific classes, and uses WLS internal classes. 
  + * This code contain WLS 5.1 specific classes, and uses WLS internal classes.
    *
    * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
    * @author <a href="mailto:bh22351@i-one.at">Bernhard Huber</a>
  - * @version CVS $Revision: 1.1 $ $Date: 2002/01/03 12:31:09 $
  + * @version CVS $Revision: 1.2 $ $Date: 2002/01/10 15:27:37 $
    */
  -public class JSPEngineImplWLS extends AbstractLoggable 
  -    implements JSPEngine, Contextualizable, Composable, Configurable, ThreadSafe, Disposable
{
  +public class JSPEngineImplWLS extends AbstractLoggable
  +    implements JSPEngine, Parameterizable, ThreadSafe {
   
       /** The Servlet Include Path */
       public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
   
  -    /** config-parameter name for specifying the jsp servlet-name. 
  +    /** config-parameter name for specifying the jsp servlet-name.
         ie. servlet-name
       */
       public static final String CONFIG_SERVLET_NAME = "servlet-name";
  @@ -61,47 +51,27 @@
       */
       String servletName = DEFAULT_SERVLET_NAME;
   
  -    /** The component manager */
  -    protected ComponentManager manager = null;
  -
  -    /** Contextualize this class */
  -    public void contextualize(Context context) throws ContextException {
  -    }
  -
       /**
  -     * Set the sitemap-provided configuration. 
  +     * Set the sitemap-provided configuration.
        * @param conf The configuration information
  -     * @exception ConfigurationException 
  +     * @exception ConfigurationException
        */
  -    public void configure(Configuration conf) throws ConfigurationException {
  -        Parameters params = Parameters.fromConfiguration(conf);
  +    public void parameterize(Parameters params) {
           this.servletName = params.getParameter( CONFIG_SERVLET_NAME, DEFAULT_SERVLET_NAME);
       }
   
       /**
  -     * Set the global component manager. This metod also sets the
  -     * <code>ComponentSelector</code> used as language factory for both markup
and programming languages.
  -     * @param manager The global component manager
  -     */
  -    public void compose(ComponentManager manager) throws ComponentException {
  -        if ((this.manager == null) && (manager != null)) {
  -            this.manager = manager;
  -        }
  -    }
  -
  -    /**
        * execute the JSP and return the output
        *
        * @param context The Servlet Context
  -     * @exception IOException 
  -     * @exception ServletException 
  -     * @exception SAXException 
  -     * @exception Exception 
  +     * @exception IOException
  +     * @exception ServletException
  +     * @exception SAXException
  +     * @exception Exception
        */
  -    public byte[] executeJSP(String url, HttpServletRequest httpRequest, HttpServletResponse
httpResponse, ServletContext context) 
  +    public byte[] executeJSP(String url, HttpServletRequest httpRequest, HttpServletResponse
httpResponse, ServletContext context)
           throws IOException, ServletException, SAXException, Exception {
   
  -        Parser parser = null;
           byte[] bytes = null;
   
           HttpServletRequest request = httpRequest;
  @@ -110,12 +80,12 @@
           MyWLSResponse response = new MyWLSResponse( httpResponse,
             (weblogic.servlet.internal.ServletContextImpl)context );
   
  -        // start JSPServlet. 
  +        // start JSPServlet.
           javax.servlet.RequestDispatcher rd = context.getNamedDispatcher( servletName );
           if (rd != null) {
             rd.include( request, response );
             response.flushBuffer();
  -          
  +
             getLogger().debug( "JSP response: " + response.getResponseContentAsString() );
             bytes = response.getResponseContentAsByteArray();
   
  @@ -129,22 +99,15 @@
           return bytes;
       }
   
  -    /**
  -     *  dispose
  -     */
  -    public void dispose() {
  -
  -    }
  -
  -    /** WLS jsp servlet hack. 
  +    /** WLS jsp servlet hack.
         <p>
  -        Here WLS specific classes are used. 
  +        Here WLS specific classes are used.
         </p>
         <p>
  -        The weblogic.servlet.JSPServlet, and 
  +        The weblogic.servlet.JSPServlet, and
           weblogic.servlet.internal.RequesDispatcherImpl expects
           objects weblogic.servlet.internal.ServletOutputStreamImpl,
  -        and weblogic.servlet.internal.ServletResponseImpl. 
  +        and weblogic.servlet.internal.ServletResponseImpl.
           Thus we have to use <i>exactly</i> these classes!
         </p>
       */
  @@ -153,31 +116,31 @@
         , cookies, etc generated inside the jsp-response
         */
         HttpServletResponse response;
  -      
  +
         ByteArrayOutputStream baos;
         weblogic.servlet.internal.ServletOutputStreamImpl wlsOutputStream;
  -      
  +
         public MyWLSResponse( HttpServletResponse response,
           weblogic.servlet.internal.ServletContextImpl servlet_context ) {
  -        
  +
           super( servlet_context );
           this.response = response;
  -        
  +
           baos = new ByteArrayOutputStream();
   
  -        wlsOutputStream = 
  +        wlsOutputStream =
             new weblogic.servlet.internal.ServletOutputStreamImpl( baos );
           this.setOutputStream( wlsOutputStream );
           wlsOutputStream.setImpl( this );
         }
  -      
  +
         /** flush response content.
         */
         public void flushBuffer() throws IOException {
           super.flushBuffer();
           baos.flush();
         }
  -      
  +
         /** return response as byte array.
           <p>Note: http-headers are skipped. More exactly all chars until first
           '&lt;?xml', or '\r\n\r\n&lt; sequence. This may be a bit heuristic.
  @@ -188,12 +151,12 @@
         */
         public byte[] getResponseContentAsByteArray() {
           byte[] baos_arr = baos.toByteArray();
  -        
  +
           int baos_arr_length = baos_arr.length;
           int i = 0;
           boolean matched = false;
           final int I_MAX = 8192; // check only header
  -        
  +
           final byte MATCH_0d = (byte)'\r';
           final byte MATCH_0a = (byte)'\n';
   
  @@ -202,9 +165,9 @@
           final byte MATCH_THIRD = (byte)'x';
           final byte MATCH_FOURTH = (byte)'m';
           final byte MATCH_FIFTH = (byte)'l';
  -        
  +
           final int MATCH_COUNT = 5;
  -        
  +
           while (i + MATCH_COUNT < baos_arr_length && i < I_MAX &&
!matched) {
   
             matched = (baos_arr[i] == MATCH_FIRST && baos_arr[i+1] == MATCH_SECOND
&&
  @@ -223,14 +186,14 @@
           }
           if (matched && i > 0) {
             int baos_arr_new_length = baos_arr_length - i;
  -          
  +
             byte []new_baos_arr = new byte[baos_arr_new_length];
             System.arraycopy( baos_arr, i, new_baos_arr, 0, baos_arr_new_length );
             baos_arr = new_baos_arr;
           }
           return baos_arr;
         }
  -      
  +
         public String getResponseContentAsString() {
           String s = new String( getResponseContentAsByteArray() );
           return s;
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org


Mime
View raw message