Thread: [Mc4j-cvs] SF.net SVN: mc4j:[592] trunk/mc4j/modules/ems
Brought to you by:
ghinkl
From: <gh...@us...> - 2008-09-16 09:33:16
|
Revision: 592 http://mc4j.svn.sourceforge.net/mc4j/?rev=592&view=rev Author: ghinkl Date: 2008-09-16 16:32:53 +0000 (Tue, 16 Sep 2008) Log Message: ----------- EMS fixes for overloaded operations Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/build.xml 2008-09-16 16:32:53 UTC (rev 592) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.2"/> + <property name="release.version" value="1.2.4"/> <target Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2008-09-16 16:32:53 UTC (rev 592) @@ -84,4 +84,6 @@ boolean isNotificationEmiter(); boolean isHasUnsupportedType(); + + EmsOperation getOperation(String operationName, Class... parameterTypes); } Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java 2008-09-16 16:32:53 UTC (rev 592) @@ -6,7 +6,7 @@ * @author Greg Hinkle (gh...@us...) * @version $Revision$($Author$ / $Date$) */ -public interface EmsParameter { +public interface EmsParameter extends Comparable { String getName(); String getDescription(); Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2008-09-16 16:32:53 UTC (rev 592) @@ -22,6 +22,7 @@ import org.mc4j.ems.connection.EmsUnsupportedTypeException; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; +import org.mc4j.ems.connection.bean.parameter.EmsParameter; import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.mc4j.ems.connection.bean.notification.EmsNotification; import org.mc4j.ems.connection.bean.operation.EmsOperation; @@ -41,17 +42,9 @@ import javax.management.MBeanRegistrationException; import javax.management.MBeanServer; import javax.management.ObjectName; -import javax.management.modelmbean.ModelMBeanInfo; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; +import java.util.*; + /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) @@ -74,6 +67,7 @@ private Map<String, EmsAttribute> attributes = new TreeMap<String, EmsAttribute>(String.CASE_INSENSITIVE_ORDER); private Map<String, EmsOperation> operations = new TreeMap<String, EmsOperation>(String.CASE_INSENSITIVE_ORDER); + private Set<EmsOperation> allOperations = new TreeSet<EmsOperation>(); private Map<String, EmsNotification> notifications = new TreeMap<String, EmsNotification>(String.CASE_INSENSITIVE_ORDER); protected List<Throwable> failures; @@ -148,6 +142,7 @@ for (MBeanOperationInfo operationInfo : info.getOperations()) { DOperation operation = new DOperation(operationInfo, this); this.operations.put(operationInfo.getName(), operation); + this.allOperations.add(operation); } for (MBeanNotificationInfo notificationInfo : info.getNotifications()) { @@ -322,9 +317,53 @@ return this.operations.get(name); } + /** + * Retrieves an operation from an mbean which matches the specified name + * and signature. The method is modeled after Class.getMethod() + * The order of parameterTypes must much the order of arguments returned + * for the operation by EMS. + * + * If not matching operation is found on the EmsBean then null is returned + */ + public EmsOperation getOperation(String operationName, Class... parameterTypes) { + getOperations(); + if (allOperations == null || allOperations.isEmpty()) { + return null; + } + + String[] parameterTypeNames = new String[parameterTypes.length]; + for (int i = 0; i < parameterTypes.length; i++) { + // TODO check whether this should be getName,getCanonicalName, + // getSimpleName + // just needs to match what EMS returns + parameterTypeNames[i] = parameterTypes[i].getName(); + } + EmsOperation selectedOperation = null; + for (EmsOperation operation : allOperations) { + List<EmsParameter> operationParameters = operation.getParameters(); + if (parameterTypeNames.length != operationParameters.size()) { + // different number of parameters to what we are looking for + continue; + } + String[] operationParameterTypeNames = new String[operationParameters.size()]; + int i = 0; + for (EmsParameter operationParameter : operationParameters) { + operationParameterTypeNames[i] = operationParameter.getType(); + i++; + } + + if (Arrays.equals(parameterTypeNames, operationParameterTypeNames)) { + selectedOperation = operation; + break; + } + } + return selectedOperation; + } + + public SortedSet<EmsOperation> getOperations() { if (info == null) loadSynchronous(); - return new TreeSet<EmsOperation>(this.operations.values()); + return new TreeSet<EmsOperation>(this.allOperations); } public EmsNotification getNotification(String name) { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2008-09-16 16:32:53 UTC (rev 592) @@ -265,7 +265,7 @@ if (failures.size() > 2) failures.removeFirst(); - log.warn("Attribute access failure " + t.getLocalizedMessage(),t); + log.debug("Attribute access failure " + t.getLocalizedMessage(),t); } public org.mc4j.ems.store.ValueHistory getValueHistory() { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java 2008-09-16 16:32:53 UTC (rev 592) @@ -27,6 +27,8 @@ import javax.management.ReflectionException; import java.util.List; import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 @@ -183,9 +185,40 @@ public int compareTo(Object o) { DOperation otherOperation = (DOperation) o; - return this.getName().compareTo( + int i = this.getName().compareTo( otherOperation.getName()); + if (i == 0) { + + i = ((Integer)parameters.size()).compareTo(otherOperation.getParameters().size()); + if (i == 0) { + for (int j = 0; j < parameters.size();j++) { + i = parameters.get(j).compareTo(otherOperation.getParameters().get(j)); + if (i != 0) { + break; + } + } + } + } + return i; } + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof DOperation)) return false; + + DOperation that = (DOperation) o; + + if (info != null ? !info.getName().equals(that.info.getName()) : that.info.getName() != null) return false; + if (parameters != null ? !parameters.equals(that.parameters) : that.parameters != null) return false; + + return true; + } + + public int hashCode() { + int result; + result = (info != null ? info.hashCode() : 0); + result = 31 * result + (parameters != null ? parameters.hashCode() : 0); + return result; + } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java 2008-09-15 19:15:02 UTC (rev 591) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java 2008-09-16 16:32:53 UTC (rev 592) @@ -26,7 +26,7 @@ * @author Greg Hinkle (gh...@us...) * @version $Revision$($Author$ / $Date$) */ -public class DParameter implements EmsParameter { +public class DParameter implements EmsParameter, Comparable { private String name; private String description; @@ -50,4 +50,33 @@ public String getType() { return type; } + + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof DParameter)) return false; + + DParameter that = (DParameter) o; + + if (name != null ? !name.equals(that.name) : that.name != null) return false; + + if (type != null ? !type.equals(that.type) : that.type != null) return false; + + return true; + } + + public int hashCode() { + int result; + result = (name != null ? name.hashCode() : 0); + result = 31 * result + (description != null ? description.hashCode() : 0); + result = 31 * result + (type != null ? type.hashCode() : 0); + return result; + } + + public int compareTo(Object o) { + int i = this.name.compareTo(((DParameter)o).getName()); + if (i == 0) { + i = this.getType().compareTo(((DParameter)o).getType()); + } + return i; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2008-11-05 16:39:06
|
Revision: 594 http://mc4j.svn.sourceforge.net/mc4j/?rev=594&view=rev Author: ianpspringer Date: 2008-11-05 16:38:56 +0000 (Wed, 05 Nov 2008) Log Message: ----------- reset the JNP credential info prior to each invocation on the MBeanServer proxy for JBoss connections (fix for https://jira.jboss.org/jira/browse/JOPR-9) Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2008-09-22 18:47:51 UTC (rev 593) +++ trunk/mc4j/modules/ems/build.xml 2008-11-05 16:38:56 UTC (rev 594) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.4"/> + <property name="release.version" value="1.2.6"/> <target @@ -96,6 +96,7 @@ <target name="clean" description="Clean"> <delete dir="classes"/> + <delete dir="javadocs"/> </target> <target name="compile" depends="init" description="Compiles the MC4J-EMS codebase."> @@ -127,7 +128,30 @@ </target> - <target name="jars" depends="compile" description="Builds the MC4J Module JAR Files"> + <target name="javadoc" depends="init" description="Generated Javadocs for MC4J-EMS classes."> + <mkdir dir="javadocs/api"/> + <mkdir dir="javadocs/impl"/> + <javadoc packagenames="org.mc4j.ems.*" + excludepackagenames="org.mc4j.ems.connection.support.classloader.*" + sourcepath="src/ems" + destdir="javadocs/api" + author="true" + version="true" + use="true" + windowtitle="EMS API"> + </javadoc> + <javadoc packagenames="org.mc4j.ems.*" + sourcepath="src/ems-impl" + destdir="javadocs/impl" + author="true" + version="true" + use="true" + windowtitle="EMS Impl"> + </javadoc> + </target> + + + <target name="jars" depends="compile, javadoc" description="Builds the MC4J Module JAR Files"> <mkdir dir="dist"/> <mkdir dir="build"/> <delete> @@ -162,6 +186,14 @@ <fileset dir="lib" includes="*.jar"/> </copy> + <!-- sources jars --> + <jar jarfile="dist/org-mc4j-ems-sources.jar" basedir="src/ems"/> + <jar jarfile="dist/org-mc4j-ems-impl-sources.jar" basedir="src/ems-impl"/> + + <!-- javadoc jars --> + <jar jarfile="dist/org-mc4j-ems-javadoc.jar" basedir="javadocs/api"/> + <jar jarfile="dist/org-mc4j-ems-impl-javadoc.jar" basedir="javadocs/impl"/> + </target> Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2008-09-22 18:47:51 UTC (rev 593) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2008-11-05 16:38:56 UTC (rev 594) @@ -113,9 +113,7 @@ log.debug("JNDI Login Context Factory not available, directly utilizing SecurityAssociation"); try { props.put(Context.INITIAL_CONTEXT_FACTORY, connectionSettings.getInitialContextName()); - Class simplePrincipalClass = Class.forName("org.jboss.security.SimplePrincipal"); - Principal p = (Principal) simplePrincipalClass.getConstructor(String.class).newInstance(connectionSettings.getPrincipal()); - SetPrincipalInfoAction.setPrincipalInfo(p,connectionSettings.getCredentials()); + resetPrincipalInfo(); } catch (ClassNotFoundException e1) { throw new ConnectionException("Secured connection not available with this version of JBoss " + e1.toString(),e1); } catch (Exception e1) { @@ -238,4 +236,10 @@ return this.mbeanServer; } + public void resetPrincipalInfo() throws Exception { + Class simplePrincipalClass = Class.forName("org.jboss.security.SimplePrincipal"); + Principal principal = (Principal) simplePrincipalClass.getConstructor(String.class).newInstance( + getConnectionSettings().getPrincipal()); + SetPrincipalInfoAction.setPrincipalInfo(principal, getConnectionSettings().getCredentials()); + } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2008-09-22 18:47:51 UTC (rev 593) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2008-11-05 16:38:56 UTC (rev 594) @@ -22,14 +22,17 @@ import org.mc4j.ems.connection.EmsUnsupportedTypeException; import org.mc4j.ems.connection.LoadException; import org.mc4j.ems.connection.support.ConnectionProvider; +import org.mc4j.ems.impl.jmx.connection.support.providers.JBossConnectionProvider; import javax.management.MBeanServer; +import javax.naming.Context; import java.io.NotSerializableException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.rmi.NoSuchObjectException; +import java.security.Principal; /** @@ -112,6 +115,10 @@ try { roundTrips++; // Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); + if (this.provider instanceof JBossConnectionProvider) { + JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider; + jbossProvider.resetPrincipalInfo(); + } return method.invoke(this.remoteServer, args); } catch(InvocationTargetException e) { failures++; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2009-06-15 20:14:34
|
Revision: 597 http://mc4j.svn.sourceforge.net/mc4j/?rev=597&view=rev Author: ianpspringer Date: 2009-06-15 19:52:30 +0000 (Mon, 15 Jun 2009) Log Message: ----------- fix OOME caused by original fix for https://jira.jboss.org/jira/browse/JOPR-9 Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java Property Changed: ---------------- trunk/mc4j/modules/ems/ Property changes on: trunk/mc4j/modules/ems ___________________________________________________________________ Added: svn:ignore + build classes dist javadocs Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2009-05-26 19:46:13 UTC (rev 596) +++ trunk/mc4j/modules/ems/build.xml 2009-06-15 19:52:30 UTC (rev 597) @@ -6,7 +6,7 @@ Author: Greg Hinkle - Copyright 2002-2005 Greg Hinkle + Copyright 2002-2009 Greg Hinkle Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.6"/> + <property name="release.version" value="1.2.7"/> <target Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2009-05-26 19:46:13 UTC (rev 596) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2009-06-15 19:52:30 UTC (rev 597) @@ -28,6 +28,7 @@ import javax.naming.NoInitialContextException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.lang.reflect.Constructor; import java.security.AccessController; import java.security.Principal; import java.security.PrivilegedAction; @@ -237,9 +238,16 @@ } public void resetPrincipalInfo() throws Exception { + // We need to tell the SecurityAssociation class to clear its internal ThreadLocal stack of authenticated + // subjects. Otherwise, every time we set the princiapl info, this stack will grow and will eventually cause the + // heap to max out. For more on this issue, see https://jira.jboss.org/jira/browse/EJBTHREE-558. + Class securityAssociationClass = Class.forName("org.jboss.security.SecurityAssociation"); + Method clearMethod = securityAssociationClass.getMethod("clear"); + clearMethod.invoke(null); + Class simplePrincipalClass = Class.forName("org.jboss.security.SimplePrincipal"); - Principal principal = (Principal) simplePrincipalClass.getConstructor(String.class).newInstance( - getConnectionSettings().getPrincipal()); + Constructor simplePrincipalConstructor = simplePrincipalClass.getConstructor(String.class); + Principal principal = (Principal) simplePrincipalConstructor.newInstance(getConnectionSettings().getPrincipal()); SetPrincipalInfoAction.setPrincipalInfo(principal, getConnectionSettings().getCredentials()); } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2009-05-26 19:46:13 UTC (rev 596) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2009-06-15 19:52:30 UTC (rev 597) @@ -117,6 +117,8 @@ // Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); if (this.provider instanceof JBossConnectionProvider) { JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider; + // See https://jira.jboss.org/jira/browse/JOPR-9 for an explanation of why we have to re-set the + // PrincipalInfo prior to every JBoss JMX call. jbossProvider.resetPrincipalInfo(); } return method.invoke(this.remoteServer, args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2009-07-10 21:35:31
|
Revision: 599 http://mc4j.svn.sourceforge.net/mc4j/?rev=599&view=rev Author: ianpspringer Date: 2009-07-10 21:35:14 +0000 (Fri, 10 Jul 2009) Log Message: ----------- use JAAS to authenticate rather than JndiLoginInitialContextFactory+SecurityAssociation (part of fix for https://jira.jboss.org/jira/browse/JOPR-263); bump version up to 1.2.8 in preparation for a release Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java Added Paths: ----------- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2009-06-15 19:54:11 UTC (rev 598) +++ trunk/mc4j/modules/ems/build.xml 2009-07-10 21:35:14 UTC (rev 599) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.7"/> + <property name="release.version" value="1.2.8"/> <target Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2009-06-15 19:54:11 UTC (rev 598) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2009-07-10 21:35:14 UTC (rev 599) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2009 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,46 +13,46 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection.support.providers; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.mc4j.ems.connection.ConnectionException; import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.GenericMBeanServerProxy; +import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossCallbackHandler; +import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossConfiguration; import javax.management.MBeanServer; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NoInitialContextException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Constructor; -import java.security.AccessController; -import java.security.Principal; -import java.security.PrivilegedAction; +import javax.security.auth.login.LoginContext; +import javax.security.auth.login.LoginException; +import javax.security.auth.login.Configuration; import java.util.Properties; /** * Represents a Connection to a JBoss JMX Server. This connection - * works against the JBoss RMI connector. + * works against the JBoss RMI connector. If a principal and + * credentials are specified in the connection settings, JAAS is + * used to authenticate prior to each call. * * @author Greg Hinkle (gh...@us...), January 2002 + * @author Ian Springer * @version $Revision$($Author$ / $Date$) */ public class JBossConnectionProvider extends AbstractConnectionProvider { + private static final String NAMING_CONTEXT_FACTORY_CLASS_NAME = "org.jnp.interfaces.NamingContextFactory"; +// private static final String MEJB_JNDI = "ejb/mgmt/MEJB"; private MBeanServer mbeanServer; private GenericMBeanServerProxy proxy; - + private LoginContext loginContext; // private Management mejb; - private static final String MEJB_JNDI = "ejb/mgmt/MEJB"; - private static Log log = LogFactory.getLog(JBossConnectionProvider.class); - protected void doConnect() throws Exception { ClassLoader currentLoader = Thread.currentThread().getContextClassLoader(); @@ -68,8 +68,12 @@ InitialContext context = getInitialContext(); - Object rmiAdaptor = context.lookup(connectionSettings.getJndiName()); + if (getConnectionSettings().getPrincipal() != null) { + initJaasLoginContext(); + } + Object rmiAdaptor = context.lookup(this.connectionSettings.getJndiName()); + // GH: Works around a real strange "LinkageError: Duplicate class found" // by loading these classes in the main connection classloader //Class foo = RMINotificationListener.class; @@ -80,7 +84,7 @@ if (this.proxy != null) { // This is a reconnect - proxy.setRemoteServer(rmiAdaptor); + this.proxy.setRemoteServer(rmiAdaptor); } else { this.proxy = new GenericMBeanServerProxy(rmiAdaptor); this.proxy.setProvider(this); @@ -88,52 +92,28 @@ this.mbeanServer = proxy.buildServerProxy(); } //this.mgmt = retrieveMEJB(); - - // Set the context classloader back to what it was } finally { + // Set the context classloader back to what it was. Thread.currentThread().setContextClassLoader(currentLoader); - } } - public static final String JNDI_LOGIN_CONTEXT_FACTORY_CLASS = "org.jboss.security.jndi.JndiLoginInitialContextFactory"; - private InitialContext getInitialContext() throws NamingException { - Properties props = connectionSettings.getAdvancedProperties(); - - if (connectionSettings.getPrincipal() != null && connectionSettings.getPrincipal().length() != 0) { - try { - Class.forName(JNDI_LOGIN_CONTEXT_FACTORY_CLASS); - log.debug("Utilizing JNDI Login Context Factory for secured access [" + JNDI_LOGIN_CONTEXT_FACTORY_CLASS + "]"); - - props.put(Context.INITIAL_CONTEXT_FACTORY, JNDI_LOGIN_CONTEXT_FACTORY_CLASS); - props.put(Context.SECURITY_PRINCIPAL, connectionSettings.getPrincipal()); - props.put(Context.SECURITY_CREDENTIALS, connectionSettings.getCredentials()); - - } catch (ClassNotFoundException e) { - log.debug("JNDI Login Context Factory not available, directly utilizing SecurityAssociation"); - try { - props.put(Context.INITIAL_CONTEXT_FACTORY, connectionSettings.getInitialContextName()); - resetPrincipalInfo(); - } catch (ClassNotFoundException e1) { - throw new ConnectionException("Secured connection not available with this version of JBoss " + e1.toString(),e1); - } catch (Exception e1) { - throw new ConnectionException("Unable to make secured connection to JBoss due to missing or unexpected security classes",e1); - } - } - - } else { - props.put(Context.INITIAL_CONTEXT_FACTORY, connectionSettings.getInitialContextName()); + Properties props = this.connectionSettings.getAdvancedProperties(); + if (!NAMING_CONTEXT_FACTORY_CLASS_NAME.equals(this.connectionSettings.getInitialContextName())) { + log.warn("Unsupported initial context factory [" + this.connectionSettings.getInitialContextName() + + "] - only " + NAMING_CONTEXT_FACTORY_CLASS_NAME + + " is supported for JBoss connections; using that instead..."); } + props.put(Context.INITIAL_CONTEXT_FACTORY, NAMING_CONTEXT_FACTORY_CLASS_NAME); + props.put(Context.PROVIDER_URL, this.connectionSettings.getServerUrl()); - props.put(Context.PROVIDER_URL, connectionSettings.getServerUrl()); - try { InitialContext context = new InitialContext(props); return context; } catch(NoInitialContextException e) { // Try to be more helpful, indicating the reason we couldn't make the connection in this - // common case of missing libraries + // common case of missing libraries. if (e.getCause() instanceof ClassNotFoundException) { throw new ConnectionException("Necessary classes not found for remote connection, check installation path configuration.",e.getCause()); } @@ -142,49 +122,6 @@ } - private static class SetPrincipalInfoAction implements PrivilegedAction { - Principal principal; - Object credential; - - public SetPrincipalInfoAction(Principal principal, Object credential) { - this.principal = principal; - this.credential = credential; - } - - public Object run() { - try { - Class saClass = Class.forName("org.jboss.security.SecurityAssociation"); - Method setCredentialMethod = saClass.getMethod("setCredential", Object.class); - - setCredentialMethod.invoke(null, credential); - credential = null; - - Method setPrincipleMethod = saClass.getMethod("setPrincipal", Principal.class); - - setPrincipleMethod.invoke(null, principal); - principal = null; - - return null; - } catch (NoSuchMethodException e) { - e.printStackTrace(); - } catch (ClassNotFoundException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - return null; - } - static void setPrincipalInfo(Principal principal, Object credential) { - SetPrincipalInfoAction action = new SetPrincipalInfoAction(principal, credential); - //noinspection unchecked - AccessController.doPrivileged(action); - } - } - - - /* GH: an aborted attempt at manually changing the polling type public class RMIAdaptorExtension extends RMIConnectorImpl { public RMIAdaptorExtension(RMIAdaptor rmiAdaptor) { @@ -237,17 +174,25 @@ return this.mbeanServer; } - public void resetPrincipalInfo() throws Exception { - // We need to tell the SecurityAssociation class to clear its internal ThreadLocal stack of authenticated - // subjects. Otherwise, every time we set the princiapl info, this stack will grow and will eventually cause the - // heap to max out. For more on this issue, see https://jira.jboss.org/jira/browse/EJBTHREE-558. - Class securityAssociationClass = Class.forName("org.jboss.security.SecurityAssociation"); - Method clearMethod = securityAssociationClass.getMethod("clear"); - clearMethod.invoke(null); + public void login() throws LoginException + { + if (this.loginContext != null) { + this.loginContext.login(); + } + } - Class simplePrincipalClass = Class.forName("org.jboss.security.SimplePrincipal"); - Constructor simplePrincipalConstructor = simplePrincipalClass.getConstructor(String.class); - Principal principal = (Principal) simplePrincipalConstructor.newInstance(getConnectionSettings().getPrincipal()); - SetPrincipalInfoAction.setPrincipalInfo(principal, getConnectionSettings().getCredentials()); + public void logout() throws LoginException + { + if (this.loginContext != null) { + this.loginContext.logout(); + } } + + private void initJaasLoginContext() throws LoginException { + Configuration jaasConfig = new JBossConfiguration(); + Configuration.setConfiguration(jaasConfig); + JBossCallbackHandler jaasCallbackHandler = new JBossCallbackHandler( + this.connectionSettings.getPrincipal(), this.connectionSettings.getCredentials()); + this.loginContext = new LoginContext(JBossConfiguration.JBOSS_ENTRY_NAME, jaasCallbackHandler); + } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java 2009-06-15 19:54:11 UTC (rev 598) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java 2009-07-10 21:35:14 UTC (rev 599) @@ -16,7 +16,6 @@ package org.mc4j.ems.impl.jmx.connection.support.providers; -import org.mc4j.ems.connection.EmsException; import org.mc4j.ems.connection.EmsConnectException; import org.mc4j.ems.impl.jmx.connection.support.providers.local.LocalVMConnector; import org.mc4j.ems.connection.local.LocalVirtualMachine; Added: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java (rev 0) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java 2009-07-10 21:35:14 UTC (rev 599) @@ -0,0 +1,52 @@ +/* + * Copyright 2002-2009 Greg Hinkle + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mc4j.ems.impl.jmx.connection.support.providers.jaas; + +import javax.security.auth.callback.*; +import java.io.IOException; + +/** + * @author Ian Springer + */ +public class JBossCallbackHandler implements CallbackHandler { + private String username; + private char[] password; + + public JBossCallbackHandler(String username, String password) + { + this.username = username; + this.password = password.toCharArray(); + } + + public void handle(Callback[] callbacks) throws + IOException, UnsupportedCallbackException + { + for (int i = 0; i < callbacks.length; i++) { + Callback callback = callbacks[i]; + //System.out.println("Handling Callback [" + callback + "]..."); + if (callback instanceof NameCallback) { + + NameCallback nameCallback = (NameCallback) callback; + nameCallback.setName(this.username); + } else if (callback instanceof PasswordCallback) { + PasswordCallback passwordCallback = (PasswordCallback) callback; + passwordCallback.setPassword(this.password); + } else { + throw new UnsupportedCallbackException(callback, "Unrecognized Callback: " + callback); + } + } + } +} Property changes on: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + LF Added: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java (rev 0) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java 2009-07-10 21:35:14 UTC (rev 599) @@ -0,0 +1,58 @@ +/* + * Copyright 2002-2009 Greg Hinkle + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mc4j.ems.impl.jmx.connection.support.providers.jaas; + +import javax.security.auth.login.Configuration; +import javax.security.auth.login.AppConfigurationEntry; +import java.util.HashMap; +import java.util.Map; + +/** + * A JAAS configuration for a JBoss client. This is the programmatic equivalent of the following auth.conf file: + * + * <code> + * jboss + * { + * org.jboss.security.ClientLoginModule required + * multi-threaded=true; + * }; + * </code> + * + * @author Ian Springer + */ +public class JBossConfiguration extends Configuration { + public static final String JBOSS_ENTRY_NAME = "jboss"; + + private static final String JBOSS_LOGIN_MODULE_CLASS_NAME = "org.jboss.security.ClientLoginModule"; + private static final String MULTI_THREADED_OPTION = "multi-threaded"; + + public AppConfigurationEntry[] getAppConfigurationEntry(String name) { + if (JBOSS_ENTRY_NAME.equals(name)) { + Map options = new HashMap(1); + options.put(MULTI_THREADED_OPTION, Boolean.TRUE.toString()); + AppConfigurationEntry appConfigurationEntry = + new AppConfigurationEntry(JBOSS_LOGIN_MODULE_CLASS_NAME, + AppConfigurationEntry.LoginModuleControlFlag.REQUIRED, options); + return new AppConfigurationEntry[] {appConfigurationEntry}; + } else { + throw new IllegalArgumentException("Unknown entry name: " + name); + } + } + + public void refresh() { + return; + } +} Property changes on: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + Date Author Id Revision HeadURL Added: svn:eol-style + LF Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2009-06-15 19:54:11 UTC (rev 598) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java 2009-07-10 21:35:14 UTC (rev 599) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2009 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection.support.providers.proxy; import org.apache.commons.logging.Log; @@ -25,19 +24,17 @@ import org.mc4j.ems.impl.jmx.connection.support.providers.JBossConnectionProvider; import javax.management.MBeanServer; -import javax.naming.Context; import java.io.NotSerializableException; import java.lang.reflect.InvocationHandler; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Proxy; import java.rmi.NoSuchObjectException; -import java.security.Principal; - /** * * @author Greg Hinkle (gh...@us...), January 2002 + * @author Ian Springer * @version $Revision$($Author$ / $Date$) */ public class GenericMBeanServerProxy implements InvocationHandler, StatsProxy { @@ -76,7 +73,6 @@ this.remoteServer = remoteServer; } - public Object invoke( Object proxy, Method m, Object[] args) throws Throwable { @@ -85,12 +81,10 @@ // // ConnectionInfoAction.addHit(); - Class serverClass = this.remoteServer.getClass(); //org.openide.windows.IOProvider.getDefault().getStdOut().println("Looking at object: " + serverClass.getName()); - - // TODO GH: This is horribly inneficient + // TODO GH: This is horribly inefficient Method[] ms = serverClass.getMethods(); Method queryMethod = null; for (int i = 0; i < ms.length; i++) { @@ -99,7 +93,7 @@ if (ms[i].getName().equals("queryMBeans")) queryMethod = ms[i]; } - Method method = null; + Method method; if ("queryMBeans".equals(m.getName())) { method = queryMethod; //method = serverClass.getMethod(m.getName(), new Class[] { ObjectName.class, QueryExp.class }); @@ -115,13 +109,26 @@ try { roundTrips++; // Thread.currentThread().setContextClassLoader(this.getClass().getClassLoader()); - if (this.provider instanceof JBossConnectionProvider) { + boolean isJBossConnection = (this.provider instanceof JBossConnectionProvider); + if (isJBossConnection) { JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider; // See https://jira.jboss.org/jira/browse/JOPR-9 for an explanation of why we have to re-set the // PrincipalInfo prior to every JBoss JMX call. - jbossProvider.resetPrincipalInfo(); + //jbossProvider.resetPrincipalInfo(); + // Login via JAAS before making the call... + jbossProvider.login(); } - return method.invoke(this.remoteServer, args); + Object returnValue; + try { + returnValue = method.invoke(this.remoteServer, args); + } finally { + if (isJBossConnection) { + JBossConnectionProvider jbossProvider = (JBossConnectionProvider) this.provider; + // Logout via JAAS before returning... + jbossProvider.logout(); + } + } + return returnValue; } catch(InvocationTargetException e) { failures++; if (e.getCause() != null) { @@ -164,7 +171,6 @@ } } - public long getRoundTrips() { return roundTrips; } @@ -185,6 +191,4 @@ throw new LoadException("Unable to find JMX Classes", e); } } - - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2009-07-14 20:25:43
|
Revision: 602 http://mc4j.svn.sourceforge.net/mc4j/?rev=602&view=rev Author: ianpspringer Date: 2009-07-14 20:25:40 +0000 (Tue, 14 Jul 2009) Log Message: ----------- add new mc4j.ems.UseContextClassLoader connection option and bump version up to 1.2.9 Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2009-07-10 21:39:37 UTC (rev 601) +++ trunk/mc4j/modules/ems/build.xml 2009-07-14 20:25:40 UTC (rev 602) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.8"/> + <property name="release.version" value="1.2.9"/> <target @@ -168,8 +168,9 @@ <attribute name="Implementation-Version" value="${release.version}"/> <attribute name="Implementation-URL" value="http://mc4j.org/"/> </manifest> - </jar> - + </jar> + <copy file="classes/main/org-mc4j-ems-impl.jar" todir="dist"/> + <jar jarfile="dist/org-mc4j-ems.jar" update="true" compress="false"> <fileset dir="classes/main"/> <fileset dir="${basedir}" includes="lib/*.jar"/> Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2009-07-10 21:39:37 UTC (rev 601) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2009-07-14 20:25:40 UTC (rev 602) @@ -61,6 +61,7 @@ public static final String JAR_TEMP_DIR = "mc4j.ems.JarTempDir"; + public static final String USE_CONTEXT_CLASSLOADER="mc4j.ems.UseContextClassLoader"; private boolean broadSearch = false; private int searchDepth = DEFAULT_SEARCH_DEPTH; Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2009-07-10 21:39:37 UTC (rev 601) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2009-07-14 20:25:40 UTC (rev 602) @@ -175,6 +175,11 @@ public ClassLoader buildClassLoader(ConnectionSettings settings) { + Boolean useContextClassLoader = Boolean.valueOf(settings.getAdvancedProperties().getProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "false")); + if (useContextClassLoader.booleanValue()) { + return Thread.currentThread().getContextClassLoader(); + } + String tempDirString = (String) settings.getControlProperties().get(ConnectionFactory.JAR_TEMP_DIR); File tempDir = null; if (tempDirString != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2009-07-16 23:59:02
|
Revision: 612 http://mc4j.svn.sourceforge.net/mc4j/?rev=612&view=rev Author: ianpspringer Date: 2009-07-16 23:59:00 +0000 (Thu, 16 Jul 2009) Log Message: ----------- we need the ems impl jar added to the classloader even when the useContextClassLoader option is specified Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2009-07-16 22:29:29 UTC (rev 611) +++ trunk/mc4j/modules/ems/build.xml 2009-07-16 23:59:00 UTC (rev 612) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.10"/> + <property name="release.version" value="1.2.11"/> <target Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2009-07-16 22:29:29 UTC (rev 611) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2009-07-16 23:59:00 UTC (rev 612) @@ -175,17 +175,20 @@ public ClassLoader buildClassLoader(ConnectionSettings settings) { - Boolean useContextClassLoader = Boolean.valueOf(settings.getAdvancedProperties().getProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "false")); - if (useContextClassLoader.booleanValue()) { - return Thread.currentThread().getContextClassLoader(); - } - String tempDirString = (String) settings.getControlProperties().get(ConnectionFactory.JAR_TEMP_DIR); File tempDir = null; if (tempDirString != null) { tempDir = new File(tempDirString); } + Boolean useContextClassLoader = Boolean.valueOf(settings.getAdvancedProperties().getProperty(ConnectionFactory.USE_CONTEXT_CLASSLOADER, "false")); + if (useContextClassLoader.booleanValue()) { + ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); + URL implURL = storeImplToTemp("org-mc4j-ems-impl.jar", tempDir); + ClassLoader loader = new URLClassLoader(new URL[] {implURL}, contextClassLoader); + return loader; + } + List<URL> entries = new ArrayList<URL>(); if (settings.getClassPathEntries() != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jma...@us...> - 2010-07-30 21:39:44
|
Revision: 617 http://mc4j.svn.sourceforge.net/mc4j/?rev=617&view=rev Author: jmazzitelli Date: 2010-07-30 21:39:38 +0000 (Fri, 30 Jul 2010) Log Message: ----------- perm gen memory seems to be left un-gc'ed. but cleaning up apache commons LogFactory seems to help alot with reclaiming perm gen memory Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2010-02-05 13:30:54 UTC (rev 616) +++ trunk/mc4j/modules/ems/build.xml 2010-07-30 21:39:38 UTC (rev 617) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.11"/> + <property name="release.version" value="1.2.12"/> <target Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2010-02-05 13:30:54 UTC (rev 616) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2010-07-30 21:39:38 UTC (rev 617) @@ -102,6 +102,7 @@ // tracker.stopTracker(); connectionProvider.disconnect(); + LogFactory.release(connectionProvider.getClass().getClassLoader()); } /* TODO: Check WebLogic <= 8.1 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jma...@us...> - 2010-07-31 15:21:29
|
Revision: 619 http://mc4j.svn.sourceforge.net/mc4j/?rev=619&view=rev Author: jmazzitelli Date: 2010-07-31 15:21:22 +0000 (Sat, 31 Jul 2010) Log Message: ----------- this provides a public API that allows consumers of EMS to ask the ClassLoaderFactory to clear all its caches of jar files, temp files and classloaders. When consumers know they are finished with EMS, they can call this public API to help free up things within perm gen. this fix also nulls out login context within the JBoss connection provider to help the GC. Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2010-07-30 21:53:43 UTC (rev 618) +++ trunk/mc4j/modules/ems/build.xml 2010-07-31 15:21:22 UTC (rev 619) @@ -30,7 +30,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.12"/> + <property name="release.version" value="1.2.13"/> <target Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2010-07-30 21:53:43 UTC (rev 618) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2010-07-31 15:21:22 UTC (rev 619) @@ -79,6 +79,16 @@ } /** + * Clears this factory's caches. You usually only call this when you need + * help cleaning out the classloaders created by this factory. + */ + public static void clearCaches() { + jarCache.clear(); + tempJarCache.clear(); + classLoaderCache.clear(); + } + + /** * TODO GH: Implement a special classloader that can load classes from * within a jar inside another jar or perhaps just ship the impl jar separately... */ Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2010-07-30 21:53:43 UTC (rev 618) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2010-07-31 15:21:22 UTC (rev 619) @@ -141,7 +141,7 @@ public void doDisconnect() { - + this.loginContext = null; } /* public Object getMEJB() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2010-08-02 19:03:12
|
Revision: 620 http://mc4j.svn.sourceforge.net/mc4j/?rev=620&view=rev Author: ianpspringer Date: 2010-08-02 19:03:05 +0000 (Mon, 02 Aug 2010) Log Message: ----------- always compile w/ source and target of 1.5, so generics will be understood when EMS classes are used by a project compiled using JDK 1.7; improve some javadocs; upgrade version to 1.2.14 Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBeanName.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/attribute/EmsAttribute.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotification.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/build.xml 2010-08-02 19:03:05 UTC (rev 620) @@ -2,11 +2,10 @@ <!-- - Author: Greg Hinkle - Copyright 2002-2009 Greg Hinkle + Copyright 2002-2010 Greg Hinkle Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -30,7 +29,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.13"/> + <property name="release.version" value="1.2.14"/> <target @@ -67,11 +66,11 @@ property="installed.netbeans"/> -<!-- + <fail unless="jre15Available" message="JDK 1.5 or later is required to compile EMS."/> <property name="compile.target" value="1.5"/> <property name="compile.source" value="1.5"/> ---> +<!-- <condition property="compile.target" value="jsr14"> <isset property="jre15Available"/> </condition> @@ -89,7 +88,7 @@ <condition property="compile.source" value="1.5"> <isset property="jre15Available"/> </condition> - +--> <echo message="Will compile with target [${compile.target}] and source [${compile.source}]"/> </target> @@ -204,6 +203,31 @@ <target name="dist" depends="jars" description="Build the EMS distribution"/> + <target name="install" depends="jars" description="Deploys the EMS JAR Files to the Local Maven Repo"> + <property name="maven.repo.local" location="${user.home}/.m2/repository"/> + <property name="ems.artifact.dir" location="${maven.repo.local}/mc4j/org-mc4j-ems/${release.version}"/> + <mkdir dir="${ems.artifact.dir}"/> + <property name="ems-impl.artifact.dir" location="${maven.repo.local}/mc4j/org-mc4j-ems-impl/${release.version}"/> + <mkdir dir="${ems-impl.artifact.dir}"/> + + <copy todir="${ems.artifact.dir}"> + <fileset dir="dist"> + <include name="org-mc4j-ems-${release.version}.jar"/> + <include name="org-mc4j-ems-${release.version}-sources.jar"/> + <include name="org-mc4j-ems-${release.version}-javadoc.jar"/> + </fileset> + </copy> + + <copy todir="${ems-impl.artifact.dir}"> + <fileset dir="dist"> + <include name="org-mc4j-ems-impl-${release.version}.jar"/> + <include name="org-mc4j-ems-impl-${release.version}-sources.jar"/> + <include name="org-mc4j-ems-impl-${release.version}-javadoc.jar"/> + </fileset> + </copy> + </target> + + <target name="test-classloader" depends="dist"> <java classname="org.mc4j.ems.connection.support.classloader.NestedJarClassLoader" fork="yes"> <classpath> Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2010-08-02 19:03:05 UTC (rev 620) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2010 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.connection.bean; import org.mc4j.ems.connection.bean.attribute.EmsAttribute; @@ -25,27 +24,54 @@ import java.util.SortedSet; /** + * An MBean. + * * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) */ public interface EmsBean extends Comparable { + /** + * Returns the name of this MBean as an EmsBeanName (analogous to <tt>javax.management.ObjectName</tt>; never null. + * + * @return the name of this MBean as an EmsBeanName (analogous to <tt>javax.management.ObjectName</tt>; never null + */ EmsBeanName getBeanName(); + /** + * Returns the connection provider that was used to load this MBean; never null. + * + * @return the connection provider that was used to load this MBean; never null + */ ConnectionProvider getConnectionProvider(); + /** + * Returns a proxy for this MBean, typed to the specified interface (typically its MBean interface); never null. + * Example Usage: + * <code> + * FooMBean fooMBean = getProxy(FooMBean.class); + * </code> + * + * @param beanInterface the interface class that the proxy should implement + * @param <T> the interface that the proxy should implement + * + * @return a proxy for this MBean, typed to the specified interface (typically its MBean interface); never null + */ <T> T getProxy(Class<T> beanInterface); void loadSynchronous() ; - EmsAttribute getAttribute(String name); - + /** + * Returns the set of all attributes for this MBean; never null. + * + * @return the set of all attributes for this MBean; never null + */ SortedSet<EmsAttribute> getAttributes(); - /** - * Refresh, from the server, all attribute values for an MBean - * @return the List<EmsAttribute> attribute list + * Refresh, from the server, all attribute values for this MBean and return the set of attributes; never null. + * + * @return the list of all attributes, with updated values from the server; never null */ List<EmsAttribute> refreshAttributes(); @@ -54,36 +80,113 @@ * the requested list of attributes by name. * This method can be used to load a group of attributes with a single * server call. Attributes updated in this fashion do update their - * internal representation and do fire events on the changes. - * @param attributeNames the names of attributes to load. - * @return the list of requested attribute objects updated + * internal representation and do fire events on the changes. Never null. + * + * @param names the names of attributes to load + * + * @return the list of requested attributes, with updated values from the server; never null */ - List<EmsAttribute> refreshAttributes(List<String> attributeNames); + List<EmsAttribute> refreshAttributes(List<String> names); + /** + * Returns the attribute with the specified name, or null if this MBean has no such attribute. + * + * @param name the attribute name + * + * @return the attribute with the specified name, or null if this MBean has no such attribute + */ + EmsAttribute getAttribute(String name); + + /** + * The fully qualified class name of this MBean's interface (e.g. "com.example.FooMBean"), as defined in its + * MBeanInfo. + * + * @return the name of this MBean's Java interface (e.g. "com.example.FooMBean"), as defined in its MBeanInfo + */ String getClassTypeName(); + /** + * This MBean's interface class (e.g. com.example.FooMBean), as defined in its MBeanInfo. + * + * @return this MBean's interface class (e.g. com.example.FooMBean), as defined in its MBeanInfo + * + * @throws ClassNotFoundException if the MBean's interface class could not be found in our class loader + */ Class getClassType() throws ClassNotFoundException; + /** + * Returns the set of all operations for this MBean; never null. + * + * @return the set of all operations for this MBean; never null + */ + SortedSet<EmsOperation> getOperations(); + + /** + * Returns an operation with the specified name, or null if this MBean has no such operations. + * <b>NOTE: </b> If the MBean has more than one operation defined with the specified name, the operation that is + * returned is indeterminate, which is why this method has been deprecated in favor of + * {@link #getOperation(String, Class[])}. + * + * @param name the operation name + * + * @return an operation with the specified name, or null if this MBean has no such operations + * + * @deprecated {@link #getOperation(String, Class[])} should be used instead + */ EmsOperation getOperation(String name); - SortedSet<EmsOperation> getOperations(); + /** + * Returns the operation with the specified name and parameter types, or null if this MBean has no such operation. + * + * @param name the operation name + * @param parameterTypes the operation parameter types + * + * @return the operation with the specified name and parameter types, or null if this MBean has no such operation + */ + EmsOperation getOperation(String name, Class... parameterTypes); + /** + * Returns the set of all notifications for this MBean; never null. + * + * @return the set of all notifications for this MBean; never null + */ + SortedSet<EmsNotification> getNotifications(); + + /** + * Returns the notification with the specified name, or null if this MBean has no such notification. + * + * @param name the notification name + * + * @return the notification with the specified name, or null if this MBean has no such notification + */ EmsNotification getNotification(String name); - SortedSet<EmsNotification> getNotifications(); - + /** + * Unregisters this MBean from the server. + */ void unregister(); /** - * This runs an live mbean server request to check that the - * MBean represented by this bean is still registered. + * This sends a request to the server to check that this + * MBean is still registered on the server. + * * @return true if the MBean is still registered in the MBeanServer */ boolean isRegistered(); + /** + * Returns true if this MBean defines one or more notifications, otherwise returns false. + * + * @return true if this MBean defines one or more notifications, otherwise returns false + */ boolean isNotificationEmiter(); + /** + * Returns true if this MBean has one or more attributes or operations with unsupported types, otherwise returns + * false. + * + * @return true if this MBean has one or more attributes or operations with unsupported types, otherwise returns + * false + */ boolean isHasUnsupportedType(); - - EmsOperation getOperation(String operationName, Class... parameterTypes); } Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBeanName.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBeanName.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBeanName.java 2010-08-02 19:03:05 UTC (rev 620) @@ -3,22 +3,57 @@ import java.util.Map; /** - * Created by IntelliJ IDEA. - * User: ghinkle - * Date: Oct 25, 2005 - * Time: 1:13:12 AM - * To change this template use File | Settings | File Templates. + * An MBean name. */ public interface EmsBeanName extends Comparable { - - + /** + * Returns the domain of this name. + * + * @return the domain of this name + */ String getDomain(); + /** + * Returns the canonical form of the name as defined by {@link ObjectName#getCanonicalName()}. + * + * @return the canonical form of the name as defined by {@link ObjectName#getCanonicalName()} + */ String getCanonicalName(); - Map<String,String> getKeyProperties(); + /** + * Returns a Map of this name's key properties. The keys of the Map are the key property names, and the values are + * the values of the corresponding key properties. + * + * @return a Map of this name's key properties + */ + Map<String, String> getKeyProperties(); + /** + * Returns the value for the key property with the specified name. + * + * @param name the key property name + * + * @return the value of the key property, or null if there is no such + * key property in this DBeanName. + * + * @throws NullPointerException If <code>name</code> is null + */ String getKeyProperty(String key); - boolean apply(String objectName); + /** + * Tests whether this name, which may be a pattern, + * matches another MBean name. If <code>name</code> is a pattern, + * the result is false. If this EmsBeanName is a pattern, the + * result is true if and only if <code>name</code> matches the + * pattern. If neither this EmsBeanName nor <code>name</code> is + * a pattern, the result is true if and only if the two + * EmsBeanNames have canonical String forms that are equal. + * + * @param name the MBean name to compare to + * + * @return true if <code>name</code> matches this EmsBeanName + * + * @throws NullPointerException if <code>name</code> is null + */ + boolean apply(String name); } Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/attribute/EmsAttribute.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/attribute/EmsAttribute.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/attribute/EmsAttribute.java 2010-08-02 19:03:05 UTC (rev 620) @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.connection.bean.attribute; import org.mc4j.ems.store.ValueHistory; /** + * An MBean attribute. + * * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) */ @@ -32,47 +33,97 @@ void registerAttributeChangeListener(AttributeChangeListener listener); + + /** + * Returns the locally stored value of this attribute. Does not ask the server for the current value. + * + * @return the locally stored value of this attribute + */ Object getValue(); /** - * Set the attribute on the server - * @param newValue The value to be set - * @throws Exception + * Set the attribute's value on the server. + * + * @param newValue the value to be set + * + * @throws Exception if there was a failure to set the attribute */ void setValue(Object newValue) throws Exception; + /** * Alters the internally stored value of this attribute. Does not update the - * server value. Is intended for mass load of attribute data via the MBean. - * @param newValue + * server value. Is intended for mass updates of attribute data via the MBean. + * + * @param newValue the value to be set */ void alterValue(Object newValue); - /** - * Updates the local value of this mbean from the server + * Updates the local value of this attribute from the server. */ Object refresh(); + /** + * + * @return + */ ValueHistory getValueHistory(); + /** + * + * @return + */ String getName(); + + /** + * + * @return + */ String getType(); + /** + * + * @return + */ Class getTypeClass(); + /** + * + * @return + */ boolean isNumericType(); String getDescription() ; + /** + * Returns true if this attribute is readable, or false if it is not. + * + * @return true if this attribute is readable, or false if it is not + */ + boolean isReadable(); - boolean isReadable(); + /** + * Returns true if this attribute is writable, or false if it is not. + * + * @return true if this attribute is writable, or false if it is not + */ boolean isWritable(); - + /** + * + * @return + */ boolean isSupportedType(); + /** + * + * @param supportedType + */ void setSupportedType(boolean supportedType); - + /** + * + * @return + */ int getValueSize(); } Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotification.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotification.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotification.java 2010-08-02 19:03:05 UTC (rev 620) @@ -19,19 +19,19 @@ import java.util.List; /** + * An MBean notification. + * * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) */ public interface EmsNotification extends Comparable { - String getName(); String getDescription(); String[] getTypes(); - void addNotificationListener(EmsNotificationListener listener); boolean removeNotificationListener(EmsNotificationListener listener); Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java 2010-08-02 19:03:05 UTC (rev 620) @@ -26,6 +26,8 @@ import java.io.ObjectStreamException; /** + * An MBean operation. + * * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) */ Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/parameter/EmsParameter.java 2010-08-02 19:03:05 UTC (rev 620) @@ -1,15 +1,30 @@ package org.mc4j.ems.connection.bean.parameter; /** - * Created: Jul 20, 2005 1:16:45 AM + * An MBean operation parameter. * * @author Greg Hinkle (gh...@us...) * @version $Revision$($Author$ / $Date$) */ public interface EmsParameter extends Comparable { + /** + * Returns the name of this parameter. + * + * @return the name of this parameter + */ String getName(); + /** + * Returns a human readable description of this parameter; may be null. + * + * @return a human readable description of this parameter; may be null + */ String getDescription(); + /** + * Returns the type (i.e. fully qualified class name as defined by {@link Class#getName()}) of this parameter. + * + * @return the type (i.e. fully qualified class name as defined by {@link Class#getName()}) of this parameter + */ String getType(); } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2010-08-02 19:03:05 UTC (rev 620) @@ -254,6 +254,7 @@ } catch (Exception e) { throw new EmsException("Could not create MBean", e); } + // TODO: Shouldn't we add the MBean to our map too? } public void removeMBean(String objectName) throws EmsException { @@ -265,6 +266,7 @@ } catch (Exception e) { throw new EmsException("Could not remove MBean", e); } + // TODO: Shouldn't we remove the MBean from our map too? } public synchronized SortedSet<EmsBean> getBeans() { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java 2010-08-02 19:03:05 UTC (rev 620) @@ -26,7 +26,6 @@ return objectName; } - public String getDomain() { return objectName.getDomain(); } @@ -41,10 +40,11 @@ return (Map<String, String>) objectName.getKeyPropertyList(); } - public String getKeyProperty(String key) { - return objectName.getKeyProperty(key); + public String getKeyProperty(String name) { + return objectName.getKeyProperty(name); } + public boolean apply(String objectNameFilterString) { try { return this.objectName.apply(new ObjectName(objectNameFilterString)); @@ -54,8 +54,9 @@ } /** - * Output the generalized objectname string in input format - * @return + * <p>Returns a string representation of this name.</p> + * + * @return a string representation of this name */ public String toString() { return this.objectName.toString(); @@ -67,7 +68,6 @@ return toString().compareTo(((EmsBeanName) o).toString()); } - public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2010-08-02 19:03:05 UTC (rev 620) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2010 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection.bean; import org.apache.commons.logging.Log; @@ -44,7 +43,6 @@ import javax.management.ObjectName; import java.util.*; - /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) @@ -388,6 +386,8 @@ } catch (InstanceNotFoundException e) { throw new EmsBeanNotFoundException("Could not unregister bean, instance not found [" + getObjectName().getCanonicalName() + "]", e); } + // TODO: Shouldn't we remove the MBean from our map too? + //connectionProvider.getExistingConnection().removeMBean(getObjectName().toString()); } protected MBeanInfo getMBeanInfo() { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2010-07-31 15:21:22 UTC (rev 619) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2010-08-02 19:03:05 UTC (rev 620) @@ -51,6 +51,8 @@ /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) + * + * TODO: Implement Comparable. */ public class DAttribute implements EmsAttribute { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2010-08-17 22:41:11
|
Revision: 622 http://mc4j.svn.sourceforge.net/mc4j/?rev=622&view=rev Author: ianpspringer Date: 2010-08-17 22:41:04 +0000 (Tue, 17 Aug 2010) Log Message: ----------- wrap a couple calls in doPrivileged blocks so EMS will work when Java security is enabled, as long as the callers have the appropriate permissions; bump up EMS version to 1.2.15 Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/ems.iml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WeblogicConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WebsphereConnectionProvider.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/build.xml 2010-08-17 22:41:04 UTC (rev 622) @@ -29,12 +29,10 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.14"/> + <property name="release.version" value="1.2.15"/> - <target - name="init" - description="Initializes the mc4j-ems build system."> + <target name="init" description="Initializes the MC4J-EMS build system."> <echo message="MC4J-EMS Build Environment - Try [ant -projecthelp] for more info."/> @@ -236,18 +234,20 @@ </java> </target> + <target name="test-OTHER"> <java classname="org.mc4j.ems.test.ConnectionTest" fork="yes"> <classpath> <pathelement location="dist/org-mc4j-ems.jar"/> <pathelement location="lib/commons-logging.jar"/> <pathelement location="classes/test"/> - <pathelement location="C:\projects\jboss\JON_DEV_1_4\hyperic_hq\thirdparty\lib\log4j.jard"/> + <pathelement location="C:\projects\jboss\JON_DEV_1_4\hyperic_hq\thirdparty\lib\log4j.jar"/> <!--<path location="/Users/ghinkle/development/tools/jboss-4.0.2/server/default/lib/jboss-jsr77.jar"/>--> </classpath> </java> </target> + <target name="run" description="Directly starts MC4J with the settings as the installer would use."> <echo>Starting MC4J-EMS Test</echo> <java @@ -282,8 +282,8 @@ </java> </target> - <target name="all-test" depends="compile, jars, run" description="Compile and run the tests."> - </target> + <target name="all-test" depends="compile, jars, run" description="Compile and run the tests."/> </project> + Modified: trunk/mc4j/modules/ems/ems.iml =================================================================== --- trunk/mc4j/modules/ems/ems.iml 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/ems.iml 2010-08-17 22:41:04 UTC (rev 622) @@ -36,7 +36,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../../../../opt/jdk-1.6.0_07/lib/tools.jar!/" /> + <root url="jar://$USER_HOME$/opt/jdk-1.6.0_07/lib/tools.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> @@ -45,7 +45,7 @@ <orderEntry type="module-library"> <library> <CLASSES> - <root url="jar://$MODULE_DIR$/../../../../opt/jdk-1.6.0_14/lib/tools.jar!/" /> + <root url="jar://$USER_HOME$/opt/jdk-1.6.0_14/lib/tools.jar!/" /> </CLASSES> <JAVADOC /> <SOURCES /> Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2010-08-17 22:41:04 UTC (rev 622) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2010 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,12 +13,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.connection; import java.io.File; import java.io.FileFilter; import java.io.FilenameFilter; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -111,34 +112,35 @@ * @param connectionSettings the connection settings for the connection * @return a ConnectionProvider that you can get live connection from. */ - public ConnectionProvider getConnectionProvider(ConnectionSettings connectionSettings) + public ConnectionProvider getConnectionProvider(final ConnectionSettings connectionSettings) { String className = connectionSettings.getConnectionType().getConnectionNodeClassName(); try { - // TODO GH: Does this need to be configurable per connection? - ClassLoader loader = ClassLoaderFactory.getInstance().buildClassLoader(connectionSettings); + ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { + return ClassLoaderFactory.getInstance().buildClassLoader(connectionSettings); + } + }); - log.debug("Loading connection class from ClassLoader [" + loader + "] ConnectionProvider class [" + className + "]"); + log.debug("Loading connection class [" + className + "] from ClassLoader [" + loader + "]..."); // TODO GH: Add intelligent classloader layer here that can either work // directly against current classloader or build a non-delegating child // to override with connection specific classes Class clazz = Class.forName(className, false, loader); + ConnectionProvider connectionProvider = (ConnectionProvider) clazz.newInstance(); - ConnectionProvider connectionProvider = - (ConnectionProvider) clazz.newInstance(); - connectionProvider.initialize(connectionSettings); return connectionProvider; } catch (IllegalAccessException e) { - throw new ConnectionException("Could not access ConnectionClass", e); + throw new ConnectionException("Could not access ConnectionClass " + className, e); } catch (InstantiationException e) { - throw new ConnectionException("Could not instantiate ConnectionClass", e); + throw new ConnectionException("Could not instantiate ConnectionClass " + className, e); } catch (ClassNotFoundException e) { throw new ConnectionException("Could not find ConnectionClass " + className, e); } @@ -152,7 +154,7 @@ */ public EmsConnection connect(ConnectionSettings connectionSettings) { - log.info("Connecting to " + connectionSettings.toString()); + log.info("Connecting to " + connectionSettings + "..."); return getConnectionProvider(connectionSettings).connect(); } @@ -167,7 +169,7 @@ * first clear the settings' classpath entries. This method appends class path entries * to the existing list. * - * @param connectionSettings the ConnectionSettings to update with recommeneded class + * @param connectionSettings the ConnectionSettings to update with recommended class * path entries */ public void discoverServerClasses(ConnectionSettings connectionSettings) { @@ -316,7 +318,7 @@ if (children.length == 1) { return children[0]; } else { - //log.info("Connection library dependancy [" + childName + "] not found in directory: " + directory.getAbsolutePath()); + //log.info("Connection library dependency [" + childName + "] not found in directory: " + directory.getAbsolutePath()); return null; } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java 2010-08-17 22:41:04 UTC (rev 622) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2010 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection.support.providers; import org.mc4j.ems.connection.EmsConnection; @@ -92,15 +91,15 @@ } - public final EmsConnection connect() { try { - doConnect(); + doConnect(); + this.connected = true; this.connectionFailure = false; } catch (Exception e) { - throw new EmsConnectException("Could not connect [" + connectionSettings.getServerUrl() + "] " + e.toString(), e); + throw new EmsConnectException("Could not connect [" + connectionSettings.getServerUrl() + "] " + e, e); } if (existingConnection == null) { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java 2010-08-17 22:41:04 UTC (rev 622) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2007 Greg Hinkle + * Copyright 2002-2010 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection.support.providers; import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; @@ -21,6 +20,9 @@ import javax.management.MBeanServer; import javax.management.MBeanServerFactory; import java.lang.management.ManagementFactory; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.ArrayList; /** * Connect to the platform mbean server in the VM that EMS is running in. @@ -45,12 +47,20 @@ MBeanServer foundServer = null; if (mbeanSearch != null) { - for (Object mbs : MBeanServerFactory.findMBeanServer(null)) + ArrayList mbeanServers = AccessController.doPrivileged(new PrivilegedAction<ArrayList>() { - if (mbeanSearch.equals(((MBeanServer)mbs).getDefaultDomain())) + public ArrayList run() { - foundServer = (MBeanServer) mbs; + return MBeanServerFactory.findMBeanServer(null); } + }); + for (Object mbeanServerObj : mbeanServers) + { + MBeanServer mbeanServer = (MBeanServer) mbeanServerObj; + if (mbeanSearch.equals(mbeanServer.getDefaultDomain())) + { + foundServer = mbeanServer; + } } } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java 2010-08-17 22:41:04 UTC (rev 622) @@ -16,7 +16,6 @@ package org.mc4j.ems.impl.jmx.connection.support.providers; - import org.mc4j.ems.connection.EmsConnectException; import org.mc4j.ems.connection.EmsException; import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.JMXRemotingMBeanServerProxy; @@ -47,7 +46,6 @@ import java.util.Map; import java.util.Set; - /** * Represents a Connection to a JSR 160 compliant RMI server * Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WeblogicConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WeblogicConnectionProvider.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WeblogicConnectionProvider.java 2010-08-17 22:41:04 UTC (rev 622) @@ -16,7 +16,6 @@ package org.mc4j.ems.impl.jmx.connection.support.providers; - import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.GenericMBeanServerProxy; import javax.management.MBeanServer; @@ -25,7 +24,6 @@ import java.lang.reflect.Method; import java.util.Hashtable; - /** * This Node acts as a connection to a WebLogic(tm) MBean Server. * Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WebsphereConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WebsphereConnectionProvider.java 2010-08-02 19:04:59 UTC (rev 621) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WebsphereConnectionProvider.java 2010-08-17 22:41:04 UTC (rev 622) @@ -27,7 +27,6 @@ import java.net.URI; import java.util.Properties; - /** * This Node acts as a connection to a WebSphere(tm) MBean Server (TMX4J based). * @@ -209,5 +208,4 @@ return statsProxy.getFailures(); } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ian...@us...> - 2011-10-28 21:44:35
|
Revision: 629 http://mc4j.svn.sourceforge.net/mc4j/?rev=629&view=rev Author: ianpspringer Date: 2011-10-28 21:44:26 +0000 (Fri, 28 Oct 2011) Log Message: ----------- fix so cached defunct MBeanInfos are nulled out after connection is re-established to a restarted MBeanServer; bump up version to 1.3 Modified Paths: -------------- trunk/mc4j/modules/ems/build.xml trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/access/Lookup.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/EmsConnection.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/LoadException.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationEvent.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationListener.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotificationEvent.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVMFinder.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVirtualMachine.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/ConnectionSettings.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingPersistence.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingsStore.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoader.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoaderOrig.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/NestedJarClassLoader.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/deepjar/Handler.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/AbstractConnectionTypeDescriptor.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/JBossConnectionTypeDescriptor.java trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/store/CompleteValueHistory.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/PooledConnectionTracker.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DAdvancedBean.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/notification/DNotification.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/Oc4jConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/PramatiConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WeblogicConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/WebsphereConnectionProvider.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossCallbackHandler.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/jaas/JBossConfiguration.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/local/LocalVMConnector.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/GenericMBeanServerProxy.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/JMXRemotingMBeanServerProxy.java trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/proxy/JSR77ManagementMBeanServerProxy.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/ConnectionTest.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/LoaderTest.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/MultiConnectionTest.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/beans/BeanTest.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/beans/MyTestBean.java trunk/mc4j/modules/ems/src/test/org/mc4j/ems/test/notifications/NotificationTest.java Modified: trunk/mc4j/modules/ems/build.xml =================================================================== --- trunk/mc4j/modules/ems/build.xml 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/build.xml 2011-10-28 21:44:26 UTC (rev 629) @@ -29,7 +29,7 @@ <property name="module.jar" value="org-mc4j-ems.jar"/> - <property name="release.version" value="1.2.16"/> + <property name="release.version" value="1.3"/> <target name="init" description="Initializes the MC4J-EMS build system."> Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/access/Lookup.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/access/Lookup.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/access/Lookup.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,12 +16,12 @@ package org.mc4j.ems.access; +import java.util.HashMap; +import java.util.Map; + import ognl.Ognl; import ognl.OgnlException; -import java.util.Map; -import java.util.HashMap; - /** * @author Greg Hinkle (gh...@us...), Apr 12, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/ConnectionFactory.java 2011-10-28 21:44:26 UTC (rev 629) @@ -26,6 +26,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.mc4j.ems.connection.settings.ConnectionSettings; import org.mc4j.ems.connection.support.ConnectionProvider; import org.mc4j.ems.connection.support.classloader.ClassLoaderFactory; Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/EmsConnection.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/EmsConnection.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/EmsConnection.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2011 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,15 +13,14 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.connection; +import java.util.List; +import java.util.SortedSet; + import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.support.ConnectionProvider; -import java.util.List; -import java.util.SortedSet; - /** * TODO GH: Decide exception handling strategy (runtime?) * @@ -30,13 +29,24 @@ */ public interface EmsConnection extends Refreshable { - ConnectionTracker getTracker(); void close(); + /** + * Does a *:* load of all MBean names and caches them as EmsBeans. + * + * @param deep if true, also loads the MBeanInfo for each MBean and caches it in the corresponding EmsBean + */ void loadSynchronous(boolean deep); + /** + * Unloads all cached metadata associated with this connection - MBeanInfos, etc. + * + * @since 1.3 + */ + void unload(); + void addRegistrationListener(MBeanRegistrationListener registrationListener); void removeRegistrationListener(MBeanRegistrationListener registrationListener); Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/LoadException.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/LoadException.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/LoadException.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,8 +16,6 @@ package org.mc4j.ems.connection; -import org.mc4j.ems.connection.EmsException; - /** * @author Greg Hinkle (gh...@us...), Apr 12, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationEvent.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationEvent.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationEvent.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,10 +16,10 @@ package org.mc4j.ems.connection; +import java.util.Set; + import org.mc4j.ems.connection.bean.EmsBean; -import java.util.Set; - /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationListener.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationListener.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/MBeanRegistrationListener.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,7 +1,5 @@ package org.mc4j.ems.connection; -import org.mc4j.ems.connection.MBeanRegistrationEvent; - /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/EmsBean.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Greg Hinkle + * Copyright 2002-2011 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,14 +15,14 @@ */ package org.mc4j.ems.connection.bean; +import java.util.List; +import java.util.SortedSet; + import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.mc4j.ems.connection.bean.notification.EmsNotification; import org.mc4j.ems.connection.bean.operation.EmsOperation; import org.mc4j.ems.connection.support.ConnectionProvider; -import java.util.List; -import java.util.SortedSet; - /** * An MBean. * @@ -59,9 +59,22 @@ */ <T> T getProxy(Class<T> beanInterface); + /** + * Loads local representations of this MBean's attributes, operations and notifications if not already loaded. + * Current attribute values are not retrieved. + */ void loadSynchronous() ; /** + * Unloads any cached metadata associated with this MBean. This is useful for handling dynamic mbeans with changing + * descriptors or corner case situations where an MBean is unregistered and then another MBean with a non-equivalent + * MBeanInfo is registered with the same ObjectName. + * + * @since 1.3 + */ + void unload(); + + /** * Returns the set of all attributes for this MBean; never null. * * @return the set of all attributes for this MBean; never null Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotificationEvent.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotificationEvent.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/notification/EmsNotificationEvent.java 2011-10-28 21:44:26 UTC (rev 629) @@ -15,10 +15,10 @@ */ package org.mc4j.ems.connection.bean.notification; +import java.util.Date; + import org.mc4j.ems.connection.bean.EmsBean; -import java.util.Date; - /** * @author Greg Hinkle (gh...@us...), Nov 10, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/bean/operation/EmsOperation.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,15 +16,15 @@ package org.mc4j.ems.connection.bean.operation; +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.mc4j.ems.connection.EmsInvocationException; import org.mc4j.ems.connection.bean.parameter.EmsParameter; -import org.mc4j.ems.connection.EmsInvocationException; -import java.util.List; -import java.util.Collections; -import java.util.Arrays; -import java.io.Serializable; -import java.io.ObjectStreamException; - /** * An MBean operation. * Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVMFinder.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVMFinder.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVMFinder.java 2011-10-28 21:44:26 UTC (rev 629) @@ -22,14 +22,14 @@ package org.mc4j.ems.connection.local; +import java.lang.reflect.Method; +import java.util.Map; + +import org.mc4j.ems.connection.EmsException; import org.mc4j.ems.connection.settings.ConnectionSettings; import org.mc4j.ems.connection.support.classloader.ClassLoaderFactory; import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor; -import org.mc4j.ems.connection.EmsException; -import java.lang.reflect.Method; -import java.util.Map; - public class LocalVMFinder { public static Map<Integer, LocalVirtualMachine> getManageableVirtualMachines() { Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVirtualMachine.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVirtualMachine.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/local/LocalVirtualMachine.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,14 +16,7 @@ package org.mc4j.ems.connection.local; -import com.sun.tools.attach.AgentInitializationException; -import com.sun.tools.attach.AgentLoadException; -import com.sun.tools.attach.AttachNotSupportedException; -import com.sun.tools.attach.VirtualMachine; - import java.io.File; -import java.io.IOException; -import java.util.Properties; public class LocalVirtualMachine { Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/ConnectionSettings.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/ConnectionSettings.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/ConnectionSettings.java 2011-10-28 21:44:26 UTC (rev 629) @@ -17,15 +17,15 @@ package org.mc4j.ems.connection.settings; -import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor; - import java.io.File; import java.io.ObjectStreamField; import java.io.Serializable; import java.util.List; +import java.util.Map; import java.util.Properties; -import java.util.Map; +import org.mc4j.ems.connection.support.metadata.ConnectionTypeDescriptor; + /** * Options for connections * Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingPersistence.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingPersistence.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingPersistence.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,20 +16,20 @@ package org.mc4j.ems.connection.settings.persistence; -import org.mc4j.ems.connection.settings.ConnectionSettings; -import org.mc4j.ems.connection.EmsException; - -import java.io.ByteArrayOutputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.ByteArrayInputStream; -import java.beans.XMLEncoder; +import java.beans.Encoder; import java.beans.ExceptionListener; +import java.beans.Expression; import java.beans.PersistenceDelegate; -import java.beans.Expression; -import java.beans.Encoder; import java.beans.XMLDecoder; +import java.beans.XMLEncoder; +import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import org.mc4j.ems.connection.EmsException; +import org.mc4j.ems.connection.settings.ConnectionSettings; + /** * @author Greg Hinkle (gh...@us...), May 9, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingsStore.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingsStore.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/settings/persistence/ConnectionSettingsStore.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,11 +16,11 @@ package org.mc4j.ems.connection.settings.persistence; +import java.util.prefs.Preferences; + import org.mc4j.ems.connection.settings.ConnectionSettings; -import java.util.prefs.Preferences; - /** * @author Greg Hinkle (gh...@us...), May 5, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/ClassLoaderFactory.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,27 +16,33 @@ package org.mc4j.ems.connection.support.classloader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mc4j.ems.connection.ConnectionFactory; -import org.mc4j.ems.connection.EmsConnectException; -import org.mc4j.ems.connection.EmsException; -import org.mc4j.ems.connection.settings.ConnectionSettings; -import org.mc4j.ems.connection.support.metadata.JSR160ConnectionTypeDescriptor; -import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor; - import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; +import java.lang.ref.WeakReference; import java.net.MalformedURLException; import java.net.URL; import java.net.URLClassLoader; -import java.util.*; -import java.lang.ref.WeakReference; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.mc4j.ems.connection.ConnectionFactory; +import org.mc4j.ems.connection.EmsConnectException; +import org.mc4j.ems.connection.EmsException; +import org.mc4j.ems.connection.settings.ConnectionSettings; +import org.mc4j.ems.connection.support.metadata.JSR160ConnectionTypeDescriptor; +import org.mc4j.ems.connection.support.metadata.LocalVMTypeDescriptor; + /** * @author Greg Hinkle (gh...@us...), Apr 5, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoader.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoader.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoader.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,8 +16,6 @@ package org.mc4j.ems.connection.support.classloader; -import org.mc4j.ems.connection.support.classloader.deepjar.Handler; - import java.net.MalformedURLException; import java.net.URL; import java.security.CodeSigner; @@ -25,6 +23,8 @@ import java.security.ProtectionDomain; import java.util.Map; +import org.mc4j.ems.connection.support.classloader.deepjar.Handler; + /** * @author Greg Hinkle (gh...@us...), May 17, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoaderOrig.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoaderOrig.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/DeepClassLoaderOrig.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,8 +16,6 @@ package org.mc4j.ems.connection.support.classloader; -import org.mc4j.ems.connection.support.classloader.deepjar.Handler; - import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; @@ -41,6 +39,8 @@ import java.util.jar.JarInputStream; import java.util.jar.Manifest; +import org.mc4j.ems.connection.support.classloader.deepjar.Handler; + /** * @author Greg Hinkle (gh...@us...), May 9, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/NestedJarClassLoader.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/NestedJarClassLoader.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/NestedJarClassLoader.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,16 +16,16 @@ package org.mc4j.ems.connection.support.classloader; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.net.URL; import java.net.URLClassLoader; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; -import java.util.ArrayList; -import java.util.List; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * <p>This classloader is able to load classes from the contents of jar files available * in the parent classloader. This mechanism creates support for nested jar file Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/deepjar/Handler.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/deepjar/Handler.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/classloader/deepjar/Handler.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,15 +16,16 @@ package org.mc4j.ems.connection.support.classloader.deepjar; -import org.mc4j.ems.connection.support.classloader.NestedJarClassLoader; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import java.net.URLStreamHandler; -import java.net.URLConnection; -import java.net.URL; -import java.io.IOException; -import java.io.InputStream; +import org.mc4j.ems.connection.support.classloader.NestedJarClassLoader; /** * @author Greg Hinkle (gh...@us...), May 9, 2005 Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/AbstractConnectionTypeDescriptor.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/AbstractConnectionTypeDescriptor.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/AbstractConnectionTypeDescriptor.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,18 +16,18 @@ package org.mc4j.ems.connection.support.metadata; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.io.File; import java.io.IOException; -import java.util.jar.JarFile; -import java.util.jar.Attributes; +import java.net.MalformedURLException; +import java.util.Iterator; import java.util.Map; -import java.util.Iterator; import java.util.Properties; -import java.net.MalformedURLException; +import java.util.jar.Attributes; +import java.util.jar.JarFile; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + /** * @author Greg Hinkle (gh...@us...), Sep 30, 2004 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/JBossConnectionTypeDescriptor.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/JBossConnectionTypeDescriptor.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/connection/support/metadata/JBossConnectionTypeDescriptor.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,10 +16,11 @@ package org.mc4j.ems.connection.support.metadata; -import javax.naming.Context; import java.util.Properties; +import javax.naming.Context; + /** * @author Greg Hinkle (gh...@us...), Sep 30, 2004 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/store/CompleteValueHistory.java =================================================================== --- trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/store/CompleteValueHistory.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems/org/mc4j/ems/store/CompleteValueHistory.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,9 +16,9 @@ package org.mc4j.ems.store; +import java.util.Collections; +import java.util.LinkedList; import java.util.List; -import java.util.LinkedList; -import java.util.Collections; /** * @author Greg Hinkle (gh...@us...), Apr 6, 2005 Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/DConnection.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2004 Greg Hinkle + * Copyright 2002-2011 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,31 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package org.mc4j.ems.impl.jmx.connection; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedMap; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import javax.management.MBeanException; +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectInstance; +import javax.management.ObjectName; +import javax.management.OperationsException; +import javax.management.QueryExp; +import javax.management.ReflectionException; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.mc4j.ems.connection.ConnectionTracker; import org.mc4j.ems.connection.EmsConnection; import org.mc4j.ems.connection.EmsException; @@ -31,24 +51,6 @@ import org.mc4j.ems.impl.jmx.connection.bean.DMBean; import org.mc4j.ems.impl.jmx.connection.support.providers.AbstractConnectionProvider; -import javax.management.MBeanException; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectInstance; -import javax.management.ObjectName; -import javax.management.OperationsException; -import javax.management.QueryExp; -import javax.management.ReflectionException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedMap; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; -import java.util.Comparator; - /** * TODO GH: Decide exception handling strategy (runtime?) * @@ -62,7 +64,6 @@ protected String connectionName; protected AbstractConnectionProvider connectionProvider; - protected SortedMap<DObjectName, EmsBean> beanMap; protected boolean loaded; @@ -89,7 +90,6 @@ return null; } - public void refresh() { try { loadSynchronous(false); @@ -119,29 +119,25 @@ objectNames = server.queryNames(null,null); }*/ - - /** - * Does a *:* load of all MBean names. Puts them in a list - * - * @param deep - */ @SuppressWarnings({"unchecked"}) public synchronized void loadSynchronous(boolean deep) { if (!connectionProvider.isConnected()) connectionProvider.connect(); - log.info("Querying MBeanServer for all MBeans"); + log.info("Querying MBeanServer for all MBeans..."); + MBeanServer mBeanServer = connectionProvider.getMBeanServer(); Set<ObjectName> objectNames = null; try { - objectNames = (Set<ObjectName>) connectionProvider.getMBeanServer().queryNames(new ObjectName("*:*"), null); + objectNames = (Set<ObjectName>) mBeanServer.queryNames(new ObjectName("*:*"), null); } catch (MalformedObjectNameException e) { /* Should never happen */ } SortedMap<ObjectName, DMBean> retrievedBeansMap = new TreeMap<ObjectName, DMBean>(new ObjectNameComparator()); - if (!loaded) - log.info("Found " + objectNames.size() + " MBeans, starting load"); + if (!loaded) { + log.info("Found " + objectNames.size() + " MBeans - starting load..."); + } Set<DObjectName> currentKeys = new HashSet<DObjectName>(this.beanMap.keySet()); @@ -149,7 +145,7 @@ // TODO: We're loading the beans on every run here i think... only load it if its not in the beanMap - DMBean bean = mapBean(connectionProvider, objectName, deep); + DMBean bean = mapBean(objectName, deep); retrievedBeansMap.put(objectName, bean); } @@ -168,11 +164,18 @@ } } -// if (false) -// log.debug("Added " + newBeans.size() + " and removed " + removedBeans.size()); + if (loaded && log.isDebugEnabled()) { + log.debug("Added " + newBeans.size() + " and removed " + removedBeans.size() + " since previous load."); + } + loaded = true; fireRegistrationEvent(newBeans, removedBeans); + } + public void unload() { + for (EmsBean bean : beanMap.values()) { + bean.unload(); + } } static boolean isJMX12 = false; @@ -185,11 +188,11 @@ } } - private DMBean mapBean(ConnectionProvider provider, ObjectName objectName, boolean loadSynchronous) { + private DMBean mapBean(ObjectName objectName, boolean loadSynchronous) { DMBean bean = null; DObjectName dObjectName = new DObjectName(objectName); - // If the bean is unkown to the internal map, create our local representation and add it + // If the bean is unknown to the internal map, create our local representation and add it synchronized (this) { if (!this.beanMap.keySet().contains(dObjectName)) { if (isJMX12) { @@ -201,8 +204,8 @@ } } - // If the bean was just created then optional load its metadata syncrhonously - // Do this outside the syncrhonized block + // If the bean was just created then optional load its metadata synchronously + // Do this outside the synchronized block if (bean != null && loadSynchronous) { try { bean.loadSynchronous(); @@ -306,7 +309,7 @@ List<EmsBean> results = new ArrayList<EmsBean>(); for (ObjectName name : objectNames) { - results.add(mapBean(connectionProvider, name, false)); + results.add(mapBean(name, false)); } return results; } @@ -338,7 +341,7 @@ try { ObjectName objName = new ObjectName(objectName); ObjectInstance instance = connectionProvider.getMBeanServer().createMBean(className, objName); - return mapBean(connectionProvider, instance.getObjectName(), false); + return mapBean(instance.getObjectName(), false); } catch (MBeanException e) { e.printStackTrace(); throw new EmsException("Couldn't create MBean", e); @@ -354,7 +357,7 @@ try { ObjectName objName = new ObjectName(objectName); ObjectInstance instance = connectionProvider.getMBeanServer().createMBean(className, objName, params, signature); - return mapBean(connectionProvider, instance.getObjectName(), false); + return mapBean(instance.getObjectName(), false); } catch (MBeanException e) { e.printStackTrace(); throw new EmsException("Couldn't create MBean", e); Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/PooledConnectionTracker.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/PooledConnectionTracker.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/PooledConnectionTracker.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,13 +16,6 @@ package org.mc4j.ems.impl.jmx.connection; -import org.mc4j.ems.connection.ConnectionTracker; -import org.mc4j.ems.connection.bean.EmsBean; -import org.mc4j.ems.connection.bean.attribute.EmsAttribute; -import org.mc4j.ems.impl.jmx.connection.bean.DMBean; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - import java.util.ArrayList; import java.util.List; import java.util.Set; @@ -31,6 +24,14 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.mc4j.ems.connection.ConnectionTracker; +import org.mc4j.ems.connection.bean.EmsBean; +import org.mc4j.ems.connection.bean.attribute.EmsAttribute; +import org.mc4j.ems.impl.jmx.connection.bean.DMBean; + /** * @author Greg Hinkle (gh...@us...), Apr 12, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DAdvancedBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DAdvancedBean.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DAdvancedBean.java 2011-10-28 21:44:26 UTC (rev 629) @@ -15,13 +15,14 @@ */ package org.mc4j.ems.impl.jmx.connection.bean; -import org.mc4j.ems.impl.jmx.connection.support.providers.AbstractConnectionProvider; +import java.lang.reflect.Method; -import javax.management.ObjectName; import javax.management.MBeanServer; import javax.management.MBeanServerInvocationHandler; -import java.lang.reflect.Method; +import javax.management.ObjectName; +import org.mc4j.ems.impl.jmx.connection.support.providers.AbstractConnectionProvider; + /** * @author Greg Hinkle (gh...@us...), Nov 16, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DBeanName.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,12 +1,13 @@ package org.mc4j.ems.impl.jmx.connection.bean; -import org.mc4j.ems.connection.bean.EmsBeanName; -import org.mc4j.ems.connection.EmsMalformedObjectNameException; +import java.util.Map; +import javax.management.MalformedObjectNameException; import javax.management.ObjectName; -import javax.management.MalformedObjectNameException; -import java.util.Map; +import org.mc4j.ems.connection.EmsMalformedObjectNameException; +import org.mc4j.ems.connection.bean.EmsBeanName; + /** * Created by IntelliJ IDEA. * User: ghinkle Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/DMBean.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Greg Hinkle + * Copyright 2002-2011 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,34 +15,46 @@ */ package org.mc4j.ems.impl.jmx.connection.bean; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import javax.management.Attribute; +import javax.management.AttributeList; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanInfo; +import javax.management.MBeanNotificationInfo; +import javax.management.MBeanOperationInfo; +import javax.management.MBeanRegistrationException; +import javax.management.MBeanServer; +import javax.management.ObjectName; + import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.mc4j.ems.connection.EmsBeanNotFoundException; import org.mc4j.ems.connection.EmsUnsupportedTypeException; import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.EmsBeanName; -import org.mc4j.ems.connection.bean.parameter.EmsParameter; import org.mc4j.ems.connection.bean.attribute.EmsAttribute; import org.mc4j.ems.connection.bean.notification.EmsNotification; import org.mc4j.ems.connection.bean.operation.EmsOperation; +import org.mc4j.ems.connection.bean.parameter.EmsParameter; import org.mc4j.ems.impl.jmx.connection.bean.attribute.DAttribute; import org.mc4j.ems.impl.jmx.connection.bean.attribute.DUnkownAttribute; import org.mc4j.ems.impl.jmx.connection.bean.notification.DNotification; import org.mc4j.ems.impl.jmx.connection.bean.operation.DOperation; import org.mc4j.ems.impl.jmx.connection.support.providers.AbstractConnectionProvider; -import javax.management.Attribute; -import javax.management.AttributeList; -import javax.management.InstanceNotFoundException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanInfo; -import javax.management.MBeanNotificationInfo; -import javax.management.MBeanOperationInfo; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.ObjectName; -import java.util.*; - /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) @@ -62,7 +74,6 @@ private boolean unsupportedType = false; protected boolean deleted = false; - private Map<String, EmsAttribute> attributes = new TreeMap<String, EmsAttribute>(String.CASE_INSENSITIVE_ORDER); private Map<String, EmsOperation> operations = new TreeMap<String, EmsOperation>(String.CASE_INSENSITIVE_ORDER); private Set<EmsOperation> allOperations = new TreeSet<EmsOperation>(); @@ -120,15 +131,8 @@ throw new UnsupportedOperationException("Proxies not supported pre-jmx 1.2"); } - /** - * Loads local representations of attributes, operations and notifications. - * Current attribute values are not retrived. - */ public synchronized void loadSynchronous() { - - if (!loaded) { - // TODO GH: Support loading twice to handle dynamic mbeans with changing descriptors? try { info = connectionProvider.getMBeanServer().getMBeanInfo(this.objectName); @@ -162,7 +166,17 @@ loaded = true; } } + } + public void unload() { + if (loaded) { + loaded = false; + info = null; + attributes.clear(); + operations.clear(); + allOperations.clear(); + notifications.clear(); + } } public boolean isRegistered() { @@ -198,7 +212,12 @@ if (info == null) loadSynchronous(); - MBeanAttributeInfo[] infos = this.info.getAttributes(); + MBeanAttributeInfo[] infos = new MBeanAttributeInfo[0]; + try { + infos = this.info.getAttributes(); + } catch (RuntimeException e) { + // If this throws an exception, there's a good chance our cached + } // MUST be careful to only ask for types that we know we have // otherwise the RMI call will fail and we will get no data. @@ -402,7 +421,6 @@ otherBean.getObjectName().getCanonicalName()); } - public String toString() { return this.getBeanName().toString(); } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/attribute/DAttribute.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,38 +16,38 @@ package org.mc4j.ems.impl.jmx.connection.bean.attribute; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mc4j.ems.connection.EmsException; -import org.mc4j.ems.connection.bean.attribute.AttributeChangeEvent; -import org.mc4j.ems.connection.bean.attribute.AttributeChangeListener; -import org.mc4j.ems.connection.bean.attribute.EmsAttribute; -import org.mc4j.ems.impl.jmx.connection.bean.DMBean; -import org.mc4j.ems.store.Value; -import org.mc4j.ems.store.ValueHistory; -import org.mc4j.ems.store.CompleteValueHistory; - -import javax.management.Attribute; -import javax.management.AttributeNotFoundException; -import javax.management.InstanceNotFoundException; -import javax.management.MBeanAttributeInfo; -import javax.management.MBeanException; -import javax.management.MBeanServer; -import javax.management.ReflectionException; -import javax.management.modelmbean.ModelMBeanAttributeInfo; import java.io.NotSerializableException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.UndeclaredThrowableException; import java.math.BigDecimal; import java.math.BigInteger; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Set; -import java.util.Collections; +import javax.management.Attribute; +import javax.management.AttributeNotFoundException; +import javax.management.InstanceNotFoundException; +import javax.management.MBeanAttributeInfo; +import javax.management.MBeanException; +import javax.management.MBeanServer; +import javax.management.ReflectionException; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.mc4j.ems.connection.EmsException; +import org.mc4j.ems.connection.bean.attribute.AttributeChangeEvent; +import org.mc4j.ems.connection.bean.attribute.AttributeChangeListener; +import org.mc4j.ems.connection.bean.attribute.EmsAttribute; +import org.mc4j.ems.impl.jmx.connection.bean.DMBean; +import org.mc4j.ems.store.CompleteValueHistory; +import org.mc4j.ems.store.ValueHistory; + /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/notification/DNotification.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/notification/DNotification.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/notification/DNotification.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,18 +16,29 @@ package org.mc4j.ems.impl.jmx.connection.bean.notification; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.management.InstanceNotFoundException; +import javax.management.ListenerNotFoundException; +import javax.management.MBeanNotificationInfo; +import javax.management.Notification; +import javax.management.NotificationFilter; +import javax.management.NotificationListener; + import org.mc4j.ems.connection.EmsBeanNotFoundException; +import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.connection.bean.notification.EmsNotification; import org.mc4j.ems.connection.bean.notification.EmsNotificationEvent; import org.mc4j.ems.connection.bean.notification.EmsNotificationListener; -import org.mc4j.ems.connection.bean.EmsBean; import org.mc4j.ems.impl.jmx.connection.bean.DBeanName; import org.mc4j.ems.impl.jmx.connection.bean.DMBean; -import javax.management.*; -import java.io.Serializable; -import java.util.*; - /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/operation/DOperation.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,20 +16,19 @@ package org.mc4j.ems.impl.jmx.connection.bean.operation; -import org.mc4j.ems.impl.jmx.connection.bean.DMBean; -import org.mc4j.ems.impl.jmx.connection.bean.parameter.DParameter; -import org.mc4j.ems.connection.bean.operation.EmsOperation; -import org.mc4j.ems.connection.bean.parameter.EmsParameter; -import org.mc4j.ems.connection.EmsInvocationException; +import java.util.ArrayList; +import java.util.List; import javax.management.MBeanOperationInfo; import javax.management.MBeanParameterInfo; import javax.management.ReflectionException; -import java.util.List; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; +import org.mc4j.ems.connection.EmsInvocationException; +import org.mc4j.ems.connection.bean.operation.EmsOperation; +import org.mc4j.ems.connection.bean.parameter.EmsParameter; +import org.mc4j.ems.impl.jmx.connection.bean.DMBean; +import org.mc4j.ems.impl.jmx.connection.bean.parameter.DParameter; + /** * @author Greg Hinkle (gh...@us...), Apr 4, 2005 * @version $Revision$($Author$ / $Date$) Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/bean/parameter/DParameter.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,10 +16,10 @@ package org.mc4j.ems.impl.jmx.connection.bean.parameter; +import javax.management.MBeanParameterInfo; + import org.mc4j.ems.connection.bean.parameter.EmsParameter; -import javax.management.MBeanParameterInfo; - /** * Created: Jul 20, 2005 1:12:14 AM * Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/AbstractConnectionProvider.java 2011-10-28 21:44:26 UTC (rev 629) @@ -1,5 +1,5 @@ /* - * Copyright 2002-2010 Greg Hinkle + * Copyright 2002-2011 Greg Hinkle * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,19 +15,20 @@ */ package org.mc4j.ems.impl.jmx.connection.support.providers; +import java.util.ArrayList; +import java.util.List; +import java.util.Timer; + +import javax.management.MBeanServer; + +import org.mc4j.ems.connection.EmsConnectException; import org.mc4j.ems.connection.EmsConnection; -import org.mc4j.ems.connection.EmsConnectException; import org.mc4j.ems.connection.settings.ConnectionSettings; +import org.mc4j.ems.connection.support.ConnectionListener; import org.mc4j.ems.connection.support.ConnectionProvider; -import org.mc4j.ems.connection.support.ConnectionListener; import org.mc4j.ems.impl.jmx.connection.DConnection; import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.StatsProxy; -import javax.management.MBeanServer; -import java.util.Timer; -import java.util.List; -import java.util.ArrayList; - /** * This Node is the abstract node representing a connection to a JMX Server. * @@ -81,18 +82,21 @@ return this.connected; } + @Deprecated public void setConnected(boolean connected) throws Exception { - - if (this.connected) { + if (connected) { + connect(); + } else { disconnect(); - } else { - connect(); } - } public final EmsConnection connect() { + if (existingConnection != null) { + // We were previously connected. Clear any cached data, since it could contain references to stale RMI stubs. + existingConnection.unload(); + } try { doConnect(); @@ -103,7 +107,7 @@ } if (existingConnection == null) { - DConnection connection = new DConnection("unknown",this); + DConnection connection = new DConnection("unknown", this); this.existingConnection = connection; } else { Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/InternalVMProvider.java 2011-10-28 21:44:26 UTC (rev 629) @@ -15,15 +15,16 @@ */ package org.mc4j.ems.impl.jmx.connection.support.providers; -import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; - -import javax.management.MBeanServer; -import javax.management.MBeanServerFactory; import java.lang.management.ManagementFactory; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; +import javax.management.MBeanServer; +import javax.management.MBeanServerFactory; + +import org.mc4j.ems.connection.support.metadata.InternalVMTypeDescriptor; + /** * Connect to the platform mbean server in the VM that EMS is running in. * Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JBossConnectionProvider.java 2011-10-28 21:44:26 UTC (rev 629) @@ -15,23 +15,25 @@ */ package org.mc4j.ems.impl.jmx.connection.support.providers; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.mc4j.ems.connection.ConnectionException; -import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.GenericMBeanServerProxy; -import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossCallbackHandler; -import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossConfiguration; +import java.util.Properties; import javax.management.MBeanServer; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.naming.NoInitialContextException; +import javax.security.auth.login.Configuration; import javax.security.auth.login.LoginContext; import javax.security.auth.login.LoginException; -import javax.security.auth.login.Configuration; -import java.util.Properties; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.mc4j.ems.connection.ConnectionException; +import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossCallbackHandler; +import org.mc4j.ems.impl.jmx.connection.support.providers.jaas.JBossConfiguration; +import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.GenericMBeanServerProxy; + /** * Represents a Connection to a JBoss JMX Server. This connection * works against the JBoss RMI connector. If a principal and @@ -84,6 +86,7 @@ if (this.proxy != null) { // This is a reconnect + log.debug("Reconnecting to remote JBoss MBeanServer..."); this.proxy.setRemoteServer(rmiAdaptor); } else { this.proxy = new GenericMBeanServerProxy(rmiAdaptor); @@ -115,7 +118,8 @@ // Try to be more helpful, indicating the reason we couldn't make the connection in this // common case of missing libraries. if (e.getCause() instanceof ClassNotFoundException) { - throw new ConnectionException("Necessary classes not found for remote connection, check installation path configuration.",e.getCause()); + throw new ConnectionException("Necessary classes not found for remote connection, check installation path configuration.", + e.getCause()); } throw e; } Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java 2011-09-13 16:50:12 UTC (rev 628) +++ trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/JMXRemotingConnectionProvider.java 2011-10-28 21:44:26 UTC (rev 629) @@ -16,11 +16,16 @@ package org.mc4j.ems.impl.jmx.connection.support.providers; -import org.mc4j.ems.connection.EmsConnectException; -import org.mc4j.ems.connection.EmsException; -import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.JMXRemotingMBeanServerProxy; -import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.JSR77ManagementMBeanServerProxy; -import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.StatsProxy; +import java.io.IOException; +import java.lang.reflect.Method; +import java.net.MalformedURLException; +import java.rmi.NotBoundException; +import java.rmi.RemoteException; +import java.rmi.registry.LocateRegistry; +import java.rmi.registry.Registry; +import java.util.Hashtable; +import java.util.Map; +import java.util.Set; import javax.management.MBeanServer; import javax.management.MBeanServerConnection; @@ -35,17 +40,13 @@ import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import javax.rmi.ssl.SslRMIClientSocketFactory; -import java.io.IOException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.rmi.NotBoundException; -import java.rmi.RemoteException; -import java.rmi.registry.LocateRegistry; -import java.rmi.registry.Registry; -import java.util.Hashtable; -import java.util.Map; -import java.util.Set; +import org.mc4j.ems.connection.EmsConnectException; +import org.mc4j.ems.connection.EmsException; +import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.JMXRemotingMBeanServerProxy; +import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.JSR77ManagementMBeanServerProxy; +import org.mc4j.ems.impl.jmx.connection.support.providers.proxy.StatsProxy; + /** * Represents a Connection to a JSR 160 compliant RMI server * Modified: trunk/mc4j/modules/ems/src/ems-impl/org/mc4j/ems/impl/jmx/connection/support/providers/LocalVMProvider.java =================================================================== --- trunk/mc4j/modules/ems/src/ems... [truncated message content] |