tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cos...@apache.org
Subject cvs commit: jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5 CoyoteConnector.java
Date Sat, 08 Mar 2003 06:51:34 GMT
costin      2003/03/07 22:51:34

  Modified:    coyote/src/java/org/apache/coyote/tomcat5
                        CoyoteConnector.java
  Log:
  A bit more flexibility in starting ( init/start may end up beeing called twice,
  that shouldn't be treated as a catastrophic event ).
  
  Improved self-registration. My understanding is that we only need an Engine,
  so if no Service exists, just go to the engine.
  
  Revision  Changes    Path
  1.17      +54 -21    jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteConnector.java
  
  Index: CoyoteConnector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-connectors/coyote/src/java/org/apache/coyote/tomcat5/CoyoteConnector.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- CoyoteConnector.java	17 Feb 2003 05:07:30 -0000	1.16
  +++ CoyoteConnector.java	8 Mar 2003 06:51:34 -0000	1.17
  @@ -102,7 +102,7 @@
   
   public final class CoyoteConnector
       implements Connector, Lifecycle, MBeanRegistration
  - {
  +{
       private static Log log = LogFactory.getLog(CoyoteConnector.class);
   
   
  @@ -941,7 +941,7 @@
   
        /**
         * Set the URI encoding to be used for the URI.
  -      * 
  +      *
         * @param URIEncoding The new URI character encoding.
         */
        public void setURIEncoding(String URIEncoding) {
  @@ -1062,11 +1062,12 @@
        * Initialize this connector (create ServerSocket here!)
        */
       public void initialize()
  -        throws LifecycleException {
  -
  -        if (initialized)
  -            throw new LifecycleException
  -                (sm.getString("coyoteConnector.alreadyInitialized"));
  +        throws LifecycleException
  +    {
  +        if (initialized) {
  +            log.info(sm.getString("coyoteConnector.alreadyInitialized"));
  +            return;
  +        }
   
           this.initialized = true;
   
  @@ -1162,11 +1163,14 @@
        * @exception LifecycleException if a fatal startup error occurs
        */
       public void start() throws LifecycleException {
  +        if( !initialized )
  +            initialize();
   
           // Validate and update our current state
  -        if (started)
  -            throw new LifecycleException
  -                (sm.getString("coyoteConnector.alreadyStarted"));
  +        if (started) {
  +            log.info(sm.getString("coyoteConnector.alreadyStarted"));
  +            return;
  +        }
           lifecycle.fireLifecycleEvent(START_EVENT, null);
           started = true;
   
  @@ -1177,7 +1181,7 @@
               try {
                   Registry.getRegistry().registerComponent
                       (protocolHandler, this.domain, "protocolHandler",
  -                     "type=protocolHandler,className=" 
  +                     "type=protocolHandler,className="
                        + protocolHandlerClassName);
               } catch (Exception ex) {
                   log.error(sm.getString
  @@ -1197,7 +1201,16 @@
           }
   
           mapperListener.init();
  -
  +        if( this.domain != null ) {
  +            try {
  +                Registry.getRegistry().registerComponent
  +                        (mapper, this.domain, "Mapper",
  +                                "type=Mapper");
  +            } catch (Exception ex) {
  +                log.error(sm.getString
  +                        ("coyoteConnector.protocolRegistrationFailed"), ex);
  +            }
  +        }
       }
   
   
  @@ -1305,15 +1318,35 @@
               log.info( "Already configured" );
               return;
           }
  +        if( container==null ) {
  +            // Register to the service
  +            ObjectName parentName=new ObjectName( domain + ":" +
  +                    "type=Service,name=Tomcat-Standalone");
  +
  +            log.info("Adding to " + parentName );
  +            if( mserver.isRegistered(parentName )) {
  +                mserver.invoke(parentName, "addConnector", new Object[] { this },
  +                        new String[] {"org.apache.catalina.Connector"});
  +                // As a side effect we'll get the container field set
  +                // Also initialize will be called
  +                return;
  +            }
  +            // XXX Go directly to the Engine
  +            // initialize(); - is called by addConnector
  +            ObjectName engName=new ObjectName( domain + ":" +
  +                    "type=Engine,name=Tomcat-Standalone");
  +            if( mserver.isRegistered(parentName )) {
  +                container=(Container)mserver.getAttribute(parentName, "managedResource");
  +                log.info("Found engine " + container);
  +                initialize();
  +
  +                log.info("Initialized");
  +                // As a side effect we'll get the container field set
  +                // Also initialize will be called
  +                return;
  +            }
   
  -        // Register to the service
  -        ObjectName parentName=new ObjectName( domain + ":" +
  -                "type=Service,name=Tomcat-Standalone");
  -        log.info("Adding to " + parentName );
  -
  -        mserver.invoke(parentName, "addConnector", new Object[] { this },
  -                new String[] {"org.apache.catalina.Connector"});
  -        // initialize(); - is called by addConnector
  +        }
       }
   
       public void destroy() throws Exception {
  
  
  

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


Mime
View raw message