User: starksm
Date: 01/06/22 12:41:42
Modified: src/main/org/jboss/util Tag: Branch_2_4
ServiceMBeanSupport.java
Log:
Initialize the logging interface in the constructor and set the
log4j category name to the full class name
Revision Changes Path
No revision
No revision
1.13.4.1 +22 -24 jboss/src/main/org/jboss/util/ServiceMBeanSupport.java
Index: ServiceMBeanSupport.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/util/ServiceMBeanSupport.java,v
retrieving revision 1.13
retrieving revision 1.13.4.1
diff -u -r1.13 -r1.13.4.1
--- ServiceMBeanSupport.java 2001/06/11 00:40:26 1.13
+++ ServiceMBeanSupport.java 2001/06/22 19:41:42 1.13.4.1
@@ -30,7 +30,7 @@
@author Rickard �berg ([EMAIL PROTECTED])
@author [EMAIL PROTECTED]
-@version $Revision: 1.13 $
+@version $Revision: 1.13.4.1 $
*/
public abstract class ServiceMBeanSupport
extends NotificationBroadcasterSupport
@@ -45,6 +45,14 @@
// Static --------------------------------------------------------
+ // Constructors --------------------------------------------------
+ public ServiceMBeanSupport()
+ {
+ category = Category.getInstance(getClass());
+ log = new LogToCategory(category);
+ }
+
+
// Public --------------------------------------------------------
public abstract String getName();
@@ -66,23 +74,20 @@
public void init()
throws Exception
{
- category = Category.getInstance(getName());
- log = new LogToCategory(category);
- log.log("Initializing");
+ category.info("Initializing");
log.setLog(log);
try
{
initService();
} catch (Exception e)
{
- log.error("Initialization failed");
- log.exception(e);
+ category.error("Initialization failed", e);
throw e;
} finally
{
log.unsetLog();
}
- log.log("Initialized");
+ category.info("Initialized");
}
public void start()
@@ -94,7 +99,7 @@
state = STARTING;
//AS It seems that the first attribute is not needed anymore and use a long
instead of a Date
sendNotification(new AttributeChangeNotification(this, id++, new
Date().getTime(), getName()+" starting", "State", "java.lang.Integer", new
Integer(STOPPED), new Integer(STARTING)));
- log.log("Starting");
+ category.info("Starting");
log.setLog(log);
try
{
@@ -104,8 +109,7 @@
state = STOPPED;
//AS It seems that the first attribute is not needed anymore and use a
long instead of a Date
sendNotification(new AttributeChangeNotification(this, id++, new
Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new
Integer(STARTING), new Integer(STOPPED)));
- log.error("Stopped");
- log.exception(e);
+ category.error("Stopped", e);
throw e;
} finally
{
@@ -114,7 +118,7 @@
state = STARTED;
//AS It seems that the first attribute is not needed anymore and use a long
instead of a Date
sendNotification(new AttributeChangeNotification(this, id++, new
Date().getTime(), getName()+" started", "State", "java.lang.Integer", new
Integer(STARTING), new Integer(STARTED)));
- log.log("Started");
+ category.info("Started");
}
public void stop()
@@ -125,7 +129,7 @@
state = STOPPING;
//AS It seems that the first attribute is not needed anymore and use a long
instead of a Date
sendNotification(new AttributeChangeNotification(this, id++, new
Date().getTime(), getName()+" stopping", "State", "java.lang.Integer", new
Integer(STARTED), new Integer(STOPPING)));
- log.log("Stopping");
+ category.info("Stopping");
log.setLog(log);
try
@@ -133,13 +137,13 @@
stopService();
} catch (Throwable e)
{
- log.exception(e);
+ category.error(e);
}
state = STOPPED;
//AS It seems that the first attribute is not needed anymore and use a long
instead of a Date
sendNotification(new AttributeChangeNotification(this, id++, new
Date().getTime(), getName()+" stopped", "State", "java.lang.Integer", new
Integer(STOPPING), new Integer(STOPPED)));
- log.log("Stopped");
+ category.info("Stopped");
log.unsetLog();
}
@@ -148,18 +152,18 @@
if (getState() != STOPPED)
stop();
- log.log("Destroying");
+ category.info("Destroying");
log.setLog(log);
try
{
destroyService();
} catch (Exception e)
{
- log.exception(e);
+ category.error(e);
}
log.unsetLog();
- log.log("Destroyed");
+ category.info("Destroyed");
}
public ObjectName preRegister(MBeanServer server, ObjectName name)
@@ -173,13 +177,7 @@
public void postRegister(java.lang.Boolean registrationDone)
{
if (!registrationDone.booleanValue()) {
- if( category == null ) {
- category = Category.getInstance(getName());
- }
- if( log == null ) {
- log = new LogToCategory(category);
- }
- log.log( "Registration is not done -> destroy" );
+ category.info( "Registration is not done -> destroy" );
destroy();
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-development