mx4j/src/tools/mx4j/tools/remote/soap/web/jetty JettyWebContainer.java,1.3,1.4

Simone Bordet <[email protected]>
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/web/jetty
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26867/src/tools/mx4j/tools/remote/soap/web/jetty

Modified Files:
	JettyWebContainer.java 
Log Message:
+ Splitting start() into start() and deploy()
+ Added undeploy()

Index: JettyWebContainer.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/soap/web/jetty/JettyWebContainer.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** JettyWebContainer.java	28 Feb 2004 10:40:47 -0000	1.3
--- JettyWebContainer.java	18 Jul 2004 21:18:13 -0000	1.4
***************
*** 9,19 ****
  package mx4j.tools.remote.soap.web.jetty;
  
  import java.util.Map;
- 
  import javax.management.remote.JMXServiceURL;
  
  import mx4j.tools.remote.soap.web.WebContainer;
- import org.apache.axis.transport.http.AxisServlet;
  import org.mortbay.jetty.Server;
  import org.mortbay.jetty.servlet.ServletHttpContext;
  import org.mortbay.util.MultiException;
--- 9,19 ----
  package mx4j.tools.remote.soap.web.jetty;
  
+ import java.io.IOException;
  import java.util.Map;
  import javax.management.remote.JMXServiceURL;
  
  import mx4j.tools.remote.soap.web.WebContainer;
  import org.mortbay.jetty.Server;
+ import org.mortbay.jetty.servlet.ServletHandler;
  import org.mortbay.jetty.servlet.ServletHttpContext;
  import org.mortbay.util.MultiException;
***************
*** 21,24 ****
--- 21,25 ----
  /**
   * Jetty's implementation of WebContainer interface
+  *
   * @author <a href="mailto:[email protected]">Alireza Taherkordi</a>
   * @version $Revision$
***************
*** 33,64 ****
     }
  
!    public void start(JMXServiceURL url, Map environment) throws Exception
     {
-       server.addListener(":" + url.getPort());
-       ServletHttpContext context = (ServletHttpContext)server.getContext("/");
- 
-       String path = url.getURLPath();
-       String urlPattern = null;
-       int lastSlash = path.lastIndexOf('/');
-       if (lastSlash < 0)
-          urlPattern = "/*";
-       else
-          urlPattern = path.substring(0, lastSlash + 1) + "*";
- 
-       context.addServlet(urlPattern, AxisServlet.class.getName());
- 
        try
        {
           server.start();
        }
        catch (MultiException x)
        {
!          x.ifExceptionThrow();
        }
     }
  
!    public void stop() throws Exception
     {
!       server.stop();
     }
  }
--- 34,96 ----
     }
  
!    public void start(JMXServiceURL url, Map environment) throws IOException
     {
        try
        {
+          server.addListener(":" + url.getPort());
           server.start();
        }
        catch (MultiException x)
        {
!          throw new IOException(x.toString());
        }
     }
  
!    public void stop() throws IOException
     {
!       try
!       {
!          server.stop();
!       }
!       catch (InterruptedException x)
!       {
!          Thread.currentThread().interrupt();
!       }
!    }
! 
!    public void deploy(String servletClassName, JMXServiceURL url, Map environment) throws IOException
!    {
!       try
!       {
!          String urlPattern = resolveServletMapping(url);
!          ServletHttpContext context = (ServletHttpContext)server.getContext("/");
!          context.addServlet(urlPattern, servletClassName);
!          // TODO: be sure an undeployed url is not restarted !
!          if (!context.isStarted()) context.start();
!       }
!       catch (Exception x)
!       {
!          throw new IOException(x.toString());
!       }
!    }
! 
!    public void undeploy(String servletName, JMXServiceURL url, Map environment)
!    {
!       String urlPattern = resolveServletMapping(url);
!       ServletHttpContext context = (ServletHttpContext)server.getContext("/");
!       ServletHandler handler = context.getServletHandler();
!       handler.getServletMap().remove(urlPattern);
!    }
! 
!    private String resolveServletMapping(JMXServiceURL url)
!    {
!       String path = url.getURLPath();
!       String urlPattern = null;
!       if (path.endsWith("/"))
!          urlPattern = path + "*";
!       else
!          urlPattern = path + "/*";
!       if (!urlPattern.startsWith("/")) urlPattern = "/" + urlPattern;
!       return urlPattern;
     }
  }



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.