User: starksm 
  Date: 01/11/27 23:48:09

  Modified:    catalina/src/main/org/jboss/web/catalina Tag: Branch_2_4
                        EmbeddedCatalinaServiceSX.java
                        EmbeddedCatalinaServiceSXMBean.java
  Log:
  Add support for setting the type of the primary connector. Currently
  http or warp connectors are supported.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.4   +74 -33    
contrib/catalina/src/main/org/jboss/web/catalina/EmbeddedCatalinaServiceSX.java
  
  Index: EmbeddedCatalinaServiceSX.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/catalina/src/main/org/jboss/web/catalina/EmbeddedCatalinaServiceSX.java,v
  retrieving revision 1.2.2.3
  retrieving revision 1.2.2.4
  diff -u -r1.2.2.3 -r1.2.2.4
  --- EmbeddedCatalinaServiceSX.java    2001/11/20 09:54:18     1.2.2.3
  +++ EmbeddedCatalinaServiceSX.java    2001/11/28 07:48:09     1.2.2.4
  @@ -19,6 +19,7 @@
   import java.util.HashMap;
   import java.util.Iterator;
   import javax.naming.InitialContext;
  +import javax.naming.NamingException;
   import javax.servlet.ServletContext;
   import javax.xml.parsers.DocumentBuilderFactory;
   import javax.xml.parsers.DocumentBuilder;
  @@ -53,6 +54,9 @@
   import org.apache.catalina.Valve;
   import org.apache.catalina.authenticator.AuthenticatorBase;
   import org.apache.catalina.connector.http.HttpConnector;
  +import org.apache.catalina.connector.warp.WarpConnector;
  +import org.apache.catalina.connector.warp.WarpHost;
  +import org.apache.catalina.connector.warp.WarpEngine;
   import org.apache.catalina.core.StandardContext;
   import org.apache.catalina.loader.WebappClassLoader;
   import org.apache.catalina.startup.Embedded;
  @@ -65,7 +69,7 @@
    @see org.apache.catalina.startup.Embedded
    
    @author [EMAIL PROTECTED]
  - @version $Revision: 1.2.2.3 $
  + @version $Revision: 1.2.2.4 $
    */
   public class EmbeddedCatalinaServiceSX extends AbstractWebContainer implements 
