Author: markt
Date: Mon May 3 22:18:43 2010
New Revision: 940656
URL: http://svn.apache.org/viewvc?rev=940656&view=rev
Log:
Fix the tests the Lifecycle/MBean refactoring in r940634 broke.
Modified:
tomcat/trunk/java/org/apache/catalina/connector/Connector.java
Modified: tomcat/trunk/java/org/apache/catalina/connector/Connector.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/connector/Connector.java?rev=940656&r1=940655&r2=940656&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/connector/Connector.java (original)
+++ tomcat/trunk/java/org/apache/catalina/connector/Connector.java Mon May 3
22:18:43 2010
@@ -850,19 +850,10 @@ public class Connector extends Lifecycle
IntrospectionUtils.setProperty(protocolHandler, "jkHome",
System.getProperty("catalina.base"));
- try {
- protocolHandler.init();
- } catch (Exception e) {
- throw new LifecycleException
- (sm.getString
- ("coyoteConnector.protocolHandlerInitializationFailed", e));
- }
-
onameProtocolHandler = register(protocolHandler,
createObjectNameKeyProperties("ProtocolHandler"));
mapperListener.setDomain(getDomain());
- mapperListener.init();
onameMapper = register(mapperListener,
createObjectNameKeyProperties("Mapper"));
@@ -879,6 +870,16 @@ public class Connector extends Lifecycle
setState(LifecycleState.STARTING);
+ // Protocol handlers do not follow Lifecycle conventions.
+ // protocolHandler.init() needs to wait until the connector.start()
+ try {
+ protocolHandler.init();
+ } catch (Exception e) {
+ throw new LifecycleException
+ (sm.getString
+ ("coyoteConnector.protocolHandlerInitializationFailed", e));
+ }
+
try {
protocolHandler.start();
} catch (Exception e) {
@@ -891,6 +892,9 @@ public class Connector extends Lifecycle
(errPrefix + " " + sm.getString
("coyoteConnector.protocolHandlerStartFailed", e));
}
+
+ // MapperListener doesn't follow Lifecycle conventions either
+ mapperListener.init();
}
@@ -904,15 +908,8 @@ public class Connector extends Lifecycle
setState(LifecycleState.STOPPING);
- }
-
-
- @Override
- protected void destroyInternal() throws LifecycleException {
- mapperListener.destroy();
- unregister(onameMapper);
- unregister(onameProtocolHandler);
-
+ // Protocol handlers do not follow Lifecycle conventions.
+ // protocolHandler.destroy() needs to be called in connector.stop()
try {
protocolHandler.destroy();
} catch (Exception e) {
@@ -921,6 +918,16 @@ public class Connector extends Lifecycle
("coyoteConnector.protocolHandlerDestroyFailed", e));
}
+ // MapperListener doesn't follow Lifecycle conventions either
+ mapperListener.destroy();
+ }
+
+
+ @Override
+ protected void destroyInternal() throws LifecycleException {
+ unregister(onameMapper);
+ unregister(onameProtocolHandler);
+
if (getService() != null) {
getService().removeConnector(this);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]