You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2005/03/11 18:14:02 UTC

DO NOT REPLY [Bug 33967] New: - add a parameter to Context

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=33967>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=33967

           Summary: add a parameter to Context
           Product: Tomcat 4
           Version: 4.1.31
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: enhancement
          Priority: P3
         Component: Webapps:Manager
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: lionel.farbos@free.fr


Hi all,

I recently post a suggestion for a problem of stop context (33589),
but you said to me that it was my problem.
So, I solved it with my solution,
And I provide you this solution :

1) I patch the Tomcat Manager to read the type parameter, pass it to the stop
method, then put it in the desired Context.
2) All my servlets inherit from a MotherServlet like below.

If other people like me want to use this new feature,
could you integrate this in the TC Manager ?

In advance, thank you.

For 1) :
$diff ManagerServlet.java.new ManagerServlet.java.cvs
371c370
<             stop(writer, path,type);
---
>             stop(writer, path);
1201c1200
<     protected void stop(PrintWriter writer, String path, String type) {
---
>     protected void stop(PrintWriter writer, String path) {
1204c1203
<             log("stop: Stopping (" + type +") web application at '" + path + "'");
---
>             log("stop: Stopping web application at '" + path + "'");
1227,1231d1225
<           if ( (type != null) && (! type.equals("")) ) {
<               context.getServletContext().setAttribute("TYPE",(Object)type);
<           }



$ diff HTMLManagerServlet.java.new HTMLManagerServlet.java.cvs
84d83
<         String type = request.getParameter("type");
107c106
<             message = stop(path,type);
---
>             message = stop(path);
524c523
<     protected String stop(String path,String type) {
---
>     protected String stop(String path) {
529c528
<         super.stop(printWriter, path,type);
---
>         super.stop(printWriter, path);


For 2), people will have to use such a MotherServlet :
public abstract class MotherServlet extends HttpServlet
{
 private static final Object lock = new Object();
 private static int nbActifsThreads = 0;
...
 protected void service(HttpServletRequest request, HttpServletResponse
response) throws IOException, ServletExcepti
on
 {
   synchronized (lock) { nbActifsThreads++; }
   try {
     super.service(request, response);
   }
   finally {
     try {
       response.flushBuffer();
     }
     catch (IOException e) {
       log( "exception", e );
     }
   }
   synchronized (lock) { nbActifsThreads--; }
 }

 public synchronized void destroy()
 {
   ServletContext myCtx = getServletContext();
   String typeStop = (String)myCtx.getAttribute("TYPE");
   if ( (typeStop != null) && (typeStop.equals("LIGHT")) )
   {
     while (nbThreadsActifs >0) {
       try { Thread.sleep(100); } catch (Exception e) {}
     }
   }
   // ... my specifics free resources
   super.destroy();
 }
}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org