EmbeddedCatalinaServiceSXMBean
   {
  @@ -76,8 +80,6 @@
      private Embedded catalina;
      /** The catalina host container */
      private Host catalinaHost;
  -   /** The name of the Engine implementation class */
  -   private String engineClassName;
      /** The catalina debug level */
      private int debugLevel;
      /** The port the web server listens on */
  @@ -95,6 +97,8 @@
      private int maxProcessors = 20;
      /** The JNDI name of the SecurityDomain implementation binding */
      private String securityDomain;
  +   /** The type of connector that Tomcat will run (HTTP or WARP) */
  +   private String connectorType = "http";
      /** Any extended configuration information specified via a config
       element in the mbean definition.
       */
  @@ -133,19 +137,21 @@
            bindAddress = InetAddress.getByName(host);
      }
   
  -   public String getEngineClass()
  +   public String getConnectorType()
      {
  -      return engineClassName;
  +      return this.connectorType;
      }
  -   public void setEngineClass(String className) throws ClassNotFoundException
  +
  +   public void setConnectorType(String type)
      {
  -      this.engineClassName = className;
  -      if( engineClassName != null )
  +      type = type.toLowerCase();
  +      if( type.equals("http") == false && type.equals("warp") == false )
         {
  -         // Check that the class is accessible
  -         ClassLoader loader = Thread.currentThread().getContextClassLoader();
  -         loader.loadClass(engineClassName);
  +         String msg= "Invalid connector type: "+connectorType
  +            + " must be one of, http warp";
  +         throw new IllegalArgumentException(msg);
         }
  +      this.connectorType = type;
      }
   
      public int getMinProcessors()
  @@ -297,7 +303,7 @@
      }
   
      /** Create and configure a org.apache.catalina.startup.Embedded
  -    instance. Currently we do not use the server.xml file as we obtain all
  +    instance. We do not use the server.xml file as we obtain all
       of the required customization from our mbean properties.
       */
      private void initCatalina(ClassLoader parent) throws Exception
  @@ -308,33 +314,39 @@
         catalina.setDebug(debugLevel);
         catalina.setUseNaming(false);
   
  +      // Setup the primary engine and connector
  +      if( connectorType.equals("http") )
  +         initHttpConnector(parent, jbossLog, jbossRealm);
  +      else if( connectorType.equals("warp") )
  +         initWarpConnector(parent, jbossLog, jbossRealm);
  +      else
  +         throw new IllegalStateException("No valid connectorType");
  +
  +      // Apply any extended configuration
  +      ConfigHandler handler = new ConfigHandler();
  +      handler.applyHostConfig(extendedConfig, catalina, debugLevel > 0);
  +   }
  +
  +   private void initHttpConnector(ClassLoader parent, Logger jbossLog, Realm 
jbossRealm)
  +      throws IOException, NamingException
  +   {
  +      log.info("Building Http engine and connector");
         String hostname = "localhost";
         if( bindAddress != null )
            hostname = bindAddress.getHostName();
  -      Engine engine = null;
  -      if( engineClassName != null )
  -      {
  -         Class engineClass = parent.loadClass(engineClassName);
  -         engine = (Engine) engineClass.newInstance();
  -         engine.setLogger(jbossLog);
  -         engine.setRealm(jbossRealm);
  -      }
  -      else
  -      {
  -         engine = catalina.createEngine();
  -      }
  +      // Create the engine
  +      Engine engine = catalina.createEngine();
         engine.setDefaultHost(hostname);
  -
  +      engine.setParentClassLoader(parent);
  +      // Create a host for the root context
         catalinaHost = catalina.createHost(hostname, "");
         engine.addChild(catalinaHost);
  -      engine.setParentClassLoader(parent);
   
  -      // Install the assembled container hierarchy
  +      // Install the engine
         catalina.addEngine(engine);
   
  -      // Assemble and install a connector for our port and address
  +      // Create the warp connector and set its properties
         HttpConnector connector = (HttpConnector) 
catalina.createConnector(bindAddress, port, false);
  -      // Set the connector properties
         connector.setAcceptCount(acceptCount);
         connector.setMinProcessors(minProcessors);
         connector.setMaxProcessors(maxProcessors);
  @@ -349,10 +361,39 @@
            connector.setFactory(new SSLServerSocketFactory(domain));
         }
         catalina.addConnector(connector);
  -
  -      // Apply any extended configuration
  -      ConfigHandler handler = new ConfigHandler();
  -      handler.applyHostConfig(extendedConfig, catalina, debugLevel > 0);
  +   }
  +   private void initWarpConnector(ClassLoader parent, Logger jbossLog, Realm 
jbossRealm)
  +   {
  +      log.info("Building Warp engine and connector");
  +      String hostname = "localhost";
  +      if( bindAddress != null )
  +         hostname = bindAddress.getHostName();
  +      // Create the engine
  +      WarpEngine warpEngine = new WarpEngine();
  +      warpEngine.setDebug(debugLevel);
  +      warpEngine.setLogger(jbossLog);
  +      warpEngine.setRealm(jbossRealm);
  +      warpEngine.setDefaultHost(hostname);
  +      warpEngine.setParentClassLoader(parent);
  +      // Create a host for the root context      
  +      WarpHost warpHost = new WarpHost();
  +      warpHost.setAppBase("");
  +      warpHost.setName(hostname);
  +      warpHost.setDebug(debugLevel);
  +      warpEngine.addChild(warpHost);
  +
  +      // Install the engine
  +      catalina.addEngine(warpEngine);
  +
  +      // Create the warp connector and set its properties
  +      WarpConnector warpConnector = new WarpConnector();
  +      warpConnector.setAcceptCount(acceptCount);
  +      warpConnector.setEnableLookups(enableLookups);
  +      warpConnector.setPort(port);
  +      if (bindAddress != null)
  +         warpConnector.setAddress(hostname);
  +      catalina.addConnector(warpConnector);
  +      catalinaHost = warpHost;
      }
   
      private WebApplication createWebContext(String ctxPath, URL warUrl,
  
  
  
  1.1.2.3   +14 -8     
contrib/catalina/src/main/org/jboss/web/catalina/EmbeddedCatalinaServiceSXMBean.java
  
  Index: EmbeddedCatalinaServiceSXMBean.java
  ===================================================================
  RCS file: 
/cvsroot/jboss/contrib/catalina/src/main/org/jboss/web/catalina/EmbeddedCatalinaServiceSXMBean.java,v
  retrieving revision 1.1.2.2
  retrieving revision 1.1.2.3
  diff -u -r1.1.2.2 -r1.1.2.3
  --- EmbeddedCatalinaServiceSXMBean.java       2001/11/20 09:54:19     1.1.2.2
  +++ EmbeddedCatalinaServiceSXMBean.java       2001/11/28 07:48:09     1.1.2.3
  @@ -16,7 +16,7 @@
   /** Management interface for the embedded Catalina service.
    *
    * @author [EMAIL PROTECTED]
  - * @version $Revision: 1.1.2.2 $
  + * @version $Revision: 1.1.2.3 $
    */
   public interface EmbeddedCatalinaServiceSXMBean extends AbstractWebContainerMBean
   {
  @@ -41,13 +41,6 @@
       */
      public void setBindAddress(String host) throws UnknownHostException;
   
  -   /** Get the class name of the server container engine class.
  -    */
  -   public String getEngineClass();
  -   /** Set the class name of the server container engine class.
  -    */
  -   public void setEngineClass(String className) throws ClassNotFoundException;
  -
      /**@return the accept count for this Connector.
       */
      public int getAcceptCount();
  @@ -99,6 +92,19 @@
       instance to use with JSSE.
       */
      public void setSecurityDomain(String securityDomain);
  +
  +   /** Get the type of the primary connector. Currently only http
  +    and warp are supported.
  +    @return http or warp
  +    */
  +   public String getConnectorType();
  +   /** Set the type of the primary connector. Currently only http
  +    and warp are supported. Additional connectors may be set through
  +    the config child element of the MBean configuration.
  +
  +    @param type, must be one of http or warp
  +    */
  +   public void setConnectorType(String type);
   
      /** Override the AbstractWebContainerMBean to provide support for extended
       configuration using constructs from the standard server.xml to configure
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to