mx4j/src/tools/mx4j/tools/remote/http/jetty JettyWebContainer.java,1.4,1.5

Simone Bordet <[email protected]> Mon, 21 Feb 2005 11:27:43 +0000
Newsgroups gmane.comp.java.mx4j.cvs
Message-ID <[email protected]>
Update of /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/http/jetty
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10292/src/tools/mx4j/tools/remote/http/jetty

Modified Files:
	JettyWebContainer.java 
Log Message:
Refactored to allow easier subclassing

Index: JettyWebContainer.java
===================================================================
RCS file: /cvsroot/mx4j/mx4j/src/tools/mx4j/tools/remote/http/jetty/JettyWebContainer.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** JettyWebContainer.java	20 Oct 2004 17:14:59 -0000	1.4
--- JettyWebContainer.java	21 Feb 2005 11:27:41 -0000	1.5
***************
*** 11,19 ****
  import java.io.IOException;
  import java.util.Map;
  import javax.management.remote.JMXServiceURL;
  
  import mx4j.log.Log;
  import mx4j.log.Logger;
! import mx4j.remote.MX4JRemoteConstants;
  import mx4j.tools.remote.http.WebContainer;
  import org.mortbay.http.HttpListener;
--- 11,20 ----
  import java.io.IOException;
  import java.util.Map;
+ 
  import javax.management.remote.JMXServiceURL;
  
  import mx4j.log.Log;
  import mx4j.log.Logger;
! import mx4j.tools.remote.http.HTTPConnectorServer;
  import mx4j.tools.remote.http.WebContainer;
  import org.mortbay.http.HttpListener;
***************
*** 36,51 ****
     }
  
!    private Logger getLogger()
     {
        return Log.getLogger(getClass().getName());
     }
  
!    public void start(JMXServiceURL url, Map environment) throws IOException
     {
  
        try
        {
           configure(url, environment);
!          server.start();
        }
        catch (IOException x)
--- 37,56 ----
     }
  
!    protected Logger getLogger()
     {
        return Log.getLogger(getClass().getName());
     }
  
!    protected Server getServer()
     {
+       return server;
+    }
  
+    public void start(JMXServiceURL url, Map environment) throws IOException
+    {
        try
        {
           configure(url, environment);
!          getServer().start();
        }
        catch (IOException x)
***************
*** 65,76 ****
        if (environment != null)
        {
!          Object config = environment.get(MX4JRemoteConstants.HTTP_SERVER_CONFIGURATION);
           if (config instanceof String)
           {
              if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Configuring Jetty with configuration " + config);
!             server.configure((String)config);
  
              // Be sure there is at least one listener on the port specified by the JMXServiceURL
!             HttpListener[] listeners = server.getListeners();
              if (listeners != null)
              {
--- 70,81 ----
        if (environment != null)
        {
!          Object config = environment.get(HTTPConnectorServer.WEB_CONTAINER_CONFIGURATION);
           if (config instanceof String)
           {
              if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Configuring Jetty with configuration " + config);
!             getServer().configure((String)config);
  
              // Be sure there is at least one listener on the port specified by the JMXServiceURL
!             HttpListener[] listeners = getServer().getListeners();
              if (listeners != null)
              {
***************
*** 100,106 ****
           }
        }
  
        if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Configuring Jetty with a default listener on port " + url.getPort());
!       server.addListener(":" + url.getPort());
     }
  
--- 105,116 ----
           }
        }
+       configureListener(url, environment);
+    }
  
+    protected void configureListener(JMXServiceURL url, Map environment) throws IOException
+    {
+       Logger logger = getLogger();
        if (logger.isEnabledFor(Logger.DEBUG)) logger.debug("Configuring Jetty with a default listener on port " + url.getPort());
!       getServer().addListener(":" + url.getPort());
     }
  
***************
*** 109,113 ****
        try
        {
!          server.stop();
        }
        catch (InterruptedException x)
--- 119,123 ----
        try
        {
!          getServer().stop();
        }
        catch (InterruptedException x)
***************
*** 122,126 ****
        {
           String urlPattern = resolveServletMapping(url);
!          ServletHttpContext context = (ServletHttpContext)server.getContext("/");
           context.addServlet(urlPattern, servletClassName);
           // TODO: be sure an undeployed url is not restarted !
--- 132,136 ----
        {
           String urlPattern = resolveServletMapping(url);
!          ServletHttpContext context = (ServletHttpContext)getServer().getContext("/");
           context.addServlet(urlPattern, servletClassName);
           // TODO: be sure an undeployed url is not restarted !
***************
*** 136,140 ****
     {
        String urlPattern = resolveServletMapping(url);
!       ServletHttpContext context = (ServletHttpContext)server.getContext("/");
        ServletHandler handler = context.getServletHandler();
        handler.getServletMap().remove(urlPattern);
--- 146,150 ----
     {
        String urlPattern = resolveServletMapping(url);
!       ServletHttpContext context = (ServletHttpContext)getServer().getContext("/");
        ServletHandler handler = context.getServletHandler();
        handler.getServletMap().remove(urlPattern);



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click