You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by co...@apache.org on 2003/04/05 06:07:52 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core StandardService.java
costin 2003/04/04 20:07:52
Modified: catalina/src/share/org/apache/catalina/core
StandardService.java
Log:
Implement the controller trick.
Replace println with log.
Don't overreact if start is called twice.
Make sure stop() is called before destroy.
Revision Changes Path
1.6 +16 -17 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardService.java
Index: StandardService.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StandardService.java 27 Mar 2003 03:06:39 -0000 1.5
+++ StandardService.java 5 Apr 2003 04:07:52 -0000 1.6
@@ -1,8 +1,4 @@
/*
- * $Header$
- * $Revision$
- * $Date$
- *
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -92,7 +88,6 @@
* not required.
*
* @author Craig R. McClanahan
- * @version $Revision$ $Date$
*/
public class StandardService
@@ -553,8 +548,7 @@
// Validate and update our current component state
if (!started) {
- throw new LifecycleException
- (sm.getString("standardService.stop.notStarted"));
+ return;
}
// Notify our interested LifecycleListeners
@@ -562,7 +556,7 @@
lifecycle.fireLifecycleEvent(STOP_EVENT, null);
- System.out.println
+ log.info
(sm.getString("standardService.stop.name", this.name));
started = false;
@@ -582,16 +576,14 @@
}
}
}
-
- // unregister this service
- if( oname!=null ) {
- try {
- Registry.getRegistry().unregisterComponent(oname);
- log.info("unregistering " + oname);
- } catch (Exception e) {
- log.error("Error unregistering ",e);
- }
+
+ if( oname==controller ) {
+ // we registered ourself on init().
+ // That should be the typical case - this object is just for
+ // backward compat, nobody should bother to load it explicitely
+ Registry.getRegistry().unregisterComponent(oname);
}
+
// Notify our interested LifecycleListeners
lifecycle.fireLifecycleEvent(AFTER_STOP_EVENT, null);
@@ -619,6 +611,7 @@
Container engine=this.getContainer();
domain=engine.getName();
oname=new ObjectName(domain + ":type=Service,serviceName="+name);
+ this.controller=oname;
Registry.getRegistry().registerComponent(this, oname, null);
} catch (Exception e) {
log.error("Error registering ",e);
@@ -641,6 +634,11 @@
}
}
}
+
+ public void destroy() throws LifecycleException {
+ if( started ) stop();
+ // unregister should be here probably
+ }
public void init() {
try {
@@ -654,6 +652,7 @@
protected String domain;
protected String suffix;
protected ObjectName oname;
+ protected ObjectName controller;
protected MBeanServer mserver;
public ObjectName getObjectName() {
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org