asmuts      02/01/18 07:21:43

  Modified:    src/java/org/apache/stratum/jcs/test/servlet
                        SessionExampleServlet.java
               src/java/org/apache/stratum/jcs/utils/reuse
                        IThreadPoolRunnable.java ThreadPoolManager.java
                        TomcatQueue.java
  Log:
  changed classes to use local copies of the thread pool and the
  queue from tomcat.
  
  Revision  Changes    Path
  1.2       +173 -150  
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/test/servlet/SessionExampleServlet.java
  
  Index: SessionExampleServlet.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/test/servlet/SessionExampleServlet.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SessionExampleServlet.java        16 Jan 2002 05:28:16 -0000      1.1
  +++ SessionExampleServlet.java        18 Jan 2002 15:21:43 -0000      1.2
  @@ -11,28 +11,28 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  + * 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.
  + * 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 acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  + * any, must include the following acknowlegement:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowlegement may appear in the software itself,
  + * if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Velocity", 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 [EMAIL PROTECTED]
  + * Foundation" must not be used to endorse or promote products derived
  + * from this software without prior written permission. For written
  + * permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  + * nor may "Apache" appear in their names without prior written
  + * permission of the Apache Group.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  @@ -53,7 +53,6 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    */
  -
   import java.io.*;
   import java.text.*;
   import java.util.*;
  @@ -67,166 +66,190 @@
   import org.apache.stratum.jcs.utils.log.LoggerManager;
   
   /**
  - * Session example using the cache for session replicaiton.  Modifed from
  - * Tomcat examples.
  - *
  - * Example servlet showing request headers
  + *  Session example using the cache for session replicaiton. Modifed from Tomcat
  + *  examples. Example servlet showing request headers
    *
  - * @author James Duncan Davidson <[EMAIL PROTECTED]>
  - * @author Aaron Smuts <[EMAIL PROTECTED]>
  + *@author     James Duncan Davidson <[EMAIL PROTECTED]>
  + *@author     Aaron Smuts <[EMAIL PROTECTED]>
  + *@created    January 18, 2002
    */
   
  -public class SessionExampleServlet extends HttpServlet {
  +public class SessionExampleServlet extends HttpServlet
  +{
   
       private static Logger log = LoggerManager.getLogger( 
SessionExampleServlet.class );
   
  -    ResourceBundle rb = ResourceBundle.getBundle("LocalStrings");
  +    ResourceBundle rb = ResourceBundle.getBundle( "LocalStrings" );
   
  -    public void doGet(HttpServletRequest request,
  -                      HttpServletResponse response)
  +    /**
  +     *  Description of the Method
  +     *
  +     *@param  request               Description of the Parameter
  +     *@param  response              Description of the Parameter
  +     *@exception  IOException       Description of the Exception
  +     *@exception  ServletException  Description of the Exception
  +     */
  +    public void doGet( HttpServletRequest request,
  +                       HttpServletResponse response )
           throws IOException, ServletException
       {
   
  -    try {
  -
  -    // get JCS wrapper
  -    request = new HttpServletRequestFacade(request, response);
  +        try
  +        {
   
  +            // get JCS wrapper
  +            request = new HttpServletRequestFacade( request, response );
   
  -        response.setContentType("text/html");
  +            response.setContentType( "text/html" );
   
  -        PrintWriter out = response.getWriter();
  -        out.println("<html>");
  -        out.println("<body bgcolor=\"white\">");
  -        out.println("<head>");
  -
  -        String title = rb.getString("sessions.title");
  -        out.println("<title>" + title + "</title>");
  -        out.println("</head>");
  -        out.println("<body>");
  -
  -        // img stuff not req'd for source code html showing
  -     // relative links everywhere!
  -
  -        // XXX
  -        // making these absolute till we work out the
  -        // addition of a PathInfo issue
  -
  -        /*
  -        out.println("<a href=\"/examples/servlets/sessions.html\">");
  -        out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"view code\"></a>");
  -        out.println("<a href=\"/examples/servlets/index.html\">");
  -        out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  -                    "width=24 align=right border=0 alt=\"return\"></a>");
  -        */
  -        out.println("<h3>" + title + "</h3>");
  -
  -      // Get session as normal, but it is coming fomr the JCS
  -      HttpSession session = null;// = request.getSession();
  -      try
  -      {
  -        session = request.getSession(true);
  -      } catch (IllegalStateException ise) {
  -        log.warn(ise.toString());
  -      }
  -
  -
  -        out.println(rb.getString("sessions.id") + " " + session.getId());
  -        out.println("<br>");
  -               out.println(rb.getString("sessions.isnew") + " " + session.isNew() + 
"<br>");
  -        out.println(rb.getString("sessions.created") + " ");
  -        out.println(new Date(session.getCreationTime()) + "<br>");
  -        out.println(rb.getString("sessions.lastaccessed") + " ");
  -        out.println(new Date(session.getLastAccessedTime()));
  -               out.println("<br>");
  -               out.println(rb.getString("sessions.requestedid") + " " + 
request.getRequestedSessionId() + "<br>");
  -               out.println(rb.getString("sessions.requestedidvalid") + " " + 
request.isRequestedSessionIdValid() + "<br>");
  -               //out.println(rb.getString("sessions.fromcookie") + " " + 
request.isRequestedSessionIdFromCookie() + "<br>");
  -               //out.println(rb.getString("sessions.fromurl") + " " + 
request.isRequestedSessionIdFromURL() + "<br>");
  -
  -               String invalidate = request.getParameter("INVALIDATE");
  -
  -               if(invalidate != null){
  -        // Remove From JCS
  -                       session.invalidate();
  -               }else{
  -                       String dataName = request.getParameter("dataname");
  -                       String dataValue = request.getParameter("datavalue");
  -                       if (dataName != null && dataValue != null) {
  -                                     session.setAttribute(dataName, dataValue);
  -                       }
  -
  -                       out.println("<P>");
  -                       out.println(rb.getString("sessions.data") + "<br>");
  -                       Enumeration names = session.getAttributeNames();
  -                       while (names.hasMoreElements()) {
  -                                     String name = (String) names.nextElement();
  -                                     String value = 
session.getAttribute(name).toString();
  -                                     out.println(name + " = " + value + "<br>");
  -                       }
  -               }
  -
  -      ///////////////////////////////////////////////
  -        out.println("<P>");
  -        out.print("<form action=\"");
  -        out.print(response.encodeURL("SessionExample"));
  -        out.print("\" ");
  -        out.println("method=POST>");
  -        out.println(rb.getString("sessions.dataname"));
  -        out.println("<input type=text size=20 name=dataname>");
  -        out.println("<br>");
  -        out.println(rb.getString("sessions.datavalue"));
  -        out.println("<input type=text size=20 name=datavalue>");
  -        out.println("<br>");
  -        out.println("<input type=submit>");
  -        out.println("</form>");
  -
  -        out.println("<P>GET based form:<br>");
  -        out.print("<form action=\"");
  -        out.print(response.encodeURL("SessionExample"));
  -        out.print("\" ");
  -        out.println("method=GET>");
  -        out.println(rb.getString("sessions.dataname"));
  -        out.println("<input type=text size=20 name=dataname>");
  -        out.println("<br>");
  -        out.println(rb.getString("sessions.datavalue"));
  -        out.println("<input type=text size=20 name=datavalue>");
  -        out.println("<br>");
  -        out.println("<input type=submit>");
  -        out.println("</form>");
  -
  -        out.println("<P>");
  -        out.println("<P>Invalidate session:<br>");
  -        out.print("<form action=\"");
  -               out.print(response.encodeURL("SessionExample"));
  -        out.print("\" ");
  -        out.println("method=POST>");
  -               out.println("<input type=\"hidden\" name=INVALIDATE value=TRUE>");
  -               out.println("<input type=submit value=\"Invalidate session\">");
  -        out.println("</form>");
  +            PrintWriter out = response.getWriter();
  +            out.println( "<html>" );
  +            out.println( "<body bgcolor=\"white\">" );
  +            out.println( "<head>" );
  +
  +            String title = rb.getString( "sessions.title" );
  +            out.println( "<title>" + title + "</title>" );
  +            out.println( "</head>" );
  +            out.println( "<body>" );
  +
  +            // img stuff not req'd for source code html showing
  +            // relative links everywhere!
  +
  +            // XXX
  +            // making these absolute till we work out the
  +            // addition of a PathInfo issue
  +
  +            /*
  +             * out.println("<a href=\"/examples/servlets/sessions.html\">");
  +             * out.println("<img src=\"/examples/images/code.gif\" height=24 " +
  +             * "width=24 align=right border=0 alt=\"view code\"></a>");
  +             * out.println("<a href=\"/examples/servlets/index.html\">");
  +             * out.println("<img src=\"/examples/images/return.gif\" height=24 " +
  +             * "width=24 align=right border=0 alt=\"return\"></a>");
  +             */
  +            out.println( "<h3>" + title + "</h3>" );
  +
  +            // Get session as normal, but it is coming fomr the JCS
  +            HttpSession session = null;// = request.getSession();
  +            try
  +            {
  +                session = request.getSession( true );
  +            }
  +            catch ( IllegalStateException ise )
  +            {
  +                log.warn( ise.toString() );
  +            }
  +
  +            out.println( rb.getString( "sessions.id" ) + " " + session.getId() );
  +            out.println( "<br>" );
  +            out.println( rb.getString( "sessions.isnew" ) + " " + session.isNew() + 
"<br>" );
  +            out.println( rb.getString( "sessions.created" ) + " " );
  +            out.println( new Date( session.getCreationTime() ) + "<br>" );
  +            out.println( rb.getString( "sessions.lastaccessed" ) + " " );
  +            out.println( new Date( session.getLastAccessedTime() ) );
  +            out.println( "<br>" );
  +            out.println( rb.getString( "sessions.requestedid" ) + " " + 
request.getRequestedSessionId() + "<br>" );
  +            out.println( rb.getString( "sessions.requestedidvalid" ) + " " + 
request.isRequestedSessionIdValid() + "<br>" );
  +            //out.println(rb.getString("sessions.fromcookie") + " " + 
request.isRequestedSessionIdFromCookie() + "<br>");
  +            //out.println(rb.getString("sessions.fromurl") + " " + 
request.isRequestedSessionIdFromURL() + "<br>");
  +
  +            String invalidate = request.getParameter( "INVALIDATE" );
  +
  +            if ( invalidate != null )
  +            {
  +                // Remove From JCS
  +                session.invalidate();
  +            }
  +            else
  +            {
  +                String dataName = request.getParameter( "dataname" );
  +                String dataValue = request.getParameter( "datavalue" );
  +                if ( dataName != null && dataValue != null )
  +                {
  +                    session.setAttribute( dataName, dataValue );
  +                }
  +
  +                out.println( "<P>" );
  +                out.println( rb.getString( "sessions.data" ) + "<br>" );
  +                Enumeration names = session.getAttributeNames();
  +                while ( names.hasMoreElements() )
  +                {
  +                    String name = ( String ) names.nextElement();
  +                    String value = session.getAttribute( name ).toString();
  +                    out.println( name + " = " + value + "<br>" );
  +                }
  +            }
  +
  +            ///////////////////////////////////////////////
  +            out.println( "<P>" );
  +            out.print( "<form action=\"" );
  +            out.print( response.encodeURL( "SessionExample" ) );
  +            out.print( "\" " );
  +            out.println( "method=POST>" );
  +            out.println( rb.getString( "sessions.dataname" ) );
  +            out.println( "<input type=text size=20 name=dataname>" );
  +            out.println( "<br>" );
  +            out.println( rb.getString( "sessions.datavalue" ) );
  +            out.println( "<input type=text size=20 name=datavalue>" );
  +            out.println( "<br>" );
  +            out.println( "<input type=submit>" );
  +            out.println( "</form>" );
  +
  +            out.println( "<P>GET based form:<br>" );
  +            out.print( "<form action=\"" );
  +            out.print( response.encodeURL( "SessionExample" ) );
  +            out.print( "\" " );
  +            out.println( "method=GET>" );
  +            out.println( rb.getString( "sessions.dataname" ) );
  +            out.println( "<input type=text size=20 name=dataname>" );
  +            out.println( "<br>" );
  +            out.println( rb.getString( "sessions.datavalue" ) );
  +            out.println( "<input type=text size=20 name=datavalue>" );
  +            out.println( "<br>" );
  +            out.println( "<input type=submit>" );
  +            out.println( "</form>" );
  +
  +            out.println( "<P>" );
  +            out.println( "<P>Invalidate session:<br>" );
  +            out.print( "<form action=\"" );
  +            out.print( response.encodeURL( "SessionExample" ) );
  +            out.print( "\" " );
  +            out.println( "method=POST>" );
  +            out.println( "<input type=\"hidden\" name=INVALIDATE value=TRUE>" );
  +            out.println( "<input type=submit value=\"Invalidate session\">" );
  +            out.println( "</form>" );
   
   //             out.print("<p><a href=\"");
   //        
out.print(response.encodeURL("SessionExample?dataname=foo&datavalue=bar"));
   //        out.println("\" >URL encoded </a>");
   
  -        out.println("</body>");
  -        out.println("</html>");
  +            out.println( "</body>" );
  +            out.println( "</html>" );
   
  -        out.println("</body>");
  -        out.println("</html>");
  +            out.println( "</body>" );
  +            out.println( "</html>" );
   
  -      } catch (Exception e) {
  -        log.error(e);
  -      }
  +        }
  +        catch ( Exception e )
  +        {
  +            log.error( e );
  +        }
   
       }
   
  -    public void doPost(HttpServletRequest request,
  -                      HttpServletResponse response)
  +    /**
  +     *  Description of the Method
  +     *
  +     *@param  request               Description of the Parameter
  +     *@param  response              Description of the Parameter
  +     *@exception  IOException       Description of the Exception
  +     *@exception  ServletException  Description of the Exception
  +     */
  +    public void doPost( HttpServletRequest request,
  +                        HttpServletResponse response )
           throws IOException, ServletException
       {
  -        doGet(request, response);
  +        doGet( request, response );
       }
   
   }
  
  
  
  1.4       +2 -2      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/IThreadPoolRunnable.java
  
  Index: IThreadPoolRunnable.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/IThreadPoolRunnable.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IThreadPoolRunnable.java  15 Jan 2002 21:33:37 -0000      1.3
  +++ IThreadPoolRunnable.java  18 Jan 2002 15:21:43 -0000      1.4
  @@ -1,7 +1,7 @@
  -
   package org.apache.stratum.jcs.utils.reuse;
   
  -import org.apache.tomcat.util.ThreadPoolRunnable;
  +
  +import org.apache.stratum.jcs.utils.threads.ThreadPoolRunnable;
   
   /**
    *  Implemented if you want to run a piece of code inside a thread pool.
  
  
  
  1.4       +2 -2      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/ThreadPoolManager.java
  
  Index: ThreadPoolManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/ThreadPoolManager.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ThreadPoolManager.java    15 Jan 2002 21:33:37 -0000      1.3
  +++ ThreadPoolManager.java    18 Jan 2002 15:21:43 -0000      1.4
  @@ -1,8 +1,8 @@
   
   package org.apache.stratum.jcs.utils.reuse;
   
  -import org.apache.tomcat.util.ThreadPool;
  -import org.apache.tomcat.util.ThreadPoolRunnable;
  +import org.apache.stratum.jcs.utils.threads.ThreadPool;
  +import org.apache.stratum.jcs.utils.threads.ThreadPoolRunnable;
   
   /**
    *  Provides a singleton thread pool.
  
  
  
  1.4       +2 -2      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/TomcatQueue.java
  
  Index: TomcatQueue.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/reuse/TomcatQueue.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TomcatQueue.java  15 Jan 2002 21:33:37 -0000      1.3
  +++ TomcatQueue.java  18 Jan 2002 15:21:43 -0000      1.4
  @@ -1,6 +1,6 @@
   package org.apache.stratum.jcs.utils.reuse;
   
  -import org.apache.tomcat.util.Queue;
  +import org.apache.stratum.jcs.utils.data.QueueT;
   
   /**
    *  A simple FIFO queue class which causes the calling thread to wait if the
  @@ -10,6 +10,6 @@
    *@author     asmuts
    *@created    January 15, 2002
    */
  -public class TomcatQueue extends Queue implements ITomcatQueue
  +public class TomcatQueue extends QueueT implements ITomcatQueue
   {
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to