pero        2005/01/29 11:44:43

  Modified:    catalina/src/share/org/apache/catalina/connector
                        LocalStrings.properties Connector.java
  Log:
  Change Mbean names from Mapper and ProtocolHandler
  Every connector have its unique  Mapper and ProtocoHandler at the MBeanserver
  Fix a start/stop/start connector szenario
  
  Revision  Changes    Path
  1.6       +6 -3      
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties
  
  Index: LocalStrings.properties
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/LocalStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LocalStrings.properties   1 Nov 2004 23:35:39 -0000       1.5
  +++ LocalStrings.properties   29 Jan 2005 19:44:43 -0000      1.6
  @@ -14,7 +14,8 @@
   coyoteConnector.protocolRegistrationFailed=Protocol JMX registration failed
   coyoteConnector.protocolHandlerPauseFailed=Protocol handler pause failed
   coyoteConnector.protocolHandlerResumeFailed=Protocol handler resume failed
  -
  +coyoteConnector.MapperRegistration=register Mapper: {0}
  +coyoteConnector.protocolUnregistrationFailed=Protocol handler stop failed
   #
   # CoyoteAdapter
   #
  @@ -50,8 +51,10 @@
   #
   # MapperListener
   #
  -
  -mapperListener.registerContext=Register Context {0}
  +mapperListener.unknownDefaultHost=Unknown default host: {0}
  +mapperListener.registerHost=Register host {0} at domain {1}
  +mapperListener.unregisterHost=Unregister host {0} at domain {1}
  +mapperListener.registerContext=Register Context {0} 
   mapperListener.unregisterContext=Unregister Context {0}
   mapperListener.registerWrapper=Register Wrapper {0} in Context {1}
   
  
  
  
  1.16      +46 -26    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java
  
  Index: Connector.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/connector/Connector.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- Connector.java    6 Dec 2004 13:59:28 -0000       1.15
  +++ Connector.java    29 Jan 2005 19:44:43 -0000      1.16
  @@ -874,6 +874,20 @@
   
       }
   
  +    
  +    protected ObjectName createObjectName(String domain, String type)
  +            throws MalformedObjectNameException {
  +        String encodedAddr = null;
  +        if (getProperty("address") != null) {
  +            encodedAddr = 
URLEncoder.encode(getProperty("address").toString());
  +        }
  +        String addSuffix = (getProperty("address") == null) ? "" : 
",address="
  +                + encodedAddr;
  +        ObjectName _oname = new ObjectName(domain + ":type=" + type + 
",port="
  +                + getPort() + addSuffix);
  +        return _oname;
  +    }
  +    
       /**
        * Initialize this connector (create ServerSocket here!)
        */
  @@ -881,7 +895,8 @@
           throws LifecycleException
       {
           if (initialized) {
  -            log.info(sm.getString("coyoteConnector.alreadyInitialized"));
  +            if(log.isInfoEnabled())
  +                log.info(sm.getString("coyoteConnector.alreadyInitialized"));
              return;
           }
   
  @@ -891,20 +906,15 @@
               try {
                   // we are loaded directly, via API - and no name was given 
to us
                   StandardEngine cb=(StandardEngine)container;
  -                String encodedAddr = null;
  -                if (getProperty("address") != null) {
  -                    encodedAddr = 
URLEncoder.encode(getProperty("address").toString());
  -                }
  -                String addSuffix=(getProperty("address")==null) ?"": 
",address=" + encodedAddr;
  -                oname=new ObjectName(cb.getName() + ":type=Connector,port="+
  -                        getPort() + addSuffix);
  +                oname = createObjectName(cb.getName(), "Connector");
                   Registry.getRegistry(null, null)
                       .registerComponent(this, oname, null);
                   controller=oname;
               } catch (Exception e) {
                   log.error( "Error registering connector ", e);
               }
  -            log.debug("Creating name for connector " + oname);
  +            if(log.isDebugEnabled())
  +                log.debug("Creating name for connector " + oname);
           }
   
           // Initializa adapter
  @@ -962,8 +972,9 @@
               initialize();
   
           // Validate and update our current state
  -        if (started) {
  -            log.info(sm.getString("coyoteConnector.alreadyStarted"));
  +        if (started ) {
  +            if(log.isInfoEnabled())
  +                log.info(sm.getString("coyoteConnector.alreadyStarted"));
               return;
           }
           lifecycle.fireLifecycleEvent(START_EVENT, null);
  @@ -975,14 +986,14 @@
               // We are registred - register the adapter as well.
               try {
                   Registry.getRegistry(null, null).registerComponent
  -                    (protocolHandler, this.domain + 
":type=protocolHandler,className="
  -                     + protocolHandlerClassName, null);
  +                    (protocolHandler, 
createObjectName(this.domain,"ProtocolHandler"), null);
               } catch (Exception ex) {
                   log.error(sm.getString
                             ("coyoteConnector.protocolRegistrationFailed"), 
ex);
               }
           } else {
  -            log.info(sm.getString
  +            if(log.isInfoEnabled())
  +                log.info(sm.getString
                        ("coyoteConnector.cannotRegisterProtocol"));
           }
   
  @@ -999,8 +1010,12 @@
               //mapperListener.setEngine( service.getContainer().getName() );
               mapperListener.init();
               try {
  +                ObjectName mapperOname = 
createObjectName(this.domain,"Mapper");
  +                if (log.isDebugEnabled())
  +                    log.debug(sm.getString(
  +                            "coyoteConnector.MapperRegistration", 
mapperOname));
                   Registry.getRegistry(null, null).registerComponent
  -                    (mapper, this.domain + ":type=Mapper", "Mapper");
  +                    (mapper, createObjectName(this.domain,"Mapper"), 
"Mapper");
               } catch (Exception ex) {
                   log.error(sm.getString
                           ("coyoteConnector.protocolRegistrationFailed"), ex);
  @@ -1026,14 +1041,14 @@
           started = false;
   
           try {
  +            mapperListener.destroy();
               Registry.getRegistry(null, null).unregisterComponent
  -                (new ObjectName(domain,"type", "Mapper"));
  +                (createObjectName(this.domain,"Mapper"));
               Registry.getRegistry(null, null).unregisterComponent
  -                (new ObjectName(domain
  -                 + ":type=protocolHandler,className="
  -                 + protocolHandlerClassName));
  +                (createObjectName(this.domain,"ProtocolHandler"));
           } catch (MalformedObjectNameException e) {
  -            log.info( "Error unregistering mapper ", e);
  +            log.error( sm.getString
  +                    ("coyoteConnector.protocolUnregistrationFailed"), e);
           }
           try {
               protocolHandler.destroy();
  @@ -1098,7 +1113,8 @@
               ObjectName parentName=new ObjectName( domain + ":" +
                       "type=Service");
               
  -            log.debug("Adding to " + parentName );
  +            if(log.isDebugEnabled())
  +                log.debug("Adding to " + parentName );
               if( mserver.isRegistered(parentName )) {
                   mserver.invoke(parentName, "addConnector", new Object[] { 
this },
                           new String[] 
{"org.apache.catalina.connector.Connector"});
  @@ -1111,13 +1127,15 @@
               ObjectName engName=new ObjectName( domain + ":" + "type=Engine");
               if( mserver.isRegistered(engName )) {
                   Object obj=mserver.getAttribute(engName, "managedResource");
  -                log.debug("Found engine " + obj + " " + obj.getClass());
  +                if(log.isDebugEnabled())
  +                      log.debug("Found engine " + obj + " " + 
obj.getClass());
                   container=(Container)obj;
                   
                   // Internal initialize - we now have the Engine
                   initialize();
                   
  -                log.debug("Initialized");
  +                if(log.isDebugEnabled())
  +                    log.debug("Initialized");
                   // As a side effect we'll get the container field set
                   // Also initialize will be called
                   return;
  @@ -1130,7 +1148,8 @@
       public void init() throws Exception {
   
           if( this.getService() != null ) {
  -            log.debug( "Already configured" );
  +            if(log.isDebugEnabled())
  +                 log.debug( "Already configured" );
               return;
           }
           if( container==null ) {
  @@ -1140,7 +1159,8 @@
   
       public void destroy() throws Exception {
           if( oname!=null && controller==oname ) {
  -            log.debug("Unregister itself " + oname );
  +            if(log.isDebugEnabled())
  +                 log.debug("Unregister itself " + oname );
               Registry.getRegistry(null, null).unregisterComponent(oname);
           }
           if( getService() == null)
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to