diff --git a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/DynamicInterceptor.java b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/DynamicInterceptor.java
index 6514208258f..f07ef872cc4 100755
--- a/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/DynamicInterceptor.java
+++ b/nucleus/core/kernel/src/main/java/com/sun/enterprise/v3/admin/DynamicInterceptor.java
@@ -40,6 +40,7 @@
package com.sun.enterprise.v3.admin;
import com.sun.enterprise.util.LocalStringManagerImpl;
+
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.*;
@@ -51,39 +52,38 @@
import javax.rmi.ssl.SslRMIClientSocketFactory;
/**
- This Interceptor wraps the real MBeanServer so that additional interceptor code can be
- "turned on" at a later point. However, it must be possible to start the MBeanServer even before
- the JVM calls main(). Therefore,
- This class must not depend on anything that can't initialize before the JVM calls main().
- This includes things like logging which is not happy being invoked
- that early.
-
- When instantiated at startup, the instance of this class that wraps the real MBeanServer
- is termed the "Primary Interceptor". There can only be one such Interceptor for each
- *real* MBeanServer. MBeanServer #0 is the Platform MBeanServer, and this class must be
- used for GlassFish. Additional MBeanServers can be created if desired.
-
- This class can also be used to implement an Interceptor which can be set for use by the Primary
- Interceptor. Such interceptors are used only for get/setAttribute(s) and invoke(), though
- the use of them could be expanded for other methods.
-
- Note that many methods are declared 'final' for efficiency. If a subclass needs
- to override a method, remove 'final'. Until that time, we might as well remain efficient,
- since most methods won't be overridden.
+ * This Interceptor wraps the real MBeanServer so that additional interceptor code can be
+ * "turned on" at a later point. However, it must be possible to start the MBeanServer even before
+ * the JVM calls main(). Therefore,
+ * This class must not depend on anything that can't initialize before the JVM calls main().
+ * This includes things like logging which is not happy being invoked
+ * that early.
+ *
+ * When instantiated at startup, the instance of this class that wraps the real MBeanServer
+ * is termed the "Primary Interceptor". There can only be one such Interceptor for each
+ * real* MBeanServer. MBeanServer #0 is the Platform MBeanServer, and this class must be
+ * used for GlassFish. Additional MBeanServers can be created if desired.
+ *
+ * This class can also be used to implement an Interceptor which can be set for use by the Primary
+ * Interceptor. Such interceptors are used only for get/setAttribute(s) and invoke(), though
+ * the use of them could be expanded for other methods.
+ *
+ * Note that many methods are declared 'final' for efficiency. If a subclass needs
+ * to override a method, remove 'final'. Until that time, we might as well remain efficient,
+ * since most methods won't be overridden.
*/
-public class DynamicInterceptor implements MBeanServer
-{
+public class DynamicInterceptor implements MBeanServer {
private volatile MBeanServer mDelegateMBeanServer;
private static final HashMap instanceConnections =
- new HashMap();;
+ new HashMap();
private static final LocalStringManagerImpl localStrings =
new LocalStringManagerImpl(DynamicInterceptor.class);
private static final String SERVER_PREFIX = "amx:pp=/domain/servers";
private static final String CLUSTER_PREFIX = "amx:pp=/domain/clusters";
private static final String CONFIG_PREFIX = "amx:pp=/domain/configs/config[";
- private static final String JSR77_PREFIX ="amx:pp=/J2EEDomain";
- private static final String MON_PREFIX ="amx:pp=/mon/server-mon[";
+ private static final String JSR77_PREFIX = "amx:pp=/J2EEDomain";
+ private static final String MON_PREFIX = "amx:pp=/mon/server-mon[";
public DynamicInterceptor() {
@@ -93,15 +93,15 @@ public DynamicInterceptor() {
MbeanService.getInstance();
}
- private DynamicInterceptor.ReplicationInfo getTargets( final ObjectName objectName) throws InstanceNotFoundException {
+ private DynamicInterceptor.ReplicationInfo getTargets(final ObjectName objectName) throws InstanceNotFoundException {
//TODO : Check if we already have a target list for this ObjectName
//create a ReplicationInfo instance
DynamicInterceptor.ReplicationInfo result = new DynamicInterceptor.ReplicationInfo();
-
+
// if this is for create Mbean
- if(objectName == null) {
+ if (objectName == null) {
result.addInstance("server");
return result;
}
@@ -109,34 +109,34 @@ private DynamicInterceptor.ReplicationInfo getTargets( final ObjectName objectNa
String oName = objectName.toString();
// Initialize the MBeanService and check if we are on DAS
- if(MbeanService.getInstance() == null) {
+ if (MbeanService.getInstance() == null) {
result.addInstance("server");
return result;
}
// Now lets start analysing the Object Name.
- if(objectName.getKeyProperty("type") != null &&
- (objectName.getKeyProperty("type").equals("Mapper") ||
- objectName.getKeyProperty("type").equals("Connector") ||
- objectName.getKeyProperty("type").equals("Engine") ||
- objectName.getKeyProperty("type").equals("ProtocolHandler") ||
- objectName.getKeyProperty("type").equals("Service") ||
- objectName.getKeyProperty("type").equals("Host") ||
- objectName.getKeyProperty("type").equals("Loader") ||
- objectName.getKeyProperty("type").equals("JspMonitor") ||
- objectName.getKeyProperty("type").equals("Valve"))) {
+ if (objectName.getKeyProperty("type") != null &&
+ (objectName.getKeyProperty("type").equals("Mapper") ||
+ objectName.getKeyProperty("type").equals("Connector") ||
+ objectName.getKeyProperty("type").equals("Engine") ||
+ objectName.getKeyProperty("type").equals("ProtocolHandler") ||
+ objectName.getKeyProperty("type").equals("Service") ||
+ objectName.getKeyProperty("type").equals("Host") ||
+ objectName.getKeyProperty("type").equals("Loader") ||
+ objectName.getKeyProperty("type").equals("JspMonitor") ||
+ objectName.getKeyProperty("type").equals("Valve"))) {
result.addInstance("server");
return result;
}
//If its a MBean corresponding to config
- if(isConfig(oName)) {
+ if (isConfig(oName)) {
String configName = getName(oName);
- if(configName != null && configName.endsWith("-config")) {
+ if (configName != null && configName.endsWith("-config")) {
String targetName = configName.substring(0, configName.indexOf("-config"));
- if( (!"default".equals(targetName)) && (!"server".equals(targetName)) ) {
+ if ((!"default".equals(targetName)) && (!"server".equals(targetName))) {
result.addAllInstances(MbeanService.getInstance().getInstances(configName));
}
} else {
@@ -145,19 +145,19 @@ private DynamicInterceptor.ReplicationInfo getTargets( final ObjectName objectNa
}
// if its a MBean corresponding to a cluster
- if(isCluster(oName)) {
+ if (isCluster(oName)) {
String targetName = getName(oName);
- if(targetName != null) {
+ if (targetName != null) {
result.addAllInstances(MbeanService.getInstance().getInstances(targetName));
}
}
// if its an MBean corresponding to a server
- if(isServer(oName)) {
+ if (isServer(oName)) {
String targetName = getName(oName);
- if(targetName != null) {
+ if (targetName != null) {
result.addInstance(targetName);
- if(!("server".equals(targetName)))
+ if (!("server".equals(targetName)))
result.setTargetIsAnInstance(true);
} else {
result.addInstance("server");
@@ -165,40 +165,40 @@ private DynamicInterceptor.ReplicationInfo getTargets( final ObjectName objectNa
}
// If its an MBean corresponding to a JSR77 managed object
- if(isJSR77(oName, objectName)) {
- if(objectName.getKeyProperty("j2eeType") != null &&
+ if (isJSR77(oName, objectName)) {
+ if (objectName.getKeyProperty("j2eeType") != null &&
objectName.getKeyProperty("j2eeType").equals("J2EEDomain")) {
result.addInstance("server");
} else if (objectName.getKeyProperty("j2eeType") != null &&
objectName.getKeyProperty("j2eeType").equals("J2EEServer")) {
String targetInstance = objectName.getKeyProperty("name");
- if(MbeanService.getInstance().isValidServer(targetInstance)) {
+ if (MbeanService.getInstance().isValidServer(targetInstance)) {
result.addInstance("server");
- result.addInstance(targetInstance);
+ result.addInstance(targetInstance);
}
} else {
String targetInstance = objectName.getKeyProperty("J2EEServer");
- if(MbeanService.getInstance().isValidServer(targetInstance)) {
+ if (MbeanService.getInstance().isValidServer(targetInstance)) {
result.addInstance(targetInstance);
}
}
}
// If its an monitoring MBean
- if(isMonitoring(oName)) {
+ if (isMonitoring(oName)) {
String targetName = getName(oName);
result.addInstance(targetName);
- if(!("server".equals(targetName)))
- result.setTargetIsAnInstance(true);
+ if (!("server".equals(targetName)))
+ result.setTargetIsAnInstance(true);
}
// If its a generic query
- if("amx:*".equals(oName) || "*.*".equals(oName)) {
+ if ("amx:*".equals(oName) || "*.*".equals(oName)) {
result.addInstance("server");
result.addAllInstances(MbeanService.getInstance().getAllInstances());
}
- if (objectName.getKeyProperty("type")!=null) {
+ if (objectName.getKeyProperty("type") != null) {
if (objectName.getKeyProperty("type").equals("domain-root") ||
objectName.getKeyProperty("type").equals("domain") ||
objectName.getKeyProperty("type").equals("resources") ||
@@ -211,16 +211,16 @@ private DynamicInterceptor.ReplicationInfo getTargets( final ObjectName objectNa
}
}
- if( oName.startsWith("amx-support") || oName.startsWith("jmxremote") ) {
+ if (oName.startsWith("amx-support") || oName.startsWith("jmxremote")) {
result.addInstance("server");
}
- if((MbeanService.getInstance().isDas())) {
+ if ((MbeanService.getInstance().isDas())) {
result.addInstance("server");
return result;
- }
+ }
// What abouut JVM
-
+
return result;
}
@@ -231,11 +231,11 @@ private DynamicInterceptor.ReplicationInfo getInstance(final ObjectName o) throw
private MBeanServerConnection getInstanceConnection(String instanceName) throws InstanceNotFoundException {
// first check if this is on the same instance as the one in the argument
// In such a case we delegate to the local MBeanServer
- if(MbeanService.getInstance().isInstance(instanceName)) {
+ if (MbeanService.getInstance().isInstance(instanceName)) {
return getDelegateMBeanServer();
}
// check if this needs a secure connection
- if(MbeanService.getInstance().isSecureJMX(instanceName)) {
+ if (MbeanService.getInstance().isSecureJMX(instanceName)) {
return getSecureInstanceConnection(instanceName);
}
synchronized (instanceConnections) {
@@ -248,8 +248,8 @@ private MBeanServerConnection getInstanceConnection(String instanceName) throws
JMXConnector jmxConn = JMXConnectorFactory.connect(url);
MBeanServerConnection conn = jmxConn.getMBeanServerConnection();
instanceConnections.put(instanceName, conn);
- } catch(Exception ex) {
- throw new InstanceNotFoundException(ex.getLocalizedMessage());
+ } catch (Exception ex) {
+ throw new InstanceNotFoundException(ex.getLocalizedMessage());
}
}
return instanceConnections.get(instanceName);
@@ -261,15 +261,13 @@ private MBeanServerConnection getSecureInstanceConnection(String instanceName) t
synchronized (instanceConnections) {
if (!instanceConnections.containsKey(instanceName)) {
try {
- //
- System.out.println("\nInitialize the environment map");
- final Map env = new HashMap();
- // Provide the SSL/TLS-based RMI Client Socket Factory required
- // by the JNDI/RMI Registry Service Provider to communicate with
- // the SSL/TLS-protected RMI Registry
-
- SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
- env.put("com.sun.jndi.rmi.factory.socket", csf);
+ final Map env = new HashMap();
+ // Provide the SSL/TLS-based RMI Client Socket Factory required
+ // by the JNDI/RMI Registry Service Provider to communicate with
+ // the SSL/TLS-protected RMI Registry
+
+ SslRMIClientSocketFactory csf = new SslRMIClientSocketFactory();
+ env.put("com.sun.jndi.rmi.factory.socket", csf);
String urlStr = "service:jmx:rmi:///jndi/rmi://" +
MbeanService.getInstance().getHost(instanceName) + ":" +
MbeanService.getInstance().getJMXPort(instanceName) + "/jmxrmi";
@@ -277,38 +275,38 @@ private MBeanServerConnection getSecureInstanceConnection(String instanceName) t
JMXConnector jmxConn = JMXConnectorFactory.connect(url, env);
MBeanServerConnection conn = jmxConn.getMBeanServerConnection();
instanceConnections.put(instanceName, conn);
- } catch(Exception ex) {
- throw new InstanceNotFoundException(ex.getLocalizedMessage());
+ } catch (Exception ex) {
+ throw new InstanceNotFoundException(ex.getLocalizedMessage());
}
}
return instanceConnections.get(instanceName);
}
-
+
}
/**
- Get the MBeanServer to which the request can be delegated.
+ * Get the MBeanServer to which the request can be delegated.
*/
public MBeanServer getDelegateMBeanServer() {
return mDelegateMBeanServer;
}
- public void setDelegateMBeanServer(final MBeanServer server) {
- mDelegateMBeanServer = server;
+ public void setDelegateMBeanServer(final MBeanServer server) {
+ mDelegateMBeanServer = server;
}
- public Object invoke( final ObjectName objectName, final String operationName,
- final Object[] params, final String[] signature)
+ public Object invoke(final ObjectName objectName, final String operationName,
+ final Object[] params, final String[] signature)
throws ReflectionException, InstanceNotFoundException, MBeanException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
- DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
+ DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
Object returnValue = null;
try {
- for(String svr : result.getInstances()) {
- if("server".equals(svr)) {
- returnValue = getDelegateMBeanServer().invoke( objectName, operationName, params, signature );
- } else {
+ for (String svr : result.getInstances()) {
+ if ("server".equals(svr)) {
+ returnValue = getDelegateMBeanServer().invoke(objectName, operationName, params, signature);
+ } else {
returnValue = getInstanceConnection(svr).invoke(objectName, operationName, params, signature);
}
}
@@ -317,35 +315,35 @@ public Object invoke( final ObjectName objectName, final String operationName,
}
return returnValue;
}
-
+
public final Object getAttribute(final ObjectName objectName, final String attributeName)
throws InstanceNotFoundException, AttributeNotFoundException, MBeanException, ReflectionException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
- if(!result.isTargetAnInstance())
- return getDelegateMBeanServer().getAttribute( objectName, attributeName);
+ if (!result.isTargetAnInstance())
+ return getDelegateMBeanServer().getAttribute(objectName, attributeName);
try {
return getInstanceConnection(result.getInstances().get(0)).getAttribute(objectName, attributeName);
} catch (IOException ioex) {
throw new ReflectionException(ioex);
}
}
-
+
public void setAttribute(final ObjectName objectName, final Attribute attribute) throws
InstanceNotFoundException, AttributeNotFoundException, MBeanException,
ReflectionException, InvalidAttributeValueException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).setAttribute(objectName, attribute);
return;
}
- for(String svr : result.getInstances()) {
- if("server".equals(svr))
- getDelegateMBeanServer().setAttribute( objectName, attribute );
+ for (String svr : result.getInstances()) {
+ if ("server".equals(svr))
+ getDelegateMBeanServer().setAttribute(objectName, attribute);
else
getInstanceConnection(svr).setAttribute(objectName, attribute);
}
@@ -356,31 +354,31 @@ public void setAttribute(final ObjectName objectName, final Attribute attribute)
public final AttributeList getAttributes(final ObjectName objectName, final String[] attrNames)
throws InstanceNotFoundException, ReflectionException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance())
+ if (result.isTargetAnInstance())
return getInstanceConnection(result.getInstances().get(0)).getAttributes(objectName, attrNames);
else
- return getDelegateMBeanServer().getAttributes( objectName, attrNames );
+ return getDelegateMBeanServer().getAttributes(objectName, attrNames);
} catch (IOException ioex) {
throw new ReflectionException(ioex);
}
}
- public AttributeList setAttributes (final ObjectName objectName, final AttributeList attributeList)
+ public AttributeList setAttributes(final ObjectName objectName, final AttributeList attributeList)
throws InstanceNotFoundException, ReflectionException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
AttributeList ret = null;
try {
- if(result.isTargetAnInstance())
+ if (result.isTargetAnInstance())
return getInstanceConnection(result.getInstances().get(0)).setAttributes(objectName, attributeList);
- for(String svr : result.getInstances()) {
- if((result.getInstances().get(0).equals("server")))
- ret = getDelegateMBeanServer().setAttributes( objectName, attributeList );
+ for (String svr : result.getInstances()) {
+ if ((result.getInstances().get(0).equals("server")))
+ ret = getDelegateMBeanServer().setAttributes(objectName, attributeList);
else
ret = getInstanceConnection(svr).setAttributes(objectName, attributeList);
}
@@ -389,52 +387,52 @@ public AttributeList setAttributes (final ObjectName objectName, final Attribute
}
return ret;
}
-
+
public final ObjectInstance registerMBean(final Object obj, final ObjectName objectName)
throws NotCompliantMBeanException, MBeanRegistrationException, InstanceAlreadyExistsException {
- return getDelegateMBeanServer().registerMBean( obj, objectName );
+ return getDelegateMBeanServer().registerMBean(obj, objectName);
}
public final void unregisterMBean(final ObjectName objectName)
throws InstanceNotFoundException, MBeanRegistrationException {
- // System.out.println("Unregistering MBean :"+objectName.toString());
- if(objectName == null)
+ // System.out.println("Unregistering MBean :"+objectName.toString());
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).unregisterMBean(objectName);
return;
}
- for(String svr : result.getInstances()) {
- if("server".equals(svr))
- getDelegateMBeanServer().unregisterMBean( objectName );
+ for (String svr : result.getInstances()) {
+ if ("server".equals(svr))
+ getDelegateMBeanServer().unregisterMBean(objectName);
else
getInstanceConnection(svr).unregisterMBean(objectName);
}
- } catch(IOException io) {
+ } catch (IOException io) {
throw new MBeanRegistrationException(io);
}
}
public final Integer getMBeanCount() {
- return getDelegateMBeanServer().getMBeanCount( );
+ return getDelegateMBeanServer().getMBeanCount();
}
@Override
- public final Set queryMBeans( final ObjectName objectName, final QueryExp expr ) {
+ public final Set queryMBeans(final ObjectName objectName, final QueryExp expr) {
//if(objectName == null)
- // return Collections.EMPTY_SET;
+ // return Collections.EMPTY_SET;
try {
Set returnVal = null;
List instance = getInstance(objectName).getInstances();
- for(String ins : instance) {
+ for (String ins : instance) {
Set tmp;
- if(ins.equals("server"))
+ if (ins.equals("server"))
tmp = getDelegateMBeanServer().queryMBeans(objectName, expr);
else
tmp = getInstanceConnection(ins).queryMBeans(objectName, expr);
- if(returnVal == null)
+ if (returnVal == null)
returnVal = tmp;
else
returnVal.addAll(tmp);
@@ -445,30 +443,30 @@ public final Set queryMBeans( final ObjectName objectName, final QueryExp expr )
}
}
- public final MBeanInfo getMBeanInfo( final ObjectName objectName)
+ public final MBeanInfo getMBeanInfo(final ObjectName objectName)
throws InstanceNotFoundException, IntrospectionException, ReflectionException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance())
+ if (result.isTargetAnInstance())
return getInstanceConnection(result.getInstances().get(0)).getMBeanInfo(objectName);
else
- return getDelegateMBeanServer().getMBeanInfo( objectName );
+ return getDelegateMBeanServer().getMBeanInfo(objectName);
} catch (IOException ioex) {
throw new ReflectionException(ioex);
}
}
- public final boolean isRegistered( final ObjectName objectName) {
- if(objectName == null)
+ public final boolean isRegistered(final ObjectName objectName) {
+ if (objectName == null)
return false;
try {
List instance = getInstance(objectName).getInstances();
-
- for(String instanceName : instance) {
- if(instanceName.equals(System.getProperty("com.sun.aas.instanceName"))) {
- return getDelegateMBeanServer().isRegistered( objectName );
+
+ for (String instanceName : instance) {
+ if (instanceName.equals(System.getProperty("com.sun.aas.instanceName"))) {
+ return getDelegateMBeanServer().isRegistered(objectName);
} else {
continue;
}
@@ -482,28 +480,28 @@ public final boolean isRegistered( final ObjectName objectName) {
}
}
- public final void addNotificationListener( final ObjectName objectName,
- final NotificationListener notificationListener,
- final NotificationFilter notificationFilter, final Object obj)
+ public final void addNotificationListener(final ObjectName objectName,
+ final NotificationListener notificationListener,
+ final NotificationFilter notificationFilter, final Object obj)
throws InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).addNotificationListener(
objectName, notificationListener, notificationFilter, obj);
return;
}
- for(String svr : result.getInstances()) {
- if("server".equals(svr))
+ for (String svr : result.getInstances()) {
+ if ("server".equals(svr))
getDelegateMBeanServer().addNotificationListener(objectName,
notificationListener, notificationFilter, obj);
else
getInstanceConnection(svr).addNotificationListener(objectName, notificationListener,
- notificationFilter, obj);
+ notificationFilter, obj);
}
- } catch(IOException ioex) {
+ } catch (IOException ioex) {
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
}
}
@@ -511,53 +509,53 @@ public final void addNotificationListener( final ObjectName objectName,
public final void addNotificationListener(final ObjectName objectName, final ObjectName objectName1,
final NotificationFilter notificationFilter, final Object obj)
throws InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).addNotificationListener(
objectName, objectName1, notificationFilter, obj);
return;
}
- for(String svr : result.getInstances()) {
- if("server".equals(svr))
+ for (String svr : result.getInstances()) {
+ if ("server".equals(svr))
getDelegateMBeanServer().addNotificationListener(objectName,
objectName1, notificationFilter, obj);
else
getInstanceConnection(svr).addNotificationListener(objectName, objectName1,
- notificationFilter, obj);
+ notificationFilter, obj);
}
- } catch(IOException ioex) {
+ } catch (IOException ioex) {
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
}
}
- public final ObjectInstance createMBean( final String str, final ObjectName objectName)
+ public final ObjectInstance createMBean(final String str, final ObjectName objectName)
throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException,
- MBeanException, NotCompliantMBeanException {
+ MBeanException, NotCompliantMBeanException {
return createMBean(str, objectName, (Object[]) null, (String[]) null);
}
- public final ObjectInstance createMBean( final String str, final ObjectName objectName,
- final ObjectName objectName2)
+ public final ObjectInstance createMBean(final String str, final ObjectName objectName,
+ final ObjectName objectName2)
throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException,
NotCompliantMBeanException, InstanceNotFoundException {
return createMBean(str, objectName, objectName2, (Object[]) null, (String[]) null);
}
- public final ObjectInstance createMBean( final String str, final ObjectName objectName, final Object[] obj,
- final String[] str3)
+ public final ObjectInstance createMBean(final String str, final ObjectName objectName, final Object[] obj,
+ final String[] str3)
throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException,
MBeanException, NotCompliantMBeanException {
try {
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
ObjectInstance ret = null;
- if(result.isTargetAnInstance())
+ if (result.isTargetAnInstance())
return getInstanceConnection(result.getInstances().get(0)).createMBean(str, objectName, obj, str3);
- for(String svr : result.getInstances())
- if(svr.equals("server"))
- ret = getDelegateMBeanServer().createMBean (str, objectName, obj, str3);
+ for (String svr : result.getInstances())
+ if (svr.equals("server"))
+ ret = getDelegateMBeanServer().createMBean(str, objectName, obj, str3);
else
ret = getInstanceConnection(svr).createMBean(str, objectName, obj, str3);
return ret;
@@ -568,19 +566,19 @@ public final ObjectInstance createMBean( final String str, final ObjectName obje
}
}
- public final ObjectInstance createMBean ( final String str, final ObjectName objectName,
- final ObjectName objectName2, final Object[] obj, final String[] str4)
+ public final ObjectInstance createMBean(final String str, final ObjectName objectName,
+ final ObjectName objectName2, final Object[] obj, final String[] str4)
throws ReflectionException, InstanceAlreadyExistsException, MBeanRegistrationException,
MBeanException, NotCompliantMBeanException, InstanceNotFoundException {
try {
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
ObjectInstance ret = null;
- if(result.isTargetAnInstance())
+ if (result.isTargetAnInstance())
return getInstanceConnection(result.getInstances().get(0)).createMBean(str, objectName,
objectName2, obj, str4);
- for(String svr : result.getInstances())
- if(svr.equals("server"))
- ret = getDelegateMBeanServer().createMBean (str, objectName, objectName2, obj, str4);
+ for (String svr : result.getInstances())
+ if (svr.equals("server"))
+ ret = getDelegateMBeanServer().createMBean(str, objectName, objectName2, obj, str4);
else
ret = getInstanceConnection(svr).createMBean(str, objectName, objectName2, obj, str4);
return ret;
@@ -591,33 +589,33 @@ public final ObjectInstance createMBean ( final String str, final ObjectName obj
}
}
- public final ObjectInputStream deserialize (String str, byte[] values)
+ public final ObjectInputStream deserialize(String str, byte[] values)
throws OperationsException, ReflectionException {
- return getDelegateMBeanServer().deserialize (str, values);
+ return getDelegateMBeanServer().deserialize(str, values);
}
- public final ObjectInputStream deserialize( final ObjectName objectName, final byte[] values)
+ public final ObjectInputStream deserialize(final ObjectName objectName, final byte[] values)
throws InstanceNotFoundException, OperationsException {
- return getDelegateMBeanServer().deserialize (objectName, values);
+ return getDelegateMBeanServer().deserialize(objectName, values);
}
- public final ObjectInputStream deserialize( final String str, final ObjectName objectName, byte[] values)
+ public final ObjectInputStream deserialize(final String str, final ObjectName objectName, byte[] values)
throws InstanceNotFoundException, OperationsException, ReflectionException {
- return getDelegateMBeanServer().deserialize (str, objectName, values);
+ return getDelegateMBeanServer().deserialize(str, objectName, values);
}
public final String getDefaultDomain() {
return getDelegateMBeanServer().getDefaultDomain();
}
-
+
public final ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
List instance = getInstance(objectName).getInstances();
- if(instance.size() != 1)
+ if (instance.size() != 1)
throw new InstanceNotFoundException(localStrings.getLocalString("interceptor.objectName.wrongservernames",
"This mbean call does not support multiple target instances"));
- if((instance.get(0).equals("server")))
+ if ((instance.get(0).equals("server")))
return getDelegateMBeanServer().getObjectInstance(objectName);
try {
return getInstanceConnection(instance.get(0)).getObjectInstance(objectName);
@@ -625,40 +623,40 @@ public final ObjectInstance getObjectInstance(ObjectName objectName) throws Inst
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
}
}
-
- public final Object instantiate( final String str) throws ReflectionException, MBeanException {
+
+ public final Object instantiate(final String str) throws ReflectionException, MBeanException {
return getDelegateMBeanServer().instantiate(str);
}
-
- public final Object instantiate( final String str, final ObjectName objectName)
+
+ public final Object instantiate(final String str, final ObjectName objectName)
throws ReflectionException, MBeanException, InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
return getDelegateMBeanServer().instantiate(str, objectName);
}
-
- public final Object instantiate( final String str, final Object[] obj, final String[] str2)
+
+ public final Object instantiate(final String str, final Object[] obj, final String[] str2)
throws ReflectionException, MBeanException {
return getDelegateMBeanServer().instantiate(str, obj, str2);
}
-
- public final Object instantiate( final String str, final ObjectName objectName, final Object[] obj,
- final String[] str3)
+
+ public final Object instantiate(final String str, final ObjectName objectName, final Object[] obj,
+ final String[] str3)
throws ReflectionException, MBeanException, InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
return getDelegateMBeanServer().instantiate(str, objectName, obj, str3);
}
- public final boolean isInstanceOf ( final ObjectName objectName, final String str)
+ public final boolean isInstanceOf(final ObjectName objectName, final String str)
throws InstanceNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
List instance = getInstance(objectName).getInstances();
- if(instance.size() != 1)
+ if (instance.size() != 1)
throw new InstanceNotFoundException(localStrings.getLocalString("interceptor.objectName.wrongservernames",
"This mbean call does not support multiple target instances"));
- if((instance.get(0).equals("server")))
+ if ((instance.get(0).equals("server")))
return getDelegateMBeanServer().isInstanceOf(objectName, str);
try {
return getInstanceConnection(instance.get(0)).isInstanceOf(objectName, str);
@@ -667,53 +665,53 @@ public final boolean isInstanceOf ( final ObjectName objectName, final String s
}
}
- public final Set queryNames( final ObjectName objectName, final QueryExp queryExp) {
+ public final Set queryNames(final ObjectName objectName, final QueryExp queryExp) {
Set returnVal = null;
//if(objectName == null)
- //return Collections.EMPTY_SET;
+ //return Collections.EMPTY_SET;
List instance;
try {
instance = getInstance(objectName).getInstances();
- } catch(InstanceNotFoundException e) {
+ } catch (InstanceNotFoundException e) {
return Collections.EMPTY_SET;
}
- for(String ins : instance) {
+ for (String ins : instance) {
Set tmp = null;
- if(ins.equals("server")) {
- tmp = getDelegateMBeanServer().queryNames( objectName, queryExp);
+ if (ins.equals("server")) {
+ tmp = getDelegateMBeanServer().queryNames(objectName, queryExp);
} else {
try {
tmp = getInstanceConnection(ins).queryNames(objectName, queryExp);
- } catch(Exception e) {
+ } catch (Exception e) {
//Swallowing this intentionally
//Because this can happen only if the instance is down / not responding
}
}
- if(tmp != null) {
- if(returnVal == null)
+ if (tmp != null) {
+ if (returnVal == null)
returnVal = tmp;
else
returnVal.addAll(tmp);
}
}
- if(returnVal == null)
+ if (returnVal == null)
return Collections.EMPTY_SET;
return returnVal;
}
- public final void removeNotificationListener(final ObjectName objectName, final ObjectName objectName1)
+ public final void removeNotificationListener(final ObjectName objectName, final ObjectName objectName1)
throws InstanceNotFoundException, ListenerNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).removeNotificationListener(objectName, objectName1);
return;
}
- for(String svr : result.getInstances()) {
- if(svr.equals("server"))
- getDelegateMBeanServer().removeNotificationListener( objectName, objectName1);
+ for (String svr : result.getInstances()) {
+ if (svr.equals("server"))
+ getDelegateMBeanServer().removeNotificationListener(objectName, objectName1);
else
getInstanceConnection(svr).removeNotificationListener(objectName, objectName1);
}
@@ -722,20 +720,20 @@ public final void removeNotificationListener(final ObjectName objectName, final
}
}
- public final void removeNotificationListener( final ObjectName objectName,
- final NotificationListener notificationListener)
+ public final void removeNotificationListener(final ObjectName objectName,
+ final NotificationListener notificationListener)
throws InstanceNotFoundException, ListenerNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).removeNotificationListener(objectName, notificationListener);
return;
}
- for(String svr : result.getInstances()) {
- if(svr.equals("server"))
- getDelegateMBeanServer().removeNotificationListener( objectName, notificationListener);
+ for (String svr : result.getInstances()) {
+ if (svr.equals("server"))
+ getDelegateMBeanServer().removeNotificationListener(objectName, notificationListener);
else
getInstanceConnection(svr).removeNotificationListener(objectName, notificationListener);
}
@@ -743,24 +741,24 @@ public final void removeNotificationListener( final ObjectName objectName,
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
}
}
-
- public final void removeNotificationListener( final ObjectName objectName,
- final NotificationListener notificationListener,
- final NotificationFilter notificationFilter, final Object obj)
+
+ public final void removeNotificationListener(final ObjectName objectName,
+ final NotificationListener notificationListener,
+ final NotificationFilter notificationFilter, final Object obj)
throws InstanceNotFoundException, ListenerNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).removeNotificationListener(objectName,
notificationListener, notificationFilter, obj);
return;
}
- for(String svr : result.getInstances()) {
- if(svr.equals("server"))
- getDelegateMBeanServer().removeNotificationListener( objectName,
- notificationListener,notificationFilter, obj);
+ for (String svr : result.getInstances()) {
+ if (svr.equals("server"))
+ getDelegateMBeanServer().removeNotificationListener(objectName,
+ notificationListener, notificationFilter, obj);
else
getInstanceConnection(svr).removeNotificationListener(objectName,
notificationListener, notificationFilter, obj);
@@ -769,47 +767,48 @@ public final void removeNotificationListener( final ObjectName objectName,
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
}
}
-
- public final void removeNotificationListener( final ObjectName objectName, final ObjectName objectName1,
- final NotificationFilter notificationFilter, final Object obj)
+
+ public final void removeNotificationListener(final ObjectName objectName, final ObjectName objectName1,
+ final NotificationFilter notificationFilter, final Object obj)
throws InstanceNotFoundException, ListenerNotFoundException {
- if(objectName == null)
+ if (objectName == null)
throw new InstanceNotFoundException();
DynamicInterceptor.ReplicationInfo result = getInstance(objectName);
try {
- if(result.isTargetAnInstance()) {
+ if (result.isTargetAnInstance()) {
getInstanceConnection(result.getInstances().get(0)).removeNotificationListener(objectName,
objectName1, notificationFilter, obj);
return;
}
- for(String svr : result.getInstances()) {
- if(svr.equals("server"))
- getDelegateMBeanServer().removeNotificationListener( objectName,
- objectName1,notificationFilter, obj);
+ for (String svr : result.getInstances()) {
+ if (svr.equals("server"))
+ getDelegateMBeanServer().removeNotificationListener(objectName,
+ objectName1, notificationFilter, obj);
else
getInstanceConnection(svr).removeNotificationListener(objectName,
objectName1, notificationFilter, obj);
}
} catch (IOException ioex) {
throw new InstanceNotFoundException(ioex.getLocalizedMessage());
- } }
+ }
+ }
- public final ClassLoader getClassLoader( final ObjectName objectName) throws InstanceNotFoundException {
- if(objectName == null)
+ public final ClassLoader getClassLoader(final ObjectName objectName) throws InstanceNotFoundException {
+ if (objectName == null)
throw new InstanceNotFoundException();
- return getDelegateMBeanServer().getClassLoader( objectName );
+ return getDelegateMBeanServer().getClassLoader(objectName);
}
-
- public final ClassLoader getClassLoaderFor( final ObjectName objectName) throws InstanceNotFoundException {
- if(objectName == null)
+
+ public final ClassLoader getClassLoaderFor(final ObjectName objectName) throws InstanceNotFoundException {
+ if (objectName == null)
throw new InstanceNotFoundException();
- return getDelegateMBeanServer().getClassLoaderFor( objectName );
+ return getDelegateMBeanServer().getClassLoaderFor(objectName);
}
-
+
public final ClassLoaderRepository getClassLoaderRepository() {
- return getDelegateMBeanServer().getClassLoaderRepository();
+ return getDelegateMBeanServer().getClassLoaderRepository();
}
-
+
public final String[] getDomains() {
return getDelegateMBeanServer().getDomains();
}
@@ -826,10 +825,10 @@ private boolean isServer(String oName) {
return oName.startsWith(SERVER_PREFIX);
}
- private boolean isJSR77(String oName, ObjectName o) {
- if(o.getKeyProperty("j2eeType") !=null) {
+ private boolean isJSR77(String oName, ObjectName o) {
+ if (o.getKeyProperty("j2eeType") != null) {
return true;
- } else if(oName.startsWith(JSR77_PREFIX)) {
+ } else if (oName.startsWith(JSR77_PREFIX)) {
return true;
} else {
return false;
@@ -841,8 +840,8 @@ private boolean isMonitoring(String oName) {
}
private String getName(String oName) {
- if(oName.indexOf('[') != -1 ) {
- return oName.substring(oName.indexOf('[') + 1, oName.indexOf(']'));
+ if (oName.indexOf('[') != -1) {
+ return oName.substring(oName.indexOf('[') + 1, oName.indexOf(']'));
} else {
return null;
}
@@ -852,14 +851,20 @@ private static class ReplicationInfo {
private boolean instanceTarget = false;
private List instances = new ArrayList();
- boolean isTargetAnInstance() { return instanceTarget;}
+ boolean isTargetAnInstance() {
+ return instanceTarget;
+ }
- void setTargetIsAnInstance(boolean b) { instanceTarget = b;}
+ void setTargetIsAnInstance(boolean b) {
+ instanceTarget = b;
+ }
- List getInstances() { return instances;}
+ List getInstances() {
+ return instances;
+ }
void addInstance(String s) {
- if(!instances.contains(s)) {
+ if (!instances.contains(s)) {
instances.add(s);
}
}