User: starksm
Date: 01/11/20 01:42:54
Modified: src/main/org/jboss/management Tag: Branch_2_4
ContainerManagement.java ServerDataCollector.java
Log:
Change to the unified log4j based org.jboss.logging.Logger class.
Revision Changes Path
No revision
No revision
1.1.2.2 +6 -16 jboss/src/main/org/jboss/management/ContainerManagement.java
Index: ContainerManagement.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/ContainerManagement.java,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -r1.1.2.1 -r1.1.2.2
--- ContainerManagement.java 2001/11/02 08:42:36 1.1.2.1
+++ ContainerManagement.java 2001/11/20 09:42:54 1.1.2.2
@@ -40,19 +40,7 @@
import javax.management.ObjectName;
import org.jboss.ejb.Container;
-
-import org.jboss.logging.Log;
-import org.jboss.logging.ConsoleLogging;
-import org.jboss.logging.ConsoleLoggingMBean;
-
-import org.jboss.metadata.ApplicationMetaData;
import org.jboss.metadata.BeanMetaData;
-import org.jboss.metadata.SessionMetaData;
-import org.jboss.metadata.EntityMetaData;
-import org.jboss.metadata.MessageDrivenMetaData;
-import org.jboss.metadata.ConfigurationMetaData;
-import org.jboss.metadata.XmlLoadable;
-import org.jboss.metadata.XmlFileLoader;
import org.jboss.logging.Logger;
/**
@@ -61,7 +49,7 @@
* @see Container
* @author Andreas Schaefer ([EMAIL PROTECTED])
*
-* @version $Revision: 1.1.2.1 $
+* @version $Revision: 1.1.2.2 $
*/
public class ContainerManagement
extends org.jboss.util.ServiceMBeanSupport
@@ -70,14 +58,16 @@
// Attributes ----------------------------------------------------
// Container this is the management proxy for
Container mContainer = null;
- // The logger of this service
- Log mLog = Log.createLog( getName() );
ObjectName mName = null;
// Constructor ---------------------------------------------------
- public ContainerManagement( Container pContainer ) {
+ public ContainerManagement( Container pContainer )
+ {
setContainer( pContainer );
+ BeanMetaData bmd = pContainer.getBeanMetaData();
+ String name = getClass().getName() + '.' + bmd.getEjbName();
+ log = Logger.getLogger(name);
}
// Public --------------------------------------------------------
1.1.2.1 +164 -124
jboss/src/main/org/jboss/management/Attic/ServerDataCollector.java
Index: ServerDataCollector.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/Attic/ServerDataCollector.java,v
retrieving revision 1.1
retrieving revision 1.1.2.1
diff -u -r1.1 -r1.1.2.1
--- ServerDataCollector.java 2001/06/16 05:48:44 1.1
+++ ServerDataCollector.java 2001/11/20 09:42:54 1.1.2.1
@@ -23,7 +23,7 @@
import javax.naming.Reference;
import javax.naming.StringRefAddr;
-import org.jboss.logging.Log;
+import org.jboss.logging.Logger;
import org.jboss.naming.NonSerializableFactory;
import org.jboss.util.ServiceMBeanSupport;
@@ -35,35 +35,35 @@
* @author Marc Fleury
**/
public class ServerDataCollector
- extends ServiceMBeanSupport
- implements ServerDataCollectorMBean
+extends ServiceMBeanSupport
+implements ServerDataCollectorMBean
{
-
+
// -------------------------------------------------------------------------
// Constants
- // -------------------------------------------------------------------------
-
+ // -------------------------------------------------------------------------
+
public static String JNDI_NAME = "servercollector:domain";
public static String JMX_NAME = "servercollector";
-
+
// -------------------------------------------------------------------------
// Members
- // -------------------------------------------------------------------------
-
+ // -------------------------------------------------------------------------
+
private MBeanServer mServer;
private String mName;
private Boolean mRefresh = new Boolean( true );
private RefreshWorker mWorker;
private int mRefreshSleep = 2000;
-
+
private Map mApplications = new Hashtable();
private Collection mResources = new ArrayList();
private Collection mNodes = new ArrayList();
-
+
// -------------------------------------------------------------------------
// Constructors
- // -------------------------------------------------------------------------
-
+ // -------------------------------------------------------------------------
+
/**
* Default (no-args) Constructor
*
@@ -73,7 +73,7 @@
{
mName = null;
}
-
+
/**
* Constructor with the necessary attributes to be set
*
@@ -83,80 +83,96 @@
{
mName = pName;
}
-
+
// -------------------------------------------------------------------------
// Methods
- // -------------------------------------------------------------------------
-
- public int getRefreshSleep() {
+ // -------------------------------------------------------------------------
+
+ public int getRefreshSleep()
+ {
return mRefreshSleep;
}
- public void setRefreshSleep( int pSleep ) {
- if( pSleep > 0 ) {
+ public void setRefreshSleep( int pSleep )
+ {
+ if( pSleep > 0 )
+ {
mRefreshSleep = pSleep;
}
}
- public void refresh() {
+ public void refresh()
+ {
// Mark it to be refreshed
- synchronized( mRefresh ) {
+ synchronized( mRefresh )
+ {
mRefresh = new Boolean( true );
}
}
-
- public void refreshNow() {
- synchronized( mRefresh ) {
+
+ public void refreshNow()
+ {
+ synchronized( mRefresh )
+ {
mWorker.doRefresh();
mRefresh = new Boolean( false );
}
}
public ObjectName getObjectName(
- MBeanServer server,
- ObjectName name
+ MBeanServer server,
+ ObjectName name
)
- throws MalformedObjectNameException
+ throws MalformedObjectNameException
{
mServer = server;
return new ObjectName( OBJECT_NAME );
}
- public String getJNDIName() {
- if( mName != null ) {
+ public String getJNDIName()
+ {
+ if( mName != null )
+ {
return JMX_NAME + ":" + mName;
}
- else {
+ else
+ {
return JMX_NAME;
}
}
- public String getName() {
+ public String getName()
+ {
return "JBoss Server Data Collector MBean";
}
public J2EEApplication getApplication(
- String pApplicationId
- ) {
+ String pApplicationId
+ )
+ {
// Loop through the applications and find the application
- if( pApplicationId != null ) {
+ if( pApplicationId != null )
+ {
return (J2EEApplication) mApplications.get( pApplicationId );
}
return null;
}
- public Collection getApplications() {
+ public Collection getApplications()
+ {
return new ArrayList( mApplications.values() );
}
-
- public Collection getResources() {
+
+ public Collection getResources()
+ {
return mResources;
}
-
- public Collection getNodes() {
+
+ public Collection getNodes()
+ {
return mNodes;
}
-
+
/* AS Keep it but mostly likely it will removed later
public void removeApplication(
String pApplicationId
@@ -165,7 +181,7 @@
mApplications.remove( pApplicationId );
}
}
-
+
public void saveModule(
String pApplicationId,
int pModuleId,
@@ -177,13 +193,13 @@
lApplication.saveModule( pModuleId, pModule );
}
}
-
+
/**
- * Removes the registered Module if found
- *
- * @param pApplicationId Id of the Application the Module is part of
- * @param pModuleId Id of the Module to be removed
- ** /
+ * Removes the registered Module if found
+ *
+ * @param pApplicationId Id of the Application the Module is part of
+ * @param pModuleId Id of the Module to be removed
+ ** /
public void removeModule(
String pApplicationId,
int pModuleId
@@ -193,160 +209,184 @@
lApplication.removeModule( pModuleId );
}
}
-*/
-
+ */
+
// -------------------------------------------------------------------------
// ServiceMBean - Methods
- // -------------------------------------------------------------------------
-
+ // -------------------------------------------------------------------------
+
protected void initService()
- throws Exception
+ throws Exception
{
-// mJBossServer = new JBossServer( mName );
+ // mJBossServer = new JBossServer( mName );
}
protected void startService()
- throws Exception
+ throws Exception
{
bind( this );
mWorker = new RefreshWorker( log );
mWorker.start();
}
- protected void stopService() {
+ protected void stopService()
+ {
mWorker.stop();
- try {
+ try
+ {
unbind();
}
- catch( Exception e ) {
- log.exception( e );
+ catch( Exception e )
+ {
+ log.error("stop failure", e );
}
}
-
+
// -------------------------------------------------------------------------
// Helper methods to bind/unbind the Management class
// -------------------------------------------------------------------------
-
- private void bind( ServerDataCollector pServer )
- throws
- NamingException
+
+ private void bind( ServerDataCollector pServer )
+ throws NamingException
{
- Context lContext = new InitialContext();
- String lJNDIName = getJNDIName();
-
- // Ah ! JBoss Server isn't serializable, so we use a helper class
- NonSerializableFactory.bind( lJNDIName, pServer );
-
+ Context lContext = new InitialContext();
+ String lJNDIName = getJNDIName();
+
+ // Ah ! JBoss Server isn't serializable, so we use a helper class
+ NonSerializableFactory.bind( lJNDIName, pServer );
+
//AS Don't ask me what I am doing here
- Name lName = lContext.getNameParser("").parse( lJNDIName );
- while( lName.size() > 1 ) {
- String lContextName = lName.get( 0 );
- try {
- lContext = (Context) lContext.lookup(lContextName);
- }
- catch( NameNotFoundException e ) {
- lContext = lContext.createSubcontext(lContextName);
- }
- lName = lName.getSuffix( 1 );
- }
-
- // The helper class NonSerializableFactory uses address type nns, we
go on to
- // use the helper class to bind the javax.mail.Session object in JNDI
- StringRefAddr lAddress = new StringRefAddr( "nns", lJNDIName );
- Reference lReference = new Reference(
- ServerDataCollector.class.getName(),
- lAddress,
- NonSerializableFactory.class.getName(),
- null
+ Name lName = lContext.getNameParser("").parse( lJNDIName );
+ while( lName.size() > 1 )
+ {
+ String lContextName = lName.get( 0 );
+ try
+ {
+ lContext = (Context) lContext.lookup(lContextName);
+ }
+ catch( NameNotFoundException e )
+ {
+ lContext = lContext.createSubcontext(lContextName);
+ }
+ lName = lName.getSuffix( 1 );
+ }
+
+ // The helper class NonSerializableFactory uses address type nns, we go on to
+ // use the helper class to bind the javax.mail.Session object in JNDI
+ StringRefAddr lAddress = new StringRefAddr( "nns", lJNDIName );
+ Reference lReference = new Reference(
+ ServerDataCollector.class.getName(),
+ lAddress,
+ NonSerializableFactory.class.getName(),
+ null
);
- lContext.bind( lName.get( 0 ), lReference );
-
- log.log( "JBoss Management Service '" + getJNDIName() + "' bound to "
+ lJNDIName );
- }
-
- private void unbind() throws NamingException
- {
+ lContext.bind( lName.get( 0 ), lReference );
+
+ log.info( "JBoss Management Service '" + getJNDIName() + "' bound to " +
lJNDIName );
+ }
+
+ private void unbind() throws NamingException
+ {
String lJNDIName = getJNDIName();
-
+
new InitialContext().unbind( lJNDIName );
NonSerializableFactory.unbind( lJNDIName );
- log.log("JBoss Management service '" + lJNDIName + "' removed from JNDI" );
- }
+ log.info("JBoss Management service '" + lJNDIName + "' removed from JNDI" );
+ }
/**
* Worker class to perform the refresh of the data
**/
private class RefreshWorker
- extends Thread
+ extends Thread
{
- private Log mLog;
+ private Logger mLog;
- public RefreshWorker( Log pLog ) {
+ public RefreshWorker(Logger pLog )
+ {
mLog = pLog;
}
- public void run() {
- while( true ) {
- try {
- synchronized( mRefresh ) {
- if( mRefresh.booleanValue() ) {
+ public void run()
+ {
+ while( true )
+ {
+ try
+ {
+ synchronized( mRefresh )
+ {
+ if( mRefresh.booleanValue() )
+ {
doRefresh();
mRefresh = new Boolean( false );
}
}
Thread.sleep( mRefreshSleep );
}
- catch( InterruptedException e ) {
+ catch( InterruptedException e )
+ {
}
}
}
- private void doRefresh() {
- try {
+ private void doRefresh()
+ {
+ try
+ {
mApplications = new Hashtable();
Collection lApplications = new EJBDataCollector().refresh( mServer );
Iterator i = lApplications.iterator();
- while( i.hasNext() ) {
+ while( i.hasNext() )
+ {
J2EEApplication lApplication = (J2EEApplication) i.next();
mApplications.put(
- lApplication.getName(),
- lApplication
+ lApplication.getName(),
+ lApplication
);
}
}
- catch( Exception e ) {
+ catch( Exception e )
+ {
e.printStackTrace();
}
mResources = new ArrayList();
- try {
+ try
+ {
// Get the info about JDBCs
mResources.addAll( new JDBCDataCollector().refresh( mServer ) );
}
- catch( Exception e ) {
+ catch( Exception e )
+ {
e.printStackTrace();
}
- try {
+ try
+ {
// Get the info about Mail
mResources.addAll( new MailDataCollector().refresh( mServer ) );
}
- catch( Exception e ) {
+ catch( Exception e )
+ {
e.printStackTrace();
}
- try {
+ try
+ {
// Get the info about JNDI
mResources.addAll( new JNDIDataCollector().refresh( mServer ) );
}
- catch( Exception e ) {
+ catch( Exception e )
+ {
e.printStackTrace();
}
- try {
+ try
+ {
// Get the info about current nodes
mNodes = new NodeDataCollector().refresh( mServer );
}
- catch( Exception e ) {
+ catch( Exception e )
+ {
e.printStackTrace();
}
}
}
-
+
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development