User: mclaugs
Date: 02/04/08 18:02:59
Modified: src/main/org/jboss/management/j2ee EJBModule.java
J2EEManagedObject.java ResourceAdapterModule.java
Log:
modified to current version of the JSR-77 Spec
removed the creation of a J2EEApplication for stand-alone
modules
also removed ^M's from EJBModule
Revision Changes Path
1.6 +180 -166
jboss-management/src/main/org/jboss/management/j2ee/EJBModule.java
Index: EJBModule.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-management/src/main/org/jboss/management/j2ee/EJBModule.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EJBModule.java 19 Mar 2002 01:09:19 -0000 1.5
+++ EJBModule.java 9 Apr 2002 01:02:59 -0000 1.6
@@ -1,169 +1,183 @@
-/*
- * JBoss, the OpenSource J2EE webOS
- *
- * Distributable under LGPL license.
- * See terms of license at gnu.org.
- */
-package org.jboss.management.j2ee;
-
-import java.net.URL;
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import javax.management.AttributeChangeNotification;
-import javax.management.JMException;
-import javax.management.MalformedObjectNameException;
-import javax.management.MBeanServer;
-import javax.management.Notification;
-import javax.management.NotificationListener;
-import javax.management.ObjectName;
-
-import org.jboss.logging.Logger;
-
-/**
- * Root class of the JBoss JSR-77 implementation of
- * {@link javax.management.j2ee.EJBModule EJBModule}.
- *
- * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
- * @version $Revision: 1.5 $
- *
- * <p><b>Revisions:</b>
- *
- * <p><b>20011123 Andreas Schaefer:</b>
- * <ul>
- * <li> Adjustments to the JBoss Guidelines and implementing of the
- * the create() and destroy() helper method
- * </ul>
- *
- * @jmx:mbean
extends="org.jboss.management.j2ee.StateManageable,org.jboss.management.j2ee.J2EEModuleMBean"
- **/
-public class EJBModule
- extends J2EEModule
- implements EJBModuleMBean
-{
-
- // Constants -----------------------------------------------------
-
- public static final String J2EE_TYPE = "EJBModule";
-
- // Attributes ----------------------------------------------------
-
- private List mEJBs = new ArrayList();
- private StateManagement mState;
- private ObjectName mService;
- //used to see if we should remove our parent when we are destroyed.
- private static final Map mCreatedParents = new HashMap();
-
- // Static --------------------------------------------------------
-
- /**
- * @todo AS: Now JVMs managed added now
- **/
- public static ObjectName create( MBeanServer pServer, String pApplicationName,
String pName, URL pURL, ObjectName pService ) {
- Logger lLog = Logger.getLogger( EJBModule.class );
- String lDD = null;
- ObjectName lApplication = null;
- ObjectName lCreated = null;
- try {
- ObjectName serverQuery = new ObjectName(
- J2EEManagedObject.getDomainName() + ":" +
- J2EEManagedObject.TYPE + "=" + J2EEServer.J2EE_TYPE + "," +
- "*"
- );
- Set servers = pServer.queryNames(serverQuery, null);
- if (servers.size() != 1)
- {
- lLog.error("Wrong number of servers found, should be 1: " +
servers.size());
- return null;
- } // end of if ()
-
- ObjectName lServer = (ObjectName)servers.iterator().next();
-
- String lServerName = lServer.getKeyPropertyList().get(
J2EEManagedObject.TYPE ) + "=" +
- lServer.getKeyPropertyList().get( "name" );
-
- lLog.debug( "EJBModule.create(), server name: " + lServerName );
-
- ObjectName parentAppQuery = new ObjectName(
- J2EEManagedObject.getDomainName() + ":" +
- J2EEManagedObject.TYPE + "=" + J2EEApplication.J2EE_TYPE + "," +
- "name=" + pApplicationName + "," +
- lServerName + "," +
- "*"
- );
- Set parentApps = pServer.queryNames(parentAppQuery, null);
-
- if (parentApps.size() == 0)
- {
- lCreated = J2EEApplication.create(
- pServer,
- pApplicationName,
- null
- );
- lApplication = lCreated;
-
- } // end of if ()
- else if (parentApps.size() == 1)
- {
- lApplication = (ObjectName)parentApps.iterator().next();
- } // end of if ()
- else
- {
- lLog.error("more than one parent app for this ejb-module: " +
parentApps.size());
- return null;
- } // end of else
-
- // First get the deployement descriptor
- lDD = J2EEDeployedObject.getDeploymentDescriptor( pURL,
J2EEDeployedObject.EJB );
- }
- catch( Exception e ) {
- lLog.error( "Could not create JSR-77 EJBModule: " + pApplicationName, e );
- return null;
- }
- try {
- // Now create the J2EE EJB module
- lLog.debug(
- "Create EJB-Module, name: " + pName +
- ", application: " + lApplication +
- ", dd: " + lDD
- );
- ObjectName lEJBModule = pServer.createMBean(
- "org.jboss.management.j2ee.EJBModule",
- null,
- new Object[] {
- pName,
- lApplication,
- null, // No JVMs management now
- lDD,
- pService
- },
- new String[] {
- String.class.getName(),
- ObjectName.class.getName(),
- ObjectName[].class.getName(),
- String.class.getName(),
- ObjectName.class.getName()
- }
- ).getObjectName();
- //remember if we created our parent, if we did we have to kill it on
destroy.
- if( lCreated != null ) {
- mCreatedParents.put( lEJBModule, lCreated );
- } // end of if ()
- return lEJBModule;
-
- }
- catch( Exception e ) {
- lLog.error( "Could not create JSR-77 EJBModule: " + pApplicationName, e );
- return null;
- }
- }
-
+/*
+ * JBoss, the OpenSource J2EE webOS
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+package org.jboss.management.j2ee;
+
+import java.net.URL;
+import java.security.InvalidParameterException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.management.AttributeChangeNotification;
+import javax.management.JMException;
+import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServer;
+import javax.management.Notification;
+import javax.management.NotificationListener;
+import javax.management.ObjectName;
+
+import org.jboss.logging.Logger;
+
+/**
+ * Root class of the JBoss JSR-77 implementation of
+ * {@link javax.management.j2ee.EJBModule EJBModule}.
+ *
+ * @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
+ * @version $Revision: 1.6 $
+ *
+ * <p><b>Revisions:</b>
+ *
+ * <p><b>20011123 Andreas Schaefer:</b>
+ * <ul>
+ * <li> Adjustments to the JBoss Guidelines and implementing of the
+ * the create() and destroy() helper method
+ * </ul>
+ *
+ * @jmx:mbean
extends="org.jboss.management.j2ee.StateManageable,org.jboss.management.j2ee.J2EEModuleMBean"
+ **/
+public class EJBModule
+ extends J2EEModule
+ implements EJBModuleMBean
+{
+
+ // Constants -----------------------------------------------------
+
+ public static final String J2EE_TYPE = "EJBModule";
+
+ // Attributes ----------------------------------------------------
+
+ private List mEJBs = new ArrayList();
+ private StateManagement mState;
+ private ObjectName mService;
+ //used to see if we should remove our parent when we are destroyed.
+ private static final Map mCreatedParents = new HashMap();
+
+ // Static --------------------------------------------------------
+
+ /**
+ * @todo AS: Now JVMs managed added now
+ **/
+ public static ObjectName create( MBeanServer pServer, String pApplicationName,
String pName, URL pURL, ObjectName pService ) {
+ Logger lLog = Logger.getLogger( EJBModule.class );
+ String lDD = null;
+ ObjectName lApplication = null;
+ ObjectName lCreated = null;
+ try {
+ ObjectName serverQuery = new ObjectName(
+ J2EEManagedObject.getDomainName() + ":" +
+ J2EEManagedObject.TYPE + "=" + J2EEServer.J2EE_TYPE + "," +
+ "*"
+ );
+ Set servers = pServer.queryNames(serverQuery, null);
+ if (servers.size() != 1)
+ {
+ lLog.error("Wrong number of servers found, should be 1: " +
servers.size());
+ return null;
+ } // end of if ()
+
+ ObjectName lServer = (ObjectName)servers.iterator().next();
+
+ String lServerName = lServer.getKeyPropertyList().get(
J2EEManagedObject.TYPE ) + "=" +
+ lServer.getKeyPropertyList().get( "name" );
+
+ lLog.debug( "EJBModule.create(), server name: " + lServerName );
+
+ // if pName is equal to pApplicationName then we have
+ // a stand alone Module so do not create a J2EEApplication
+
+ if(pName.compareTo(pApplicationName) != 0)
+ {
+
+ ObjectName parentAppQuery = new ObjectName(
+ J2EEManagedObject.getDomainName() + ":" +
+ J2EEManagedObject.TYPE + "=" + J2EEApplication.J2EE_TYPE + "," +
+ "name=" + pApplicationName + "," +
+ lServerName + "," +
+ "*"
+ );
+ Set parentApps = pServer.queryNames(parentAppQuery, null);
+
+ if (parentApps.size() == 0)
+ {
+ lCreated = J2EEApplication.create(
+ pServer,
+ pApplicationName,
+ null
+ );
+ lApplication = lCreated;
+
+ } // end of if ()
+ else if (parentApps.size() == 1)
+ {
+ lApplication = (ObjectName)parentApps.iterator().next();
+ } // end of if ()
+ else
+ {
+ lLog.error("more than one parent app for this ejb-module: " +
parentApps.size());
+ return null;
+ } // end of else
+ }
+ else
+ {
+ Hashtable lProperties = new Hashtable();
+ lProperties.put( J2EEServer.J2EE_TYPE,
lServer.getKeyPropertyList().get( "name" ));
+ lProperties.put( "name" , " " );
+ lApplication = new ObjectName( getDomainName(), lProperties );
+ }
+ // First get the deployement descriptor
+ lDD = J2EEDeployedObject.getDeploymentDescriptor( pURL,
J2EEDeployedObject.EJB );
+ }
+ catch( Exception e ) {
+ lLog.error( "Could not create JSR-77 EJBModule: " + pApplicationName, e );
+ return null;
+ }
+ try {
+ // Now create the J2EE EJB module
+ lLog.debug(
+ "Create EJB-Module, name: " + pName +
+ ", application: " + lApplication +
+ ", dd: " + lDD
+ );
+ ObjectName lEJBModule = pServer.createMBean(
+ "org.jboss.management.j2ee.EJBModule",
+ null,
+ new Object[] {
+ pName,
+ lApplication,
+ null, // No JVMs management now
+ lDD,
+ pService
+ },
+ new String[] {
+ String.class.getName(),
+ ObjectName.class.getName(),
+ ObjectName[].class.getName(),
+ String.class.getName(),
+ ObjectName.class.getName()
+ }
+ ).getObjectName();
+ //remember if we created our parent, if we did we have to kill it on
destroy.
+ if( lCreated != null ) {
+ mCreatedParents.put( lEJBModule, lCreated );
+ } // end of if ()
+ return lEJBModule;
+
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ lLog.error( "Could not create JSR-77 EJBModule: " + pApplicationName, e );
+ return null;
+ }
+ }
+
public static void destroy( MBeanServer pServer, String pModuleName ) {
Logger lLog = Logger.getLogger( EJBModule.class );
try {
1.7 +27 -7
jboss-management/src/main/org/jboss/management/j2ee/J2EEManagedObject.java
Index: J2EEManagedObject.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-management/src/main/org/jboss/management/j2ee/J2EEManagedObject.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- J2EEManagedObject.java 24 Mar 2002 02:25:05 -0000 1.6
+++ J2EEManagedObject.java 9 Apr 2002 01:02:59 -0000 1.7
@@ -25,7 +25,7 @@
* {@link javax.management.j2ee.J2EEManagedObject J2EEManagedObject}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>.
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
*
* <p><b>Revisions:</b>
*
@@ -233,12 +233,32 @@
if( mParent != null ) {
try {
// Notify the parent about its new child
- getServer().invoke(
- mParent,
- "addChild",
- new Object[] { mName },
- new String [] { ObjectName.class.getName() }
- );
+ if(mParent.getKeyProperty( "name" ).compareTo(" ") != 0) {
+ getServer().invoke(
+ mParent,
+ "addChild",
+ new Object[] { mName },
+ new String [] { ObjectName.class.getName() }
+ );
+ }
+ else
+ {
+ ObjectName lServer = (ObjectName) getServer().queryNames(
+ new ObjectName(
+ J2EEManagedObject.getDomainName() + ":" +
+ J2EEManagedObject.TYPE + "=" + J2EEServer.J2EE_TYPE + "," +
+ "name=" + mParent.getKeyProperty( J2EEServer.J2EE_TYPE ) +
"," +
+ "*"
+ ),
+ null
+ ).iterator().next();
+ getServer().invoke(
+ lServer,
+ "addChild",
+ new Object[] { mName },
+ new String [] { ObjectName.class.getName() }
+ );
+ }
super.postRegister( pRegistrationDone );
}
catch( JMException jme ) {
1.5 +50 -32
jboss-management/src/main/org/jboss/management/j2ee/ResourceAdapterModule.java
Index: ResourceAdapterModule.java
===================================================================
RCS file:
/cvsroot/jboss/jboss-management/src/main/org/jboss/management/j2ee/ResourceAdapterModule.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ResourceAdapterModule.java 19 Mar 2002 01:09:19 -0000 1.4
+++ ResourceAdapterModule.java 9 Apr 2002 01:02:59 -0000 1.5
@@ -33,7 +33,7 @@
* {@link javax.management.j2ee.ResourceAdapterModule ResourceAdapterModule}.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Scott McLaughlin</a>.
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*
* <p><b>Revisions:</b>
*
@@ -75,7 +75,7 @@
public static ObjectName create( MBeanServer pServer, String pApplicationName,
String pName, URL pURL, ObjectName pService) {
Logger lLog = Logger.getLogger( ResourceAdapterModule.class );
String lDD = null;
- ObjectName lParent = null;
+ ObjectName lApplication = null;
ObjectName lCreated = null;
try {
ObjectName lServer = (ObjectName) pServer.queryNames(
@@ -89,31 +89,49 @@
String lServerName = lServer.getKeyPropertyList().get(
J2EEManagedObject.TYPE ) + "=" +
lServer.getKeyPropertyList().get( "name" );
lLog.debug( "ResourceAdapterModule.create(), server name: " + lServerName
);
- if( pApplicationName != null )
- {
- lParent = (ObjectName) pServer.queryNames(
- new ObjectName(
- J2EEManagedObject.getDomainName() + ":" +
- J2EEManagedObject.TYPE + "=" + J2EEApplication.J2EE_TYPE + "," +
- "name=" + pApplicationName + "," +
- lServerName + "," +
- "*"
- ),
- null
- ).iterator().next();
- }
- else
+
+ // if pName is equal to pApplicationName then we have
+ // a stand alone Module so do not create a J2EEApplication
+ if( pName.compareTo(pApplicationName) != 0 )
{
- lCreated = J2EEApplication.create(
- pServer,
- pName,
- null
- );
- lParent = lCreated;
- pApplicationName = pName;
- }
- // First get the deployement descriptor
- lDD = J2EEDeployedObject.getDeploymentDescriptor( pURL,
J2EEDeployedObject.RAR );
+ ObjectName parentAppQuery = new ObjectName(
+ J2EEManagedObject.getDomainName() + ":" +
+ J2EEManagedObject.TYPE + "=" + J2EEApplication.J2EE_TYPE + "," +
+ "name=" + pApplicationName + "," +
+ lServerName + "," +
+ "*"
+ );
+ Set parentApps = pServer.queryNames(parentAppQuery, null);
+
+ if (parentApps.size() == 0)
+ {
+ lCreated = J2EEApplication.create(
+ pServer,
+ pApplicationName,
+ null
+ );
+ lApplication = lCreated;
+
+ } // end of if ()
+ else if (parentApps.size() == 1)
+ {
+ lApplication = (ObjectName)parentApps.iterator().next();
+ } // end of if ()
+ else
+ {
+ lLog.error("more than one parent app for this
ResourceAdapterModule: " + parentApps.size());
+ return null;
+ } // end of else
+ }
+ else
+ {
+ Hashtable lProperties = new Hashtable();
+ lProperties.put( J2EEServer.J2EE_TYPE,
lServer.getKeyPropertyList().get( "name" ));
+ lProperties.put( "name" , " " );
+ lApplication = new ObjectName( getDomainName(), lProperties );
+ }
+ // First get the deployement descriptor
+ lDD = J2EEDeployedObject.getDeploymentDescriptor( pURL,
J2EEDeployedObject.RAR );
}
catch( Exception e ) {
@@ -124,7 +142,7 @@
// Now create the ResourceAdapterModule
lLog.debug(
"Create ResourceAdapterModule, name: " + pName +
- ", application: " + lParent +
+ ", application: " + lApplication +
", dd: " + lDD
);
ObjectName lModule = pServer.createMBean(
@@ -132,7 +150,7 @@
null,
new Object[] {
pName,
- lParent,
+ lApplication,
null,
lDD,
pService
@@ -174,11 +192,11 @@
ObjectName lResourceAdapterModule = (ObjectName)
lNames.iterator().next();
// Now remove the ResourceAdapterModule
pServer.unregisterMBean( lResourceAdapterModule );
- ObjectName lParent = (ObjectName) mCreatedParents.get(
lResourceAdapterModule );
- if( lParent != null )
+ ObjectName lApplication = (ObjectName) mCreatedParents.get(
lResourceAdapterModule );
+ if( lApplication != null )
{
- lLog.info( "Remove fake JSR-77 parent Application: " +
lParent.toString() );
- J2EEApplication.destroy( pServer, lParent.toString() );
+ lLog.info( "Remove fake JSR-77 parent Application: " +
lApplication.toString() );
+ J2EEApplication.destroy( pServer, lApplication.toString() );
} // end of if ()
}
Sponsored by http://www.ThinkGeek.com/
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development