User: schaefera
Date: 01/11/22 22:20:12
Modified: src/main/org/jboss/management/j2ee IpAddress.java
J2EEApplication.java J2EEApplicationMBean.java
J2EEManagedObject.java J2EEServer.java Node.java
SingleJBossServerManagement.java
Added: src/main/org/jboss/management/j2ee IpAddressMBean.java
Log:
First added the J2EEApplication to JSR-77.
Revision Changes Path
1.4 +2 -4 jboss/src/main/org/jboss/management/j2ee/IpAddress.java
Index: IpAddress.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/IpAddress.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- IpAddress.java 2001/11/21 04:50:53 1.3
+++ IpAddress.java 2001/11/23 06:20:12 1.4
@@ -11,14 +11,12 @@
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
-import javax.management.j2ee.Port;
-
/**
* @author Marc Fleury
**/
public class IpAddress
extends J2EEManagedObject
- implements javax.management.j2ee.IpAddress
+ implements IpAddressMBean
{
// -------------------------------------------------------------------------
// Members
@@ -54,7 +52,7 @@
}
public String toString() {
- return "IpAddress [ " +
+ return "IpAddress { " + super.toString() + " } [ " +
"IpAddress: " + getAddress() +
" ]";
}
1.3 +72 -1 jboss/src/main/org/jboss/management/j2ee/J2EEApplication.java
Index: J2EEApplication.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEApplication.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- J2EEApplication.java 2001/11/20 07:01:39 1.2
+++ J2EEApplication.java 2001/11/23 06:20:12 1.3
@@ -6,12 +6,19 @@
*/
package org.jboss.management.j2ee;
+import java.io.InputStreamReader;
+import java.io.StringWriter;
+import java.net.URL;
import java.security.InvalidParameterException;
import java.util.Arrays;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
import javax.management.MalformedObjectNameException;
+import javax.management.MBeanServer;
import javax.management.ObjectName;
/**
@@ -19,7 +26,7 @@
* JBoss specific implementation.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schafer</a>
-* @version $Revision: 1.2 $
+* @version $Revision: 1.3 $
*/
public class J2EEApplication
extends J2EEDeployedObject
@@ -30,6 +37,54 @@
// -------------------------------------------------------------------------
private List mModules = new ArrayList();
+
+ public static ObjectName create( MBeanServer pServer, String pName, URL pURL ) {
+ String lDD = null;
+ ObjectName lServer = null;
+ try {
+ lServer = (ObjectName) pServer.queryNames(
+ new ObjectName( J2EEManagedObject.getDomainName() +
":type=J2EEServer,*" ),
+ null
+ ).iterator().next();
+ // First get the deployement descriptor
+ System.out.println( "URL: " + pURL.getFile() );
+ JarFile lFile = new JarFile( pURL.getFile() );
+ JarEntry lDDEntry = lFile.getJarEntry( "META-INF/application.xml" );
+ if( lDDEntry != null ) {
+ InputStreamReader lInput = new InputStreamReader( lFile.getInputStream(
lDDEntry ) );
+ StringWriter lOutput = new StringWriter();
+ char[] lBuffer = new char[ 1024 ];
+ int lLength = 0;
+ while( ( lLength = lInput.read( lBuffer ) ) > 0 ) {
+ lOutput.write( lBuffer, 0, lLength );
+ }
+ lDD = lOutput.toString();
+ }
+ }
+ catch( Exception e ) {
+ e.printStackTrace();
+ }
+ try {
+ // Now create the J2EEApplication
+ return pServer.createMBean(
+ "org.jboss.management.j2ee.J2EEApplication",
+ null,
+ new Object[] {
+ pName,
+ lServer,
+ lDD
+ },
+ new String[] {
+ String.class.getName(),
+ ObjectName.class.getName(),
+ String.class.getName()
+ }
+ ).getObjectName();
+ }
+ catch( Exception e ) {
+ return null;
+ }
+ }
// -------------------------------------------------------------------------
// Constructors
@@ -65,6 +120,22 @@
return null;
}
+ public void addChild( ObjectName pChild ) {
+ Hashtable lProperties = pChild.getKeyPropertyList();
+ String lType = lProperties.get( "type" ) + "";
+ if( "EJBModule".equals( lType ) ) {
+ mModules.add( pChild );
+ } else if( "WebModule".equals( lType ) ) {
+ mModules.add( pChild );
+ } else if( "ConnectorModule".equals( lType ) ) {
+ mModules.add( pChild );
+ }
+ }
+
+ public void removeChild( ObjectName pChild ) {
+ //AS ToDo
+ }
+
public String toString() {
return "J2EEApplication { " + super.toString() + " } [ " +
"modules: " + mModules +
1.2 +1 -1
jboss/src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java
Index: J2EEApplicationMBean.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEApplicationMBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- J2EEApplicationMBean.java 2001/11/20 07:01:39 1.1
+++ J2EEApplicationMBean.java 2001/11/23 06:20:12 1.2
@@ -6,6 +6,6 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
**/
public interface J2EEApplicationMBean
- extends J2EEApplication
+ extends J2EEApplication, J2EEManagedObjectMBean
{
}
1.4 +1 -1 jboss/src/main/org/jboss/management/j2ee/J2EEManagedObject.java
Index: J2EEManagedObject.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEManagedObject.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- J2EEManagedObject.java 2001/11/21 04:50:53 1.3
+++ J2EEManagedObject.java 2001/11/23 06:20:12 1.4
@@ -98,7 +98,7 @@
InvalidParentException
{
try {
- Hashtable lProperties = pParent.getKeyPropertyList();
+ Hashtable lProperties = (Hashtable) pParent.getKeyPropertyList().clone();
System.out.println( "J2EEManagedObject(), parent properties: " + lProperties
);
System.out.println( "J2EEManagedObject(), parent type: " + lProperties.get(
"type" ) );
System.out.println( "J2EEManagedObject(), parent name: " + lProperties.get(
"name" ) );
1.3 +1 -1 jboss/src/main/org/jboss/management/j2ee/J2EEServer.java
Index: J2EEServer.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/J2EEServer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- J2EEServer.java 2001/11/21 04:50:53 1.2
+++ J2EEServer.java 2001/11/23 06:20:12 1.3
@@ -122,7 +122,7 @@
public void addChild( ObjectName pChild ) {
Hashtable lProperties = pChild.getKeyPropertyList();
String lType = lProperties.get( "type" ) + "";
- if( "Application".equals( lType ) ) {
+ if( "J2EEApplication".equals( lType ) ) {
mApplications.add( pChild );
} else if( "Node".equals( lType ) ) {
mNodes.add( pChild );
1.4 +20 -26 jboss/src/main/org/jboss/management/j2ee/Node.java
Index: Node.java
===================================================================
RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/Node.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Node.java 2001/11/21 04:50:53 1.3
+++ Node.java 2001/11/23 06:20:12 1.4
@@ -6,6 +6,11 @@
*/
package org.jboss.management.j2ee;
+import java.util.Arrays;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+
import java.security.InvalidParameterException;
import javax.management.MalformedObjectNameException;
@@ -23,7 +28,7 @@
// -------------------------------------------------------------------------
private String mHardwareType;
- private ObjectName[] mIPAddressList;
+ private List mIPAddressList = new ArrayList();
private String mOSType;
// -------------------------------------------------------------------------
@@ -34,23 +39,16 @@
* @param pName Name of the Node
* @param pHardwareType Type of Hardware
* @param pOsType Type of the OS
- * @param pIpAddresses List of IP Addresses
*
* @throws InvalidParameterException If list of IPAddresses or Java VMs is null
or empty
**/
- public Node( String pName, ObjectName pServer, String pHardwareType, String
pOsType, ObjectName[] pIpAddresses )
+ public Node( String pName, ObjectName pServer, String pHardwareType, String
pOsType )
throws
MalformedObjectNameException,
InvalidParentException
{
super( "Node", pName, pServer );
mHardwareType = pHardwareType;
-/*
- if( pIpAddresses == null || pIpAddresses.length == 0 ) {
- throw new InvalidParameterException( "There must always be at least one
IpAddress defined" );
- }
-*/
- mIPAddressList = pIpAddresses;
mOSType = pOsType;
}
@@ -67,42 +65,38 @@
}
public ObjectName[] getIpAddresses() {
- return mIPAddressList;
+ return (ObjectName[]) mIPAddressList.toArray( new ObjectName[ 0 ] );
}
public ObjectName getIpAddress( int pIndex ) {
- if( pIndex >= 0 && pIndex < mIPAddressList.length ) {
- return mIPAddressList[ pIndex ];
+ if( pIndex >= 0 && pIndex < mIPAddressList.size() ) {
+ return (ObjectName) mIPAddressList.get( pIndex );
} else {
return null;
}
}
public void addChild( ObjectName pChild ) {
-/*
Hashtable lProperties = pChild.getKeyPropertyList();
String lType = lProperties.get( "type" ) + "";
- if( "J2EEApplication".equals( lType ) ) {
- m
- mApplications.add( pChild );
- } else if( "J2EEDeployments".equals( lType ) ) {
- mDeployments.add( pChild );
- } else if( "J2EEServer".equals( lType ) ) {
- mServers.add( pChild );
+ if( "IpAddress".equals( lType ) ) {
+ mIPAddressList.add( pChild );
}
-*/
}
public void removeChild( ObjectName pChild ) {
- //AS ToDo
+ Hashtable lProperties = pChild.getKeyPropertyList();
+ String lType = lProperties.get( "type" ) + "";
+ if( "IpAddress".equals( lType ) ) {
+ mIPAddressList.remove( pChild );
+ }
}
public String toString() {
- return "Node [ " +
- "name: " + getName() +
- ", hardware type: " + getHardwareType() +
+ return "Node { " + super.toString() + " } [ " +
+ "hardware type: " + getHardwareType() +
", os type: " + getOsType() +
- ", IP addresses: " + getIpAddresses() +
+ ", IP addresses: " + mIPAddressList +
" ]";
}
}
1.3 +16 -3
jboss/src/main/org/jboss/management/j2ee/SingleJBossServerManagement.java
Index: SingleJBossServerManagement.java
===================================================================
RCS file:
/cvsroot/jboss/jboss/src/main/org/jboss/management/j2ee/SingleJBossServerManagement.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SingleJBossServerManagement.java 2001/11/21 04:50:53 1.2
+++ SingleJBossServerManagement.java 2001/11/23 06:20:12 1.3
@@ -65,15 +65,28 @@
"Localhost",
lServer,
"PC Pentium 4",
- "Windows 2000",
- new ObjectName[ 0 ]
+ "Windows 2000"
},
new String[] {
String.class.getName(),
ObjectName.class.getName(),
String.class.getName(),
+ String.class.getName()
+ }
+ ).getObjectName();
+ // Create its IP-Address
+ ObjectName lIpAddress = getServer().createMBean(
+ "org.jboss.management.j2ee.IpAddress",
+ null,
+ new Object[] {
+ "Localhost",
+ lNode,
+ "127.0.0.1"
+ },
+ new String[] {
String.class.getName(),
- ObjectName[].class.getName()
+ ObjectName.class.getName(),
+ String.class.getName()
}
).getObjectName();
}
1.1 jboss/src/main/org/jboss/management/j2ee/IpAddressMBean.java
Index: IpAddressMBean.java
===================================================================
package org.jboss.management.j2ee;
import javax.management.j2ee.IpAddress;
/**
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Schaefer</a>
**/
public interface IpAddressMBean
extends IpAddress
{
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development