http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/jmx/MBeanServerGateway.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/jmx/MBeanServerGateway.java b/core/src/flex/management/jmx/MBeanServerGateway.java deleted file mode 100644 index f60c401..0000000 --- a/core/src/flex/management/jmx/MBeanServerGateway.java +++ /dev/null @@ -1,906 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.jmx; - -import flex.management.BaseControl; -import flex.management.MBeanServerLocatorFactory; -import flex.management.ManagementException; - -import java.util.Iterator; -import java.util.Set; -import java.util.TreeSet; - -import javax.management.AttributeList; -import javax.management.AttributeNotFoundException; -import javax.management.InstanceAlreadyExistsException; -import javax.management.InstanceNotFoundException; -import javax.management.IntrospectionException; -import javax.management.InvalidAttributeValueException; -import javax.management.MalformedObjectNameException; -import javax.management.MBeanException; -import javax.management.MBeanRegistrationException; -import javax.management.MBeanServer; -import javax.management.NotCompliantMBeanException; -import javax.management.ReflectionException; -import javax.management.RuntimeOperationsException; - -/** - * Remoting gateway to the MBean server that hosts Flex MBeans. - * - * Some base javax.management.MBeanServer methods are unimplemented due to the - * fact that we're interacting with the MBean server from remote Flash clients. - * Some methods have been modified to better suite remote Flash clients. Other - * methods are additive, serving as a convenience for Flex applications. - * - * Unimplemented methods from the base MBeanServer API: - * <ul> - * <li>getDomains() - JMX 1.2</li> - * <li>addNotificationListener()/removeNotificationListener() - Flash objects - * cannot listen directly for MBean notifications.</li> - * <li>instantiate() - returns a reference to a Java object that is not useful - * to a remote Flash client.</li> - * <li>deserialize() - deprecated.</li> - * <li>getClassLoaderFor() - meaningless to a Flash client.</li> - * <li>getClassLoader() - meaningless to a Flash client.</li> - * <li>getClassLoaderRepository() - meaningless to a Flash client.</li> - * </ul> - * - * Modifications to the base MBeanServer API: - * <ul> - * <li>* All ObjectName arguments are typed as String because serialization in either - * direction doesn't support ObjectNames that are patterns. This does not effect - * ObjectNames that are not patterns that are returned to the client.</li> - * <li>queryMBeans() - returns an Array of ObjectInstances rather than a java.util.Set - * and does not currently support the QueryExp argument.</li> - * <li>queryNames() returns an Array of ObjectNames rather than a java.util.Set - * and does not currently support the QueryExp argument.</li> - * <li>getAttributes() returns an Array of Attributes rather than an AttributeList.</li> - * <li>setAttributes() accepts and returns Arrays of Attributes rather than AttributeLists.</li> - * </ul> - * - * Additonal Flex-specific methods: - * <ul> - * <li>getFlexMBeanCount()</li> - * <li>getFlexDomains()</li> - * <li>getFlexMBeanObjectNames()</li> - * </ul> - */ -public class MBeanServerGateway -{ - // Error string constants. - private static final int MALFORMED_OBJECTNAME = 10400; - private static final int GETINFO_INTROSPECTION_ERR = 10406; - private static final int MBEAN_NOTFOUND = 10407; - private static final int GETINFO_REFLECT_ERR = 10408; - private static final int ATTRIB_NOTFOUND = 10409; - private static final int GETATTRIB_EXCEPTION = 10410; - private static final int GETATTRIB_REFLECT_ERR = 10411; - private static final int GETATTRIB_NULL_ARGUMENT = 10412; - private static final int GETATTRIBS_REFLECT_ERR = 10413; - private static final int GETATTRIBS_NULL_ARGUMENT = 10414; - private static final int INVOKE_REFLECT_ERR = 10415; - private static final int INVOKE_ERR = 10416; - private static final int CREATE_ERR = 10417; - private static final int INSTANCE_EXISTS = 10418; - private static final int NOT_COMPLIANT = 10419; - private static final int MBEAN_PREREG_ERR = 10420; - private static final int MBEAN_PREDEREG_ERR = 10421; - private static final int SETATTRIB_REFLECT_ERR = 10422; - private static final int SETATTRIB_EXCEPTION = 10423; - private static final int INVALID_ATTRIB_VALUE = 10424; - private static final int SETATTRIBS_REFLECT_ERR = 10425; - - private MBeanServer server; - - /** - * Constructs a new MBeanServerGateway. The gateway exposes the MBean server - * that Flex MBean are registered with in a remoting-friendly fashion. - */ - public MBeanServerGateway() - { - server = MBeanServerLocatorFactory.getMBeanServerLocator().getMBeanServer(); - } - - ///////////////////////////////////// - // - // Core MBeanServer API - // - ///////////////////////////////////// - - /** - * Instantiates and registers an MBean with the MBean server. - * - * @param className The class name for the MBean to instantiate. - * @param objectName The object name of the MBean. - * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean. - */ - public ObjectInstance createMBean(String className, String objectName) - { - javax.management.ObjectName name = null; - if (objectName != null) - name = validateObjectName(objectName); - try - { - return new ObjectInstance(server.createMBean(className, name)); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - catch (InstanceAlreadyExistsException iaee) - { - ManagementException me = new ManagementException(); - me.setMessage(INSTANCE_EXISTS, new Object[] {name}); - me.setRootCause(iaee); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(mbe); - throw me; - } - catch (NotCompliantMBeanException ncmbe) - { - ManagementException me = new ManagementException(); - me.setMessage(NOT_COMPLIANT, new Object[] {className}); - me.setRootCause(ncmbe); - throw me; - } - } - - /** - * Instantiates and registers an MBean with the MBean server. The class loader - * to use to load the MBean class is identified by its ObjectName. - * - * @param className The class name for the MBean to instantiate. - * @param objectName The object name of the MBean. - * @param loaderName The object name of the desired class loader. - * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean. - */ - public ObjectInstance createMBean(String className, String objectName, String loaderName) - { - javax.management.ObjectName name = null; - javax.management.ObjectName loader = null; - if (objectName != null) - name = validateObjectName(objectName); - if (loaderName != null) - loader = validateObjectName(loaderName); - try - { - return new ObjectInstance(server.createMBean(className, name, loader)); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - catch (InstanceAlreadyExistsException iaee) - { - ManagementException me = new ManagementException(); - me.setMessage(INSTANCE_EXISTS, new Object[] {name}); - me.setRootCause(iaee); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(mbe); - throw me; - } - catch (NotCompliantMBeanException ncmbe) - { - ManagementException me = new ManagementException(); - me.setMessage(NOT_COMPLIANT, new Object[] {className}); - me.setRootCause(ncmbe); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - } - - /** - * Instantiates and registers an MBean with the MBean server. - * - * @param className The class name for the MBean to instantiate. - * @param objectName The object name of the MBean. - * @param params An array of parameters to pass to the MBean constructor. - * @param signature An array containing the type signature for the constructor to invoke. - * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean. - */ - public ObjectInstance createMBean(String className, String objectName, Object[] params, String[] signature) - { - javax.management.ObjectName name = null; - if (objectName != null) - name = validateObjectName(objectName); - try - { - return new ObjectInstance(server.createMBean(className, name, params, signature)); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - catch (InstanceAlreadyExistsException iaee) - { - ManagementException me = new ManagementException(); - me.setMessage(INSTANCE_EXISTS, new Object[] {name}); - me.setRootCause(iaee); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(mbe); - throw me; - } - catch (NotCompliantMBeanException ncmbe) - { - ManagementException me = new ManagementException(); - me.setMessage(NOT_COMPLIANT, new Object[] {className}); - me.setRootCause(ncmbe); - throw me; - } - } - - /** - * Instantiates and registers an MBean with the MBean server. The class loader - * to use to load the MBean class is identified by its ObjectName. - * - * @param className The class name for the MBean to instantiate. - * @param objectName The object name of the MBean. - * @param loaderName The object name of the desired class loader. - * @param params An array of parameters to pass to the MBean constructor. - * @param signature An array containing the type signature for the constructor to invoke. - * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean. - */ - public ObjectInstance createMBean(String className, String objectName, String loaderName, Object[] params, String[] signature) - { - javax.management.ObjectName name = null; - javax.management.ObjectName loader = null; - if (objectName != null) - name = validateObjectName(objectName); - if (loaderName != null) - loader = validateObjectName(loaderName); - try - { - return new ObjectInstance(server.createMBean(className, name, loader, params, signature)); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - catch (InstanceAlreadyExistsException iaee) - { - ManagementException me = new ManagementException(); - me.setMessage(INSTANCE_EXISTS, new Object[] {name}); - me.setRootCause(iaee); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(CREATE_ERR, new Object[] {name}); - me.setRootCause(mbe); - throw me; - } - catch (NotCompliantMBeanException ncmbe) - { - ManagementException me = new ManagementException(); - me.setMessage(NOT_COMPLIANT, new Object[] {className}); - me.setRootCause(ncmbe); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - } - - /** - * Registers a pre-existing object as an MBean with the MBean server. - * - * @param object The object to register as an MBean. - * @param objectName The object name for the MBean. - * @return An ObjectInstance containing the ObjectName and Java class name of the new MBean. - */ - public ObjectInstance registerMBean(Object object, String objectName) - { - javax.management.ObjectName name = null; - if (objectName != null) - name = validateObjectName(objectName); - try - { - return new ObjectInstance(server.registerMBean(object, name)); - } - catch (InstanceAlreadyExistsException iaee) - { - ManagementException me = new ManagementException(); - me.setMessage(INSTANCE_EXISTS, new Object[] {name}); - me.setRootCause(iaee); - throw me; - } - catch (NotCompliantMBeanException ncmbe) - { - ManagementException me = new ManagementException(); - me.setMessage(NOT_COMPLIANT, new Object[] {object.getClass().getName()}); - me.setRootCause(ncmbe); - throw me; - } - catch (MBeanRegistrationException mbre) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_PREREG_ERR, new Object[] {name}); - me.setRootCause(mbre); - throw me; - } - } - - /** - * Unregisters an MBean from the MBean server. - * - * @param objectName The object name of the MBean to unregister. - */ - public void unregisterMBean(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - server.unregisterMBean(name); - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - catch (MBeanRegistrationException mbre) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_PREDEREG_ERR, new Object[] {name}); - me.setRootCause(mbre); - throw me; - } - } - - /** - * Gets the ObjectInstance for the specified MBean registered with the - * MBean server. - * - * @param objectName The object name of the MBean. - * @return An ObjectInstance containing the ObjectName and Java class name of the MBean. - */ - public ObjectInstance getObjectInstance(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - return new ObjectInstance(server.getObjectInstance(name)); - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - } - - /** - * Gets MBeans controlled by the MBean server. This method allows the following to be obtained: - * All MBeans, or a set of MBeans specified by pattern matching on the ObjectName, or a specific - * MBean. - * <p> - * This method does not support a QueryExp argument for additional filtering of the queried set. - * </p> - * - * @param objectName The object name pattern identifying the MBeans to retrieve. - * @return A set of ObjectInstances for the selected MBeans. - */ - public ObjectInstance[] queryMBeans(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - Set result = server.queryMBeans(name, null); - int n = result.size(); - if (n > 0) - { - ObjectInstance[] toReturn = new ObjectInstance[n]; - int i = 0; - for (Iterator iter = result.iterator(); iter.hasNext();) - { - toReturn[i++] = new ObjectInstance((javax.management.ObjectInstance)iter.next()); - } - return toReturn; - } - else - { - return new ObjectInstance[0]; - } - } - - /** - * Gets the names of MBeans controlled by the MBean server. This method allows the following to be - * obtained: The names of all MBeans, the names of the set of MBeans matching the ObjectName pattern, - * a specific MBean name. - * <p> - * This method does not support a QueryExp argument for additional filtering of the queried set. - * </p> - * - * @param objectName The object name pattern identifying the MBean names to retrieve. - * @return A set of ObjectNames for the selected MBeans. - */ - public ObjectName[] queryNames(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - Set result = server.queryNames(name, null); - int n = result.size(); - if (n > 0) - { - ObjectName[] toReturn = new ObjectName[n]; - int i = 0; - for (Iterator iter = result.iterator(); iter.hasNext();) - { - toReturn[i++] = new ObjectName((javax.management.ObjectName)iter.next()); - } - return toReturn; - } - else - { - return new ObjectName[0]; - } - } - - /** - * Checks whether an MBean, identified by its object name, is already registered with the MBean server. - * - * @param objectName The object name of the MBean to be checked. - * @return True if the MBean is already registered in the MBean server, false otherwise. - */ - public boolean isRegistered(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - return server.isRegistered(name); - } - - /** - * Returns the total number of beans registered in the MBean server. - * - * @return The number of registered MBeans. - */ - public Integer getMBeanCount() - { - return server.getMBeanCount(); - } - - /** - * Gets the value of a specific attribute of a named MBean. The MBean is identified by its object name. - * - * @param objectName The object name of the MBean from which the attribute is to be retrieved. - * @param attribute The name of the attribute to be retrieved. - * @return The value of the retrieved attribute. - */ - public Object getAttribute(String objectName, String attribute) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - return server.getAttribute(name, attribute); - } - catch (AttributeNotFoundException anfe) - { - ManagementException me = new ManagementException(); - me.setMessage(ATTRIB_NOTFOUND, new Object[] {attribute, name}); - me.setRootCause(anfe); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(GETATTRIB_EXCEPTION, new Object[] {attribute, name}); - me.setRootCause(mbe); - throw me; - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(GETATTRIB_REFLECT_ERR, new Object[] {attribute, name}); - me.setRootCause(re); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - catch (RuntimeOperationsException roe) - { - ManagementException me = new ManagementException(); - me.setMessage(GETATTRIB_NULL_ARGUMENT); - me.setRootCause(roe); - throw me; - } - } - - /** - * Gets the values of several attributes of a named MBean. - * - * @param objectName The object name of the MBean to get attribute values from. - * @param attributes The names of the attributes to get values for. - * @return The attributes, each containing their name and value. - */ - public Attribute[] getAttributes(String objectName, String[] attributes) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - AttributeList result = server.getAttributes(name, attributes); - Attribute[] values = new Attribute[result.size()]; - for (int i = 0; i < result.size(); i++) - { - values[i] = new Attribute((javax.management.Attribute)result.get(i)); - } - return values; - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(GETATTRIBS_REFLECT_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - catch (RuntimeOperationsException roe) - { - ManagementException me = new ManagementException(); - me.setMessage(GETATTRIBS_NULL_ARGUMENT); - me.setRootCause(roe); - throw me; - } - } - - /** - * Sets the value of the attribute for the specified MBean. - * - * @param objectName The name of the MBean. - * @param attribute The attribute to set. - */ - public void setAttribute(String objectName, Attribute attribute) - { - javax.management.ObjectName name = validateObjectName(objectName); - javax.management.Attribute attrib = validateAttribute(attribute); - try - { - server.setAttribute(name, attrib); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(SETATTRIB_REFLECT_ERR, new Object[] {attrib.getName(), name}); - me.setRootCause(re); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - catch (AttributeNotFoundException anfe) - { - ManagementException me = new ManagementException(); - me.setMessage(ATTRIB_NOTFOUND, new Object[] {attrib.getName(), name}); - me.setRootCause(anfe); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(SETATTRIB_EXCEPTION, new Object[] {attrib.getName(), name}); - me.setRootCause(mbe); - throw me; - } - catch (InvalidAttributeValueException iave) - { - ManagementException me = new ManagementException(); - me.setMessage(INVALID_ATTRIB_VALUE, new Object[] {attrib.getValue(), attrib.getName(), name}); - me.setRootCause(iave); - throw me; - } - } - - /** - * Sets the values for several attributes of the specified MBean. - * - * @param objectName The object name for the MBean. - * @param attributes The attributes to set. - * @return The attributes that were set with their new values. - */ - public Attribute[] setAttributes(String objectName, Attribute[] attributes) - { - javax.management.ObjectName name = validateObjectName(objectName); - AttributeList attribList = new AttributeList(); - for (int i = 0; i < attributes.length; i++) - { - attribList.add(attributes[i].toAttribute()); - } - try - { - AttributeList result = server.setAttributes(name, attribList); - Attribute[] values = new Attribute[result.size()]; - for (int i = 0; i < result.size(); i++) - { - values[i] = new Attribute((javax.management.Attribute)result.get(i)); - } - return values; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {name}); - me.setRootCause(infe); - throw me; - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(SETATTRIBS_REFLECT_ERR, new Object[] {name}); - me.setRootCause(re); - throw me; - } - } - - /** - * Invokes an operation on an MBean. - * - * @param objectName The object name of the MBean to invoke the operation on. - * @param operationName The operation to invoke. - * @param params The parameters for the operation invocation. - * @param signature The parameter signature for the operation. - * @return The object returned by the operation invocation. - */ - public Object invoke(String objectName, String operationName, Object[] params, String[] signature) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - return server.invoke(name, operationName, params, signature); - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(INVOKE_REFLECT_ERR, new Object[] {operationName, objectName}); - me.setRootCause(re); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName}); - me.setRootCause(infe); - throw me; - } - catch (MBeanException mbe) - { - ManagementException me = new ManagementException(); - me.setMessage(INVOKE_ERR, new Object[] {operationName, objectName}); - me.setRootCause(mbe); - throw me; - } - } - - /** - * Returns the default domain used for naming MBeans. - * - * @return The default domain. - */ - public String getDefaultDomain() - { - return server.getDefaultDomain(); - } - - /** - * This method discovers the attributes and operations that an MBean exposes for management - * by a Flash client. - * - * @param objectName The name of the MBean to get metadata for. - * @return An MBeanInfo instance that describes the MBean. - */ - public flex.management.jmx.MBeanInfo getMBeanInfo(String objectName) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - return new MBeanInfo(server.getMBeanInfo(name)); - } - catch (IntrospectionException ie) - { - ManagementException me = new ManagementException(); - me.setMessage(GETINFO_INTROSPECTION_ERR, new Object[] {objectName}); - me.setRootCause(ie); - throw me; - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName}); - me.setRootCause(infe); - throw me; - } - catch (ReflectionException re) - { - ManagementException me = new ManagementException(); - me.setMessage(GETINFO_REFLECT_ERR, new Object[] {objectName}); - me.setRootCause(re); - throw me; - } - } - - - /** - * Returns true if the specified MBean is an instance of the specified class; otherwise false. - * - * @param objectName The object name of the MBean. - * @param className The name of the class. - * @return true if the specified MBean is an instance of the specified class; otherwise false. - */ - public boolean isInstanceOf(String objectName, String className) - { - javax.management.ObjectName name = validateObjectName(objectName); - try - { - return server.isInstanceOf(name, className); - } - catch (InstanceNotFoundException infe) - { - ManagementException me = new ManagementException(); - me.setMessage(MBEAN_NOTFOUND, new Object[] {objectName}); - me.setRootCause(infe); - throw me; - } - } - - //////////////////////////////// - // - // Additive Flex-specific API - // - //////////////////////////////// - - /** - * Returns all the object names for Flex related MBeans. - * - * @return The object names for all Flex related MBeans. - */ - public ObjectName[] getFlexMBeanObjectNames() - { - javax.management.ObjectName pattern = validateObjectName(BaseControl.DOMAIN_PREFIX + "*:*"); - Set result = server.queryNames(pattern, null); - ObjectName[] names = new ObjectName[result.size()]; - int i = 0; - for (Iterator iter = result.iterator(); iter.hasNext(); ) - { - names[i++] = new ObjectName((javax.management.ObjectName)iter.next()); - } - return names; - } - - /** - * Returns the number of narrowed Flex MBeans registered in the MBean server. - * - * @return The number of narrowed Flex MBeans registered in the MBean server. - */ - public Integer getFlexMBeanCount() - { - return new Integer(getFlexMBeanObjectNames().length); - } - - /** - * Returns the narrowed list of Flex domains in which any MBean is currently registered. - * The domains are returned in naturally sorted order. - * - * @return The narrowed list of Flex domains in which any MBean is currently registered. - */ - public String[] getFlexDomains() - { - ObjectName[] names = getFlexMBeanObjectNames(); - Set domains = new TreeSet(); - String name; - String domain; - if (names.length > 0) - { - for (int i = 0; i < names.length; ++i) - { - name = names[i].canonicalName; - domain = name.substring(0, name.indexOf(':')); - if (!domains.contains(domain)) - { - domains.add(domain); - } - } - } - return (String[])domains.toArray(new String[domains.size()]); - } - - /////////////////////////////// - // - // Internal helper methods - // - /////////////////////////////// - - /** - * Helper method to validate that we have a well-formed ObjectName string. - * - * @param objectName The object name to validate. - * @return The valid ObjectName. - */ - private javax.management.ObjectName validateObjectName(String objectName) - { - try - { - return new javax.management.ObjectName(objectName); - } - catch (MalformedObjectNameException mone) - { - ManagementException me = new ManagementException(); - me.setMessage(MALFORMED_OBJECTNAME, new Object[] {objectName}); - throw me; - } - } - - /** - * Helper method to validate that we have a well-formed Attribute. - * - * @param attribute The attribute to validate. - * @return The valid Attribute. - */ - private javax.management.Attribute validateAttribute(Attribute attribute) - { - return attribute.toAttribute(); - } - -}
http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/jmx/ObjectInstance.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/jmx/ObjectInstance.java b/core/src/flex/management/jmx/ObjectInstance.java deleted file mode 100644 index 8985ee0..0000000 --- a/core/src/flex/management/jmx/ObjectInstance.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.jmx; - -import javax.management.MalformedObjectNameException; - -/** - * Remotable ObjectInstance representation that complies with Flash serialization requirements. - */ -public class ObjectInstance -{ - /** - * The object name part of the <code>ObjectInstance</code>. - */ - public ObjectName objectName; - - /** - * The class name part of the <code>ObjectInstance</code>. - */ - public String className; - - /** - * Constructs an empty <code>ObjectInstance</code> instance. - * - */ - public ObjectInstance() - {} - - /** - * Constructs a <code>ObjectInstance</code> instance based upon a - * <code>javax.management.ObjectInstance</code> instance. - * - * @param objectInstance The JMX <code>ObjectInstance</code> instance to base this instance on. - */ - public ObjectInstance(javax.management.ObjectInstance objectInstance) - { - objectName = new ObjectName(objectInstance.getObjectName()); - className = objectInstance.getClassName(); - } - - /** - * Utility method to convert this <code>ObjectInstance</code> to a - * <code>javax.management.ObjectInstance</code> instance. - * - * @return A JMX <code>ObjectInstance</code> based upon this instance. - * @throws MalformedObjectNameException an exception - */ - public javax.management.ObjectInstance toObjectInstance() throws MalformedObjectNameException - { - return new javax.management.ObjectInstance(objectName.toObjectName(), className); - } -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/jmx/ObjectName.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/jmx/ObjectName.java b/core/src/flex/management/jmx/ObjectName.java deleted file mode 100644 index b55ebb4..0000000 --- a/core/src/flex/management/jmx/ObjectName.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.jmx; - -import java.util.Hashtable; -import javax.management.MalformedObjectNameException; - -/** - * Remotable ObjectName representation that complies with Flash serialization requirements. - * This class is JMX 1.1 compliant. - */ -public class ObjectName -{ - /** - * String representation of the list of key properties sorted in lexical order. - */ - public String canonicalKeyPropertyListString; - - /** - * Canonical form of the name with properties sorted in lexical order. - */ - public String canonicalName; - - /** - * The domain part of the object name. - */ - public String domain; - - /** - * A Hashtable containing key-property pairs. - */ - public Hashtable keyPropertyList; - - /** - * String representation of the key properties. - */ - public String keyPropertyListString; - - /** - * Indicates whether the object name is a pattern. - */ - public boolean pattern; - - /** - * Indicates whether the object name is a pattern on key properties. - */ - public boolean propertyPattern; - - /** - * Constructs an empty <code>ObjectName</code> instance. - */ - public ObjectName() - {} - - /** - * Constructs a <code>ObjectName</code> instance based upon a - * <code>javax.management.ObjectName</code> instance. - * - * @param objectName The JMX <code>ObjectName</code> instance to base this instance on. - */ - public ObjectName(javax.management.ObjectName objectName) - { - canonicalKeyPropertyListString = objectName.getCanonicalKeyPropertyListString(); - canonicalName = objectName.getCanonicalName(); - domain = objectName.getDomain(); - keyPropertyList = objectName.getKeyPropertyList(); - keyPropertyListString = objectName.getKeyPropertyListString(); - pattern = objectName.isPattern(); - propertyPattern = objectName.isPropertyPattern(); - } - - /** - * Utility method to convert this <code>ObjectName</code> to a - * <code>javax.management.ObjectName</code> instance. - * - * @return A JMX <code>ObjectName</code> based upon this instance. - * @throws MalformedObjectNameException an exception - */ - public javax.management.ObjectName toObjectName() throws MalformedObjectNameException - { - return new javax.management.ObjectName(domain, keyPropertyList); - } - -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/jmx/package-info.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/jmx/package-info.java b/core/src/flex/management/jmx/package-info.java deleted file mode 100644 index fa47d96..0000000 --- a/core/src/flex/management/jmx/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.jmx; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/package-info.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/package-info.java b/core/src/flex/management/package-info.java deleted file mode 100644 index 46ac51b..0000000 --- a/core/src/flex/management/package-info.java +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java b/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java deleted file mode 100644 index f16dbce..0000000 --- a/core/src/flex/management/runtime/AdminConsoleDisplayRegistrar.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.HashMap; - -import flex.management.BaseControl; - -/** - * - */ -public class AdminConsoleDisplayRegistrar extends BaseControl implements AdminConsoleDisplayRegistrarMBean -{ - public static final String ID = "AdminConsoleDisplay"; - - private HashMap registeredExposedObjects; - - public AdminConsoleDisplayRegistrar(BaseControl parent) - { - super(parent); - registeredExposedObjects = new HashMap(); - register(); - } - - public void registerObject(int type, String beanName, String propertyName) - { - Object objects = registeredExposedObjects.get(new Integer(type)); - if (objects != null) - { - ((ArrayList)objects).add(beanName + ":" + propertyName); - } - else - { - if (type < 1) - return; - - objects = new ArrayList(); - ((ArrayList)objects).add(beanName + ":" + propertyName); - registeredExposedObjects.put(new Integer(type), objects); - } - } - - public void registerObjects(int type, String beanName, String[] propertyNames) - { - for (int i = 0; i < propertyNames.length; i++) - { - registerObject(type, beanName, propertyNames[i]); - } - } - - public void registerObjects(int[] types, String beanName, String[] propertyNames) - { - for (int j = 0; j < types.length; j++) - { - registerObjects(types[j], beanName, propertyNames); - } - } - - public Integer[] getSupportedTypes() throws IOException - { - Object[] array = registeredExposedObjects.keySet().toArray(); - Integer[] types = new Integer[array.length]; - for (int i = 0; i < array.length; i++) - { - types[i] = (Integer)array[i]; - } - return types; - } - - public String[] listForType(int type) throws IOException - { - Object list = registeredExposedObjects.get(new Integer(type)); - - return (list != null) ? (String[]) ((ArrayList)list).toArray(new String[0]) : new String[0]; - } - - public String getId() - { - return ID; - } - - public String getType() - { - return ID; - } - - -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java b/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java deleted file mode 100644 index be7b36a..0000000 --- a/core/src/flex/management/runtime/AdminConsoleDisplayRegistrarMBean.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime; - -import java.io.IOException; - -import flex.management.BaseControlMBean; - -/** - * - */ -public interface AdminConsoleDisplayRegistrarMBean extends BaseControlMBean -{ - - Integer[] getSupportedTypes() throws IOException; - - String[] listForType(int type) throws IOException; - -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/AdminConsoleTypes.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/AdminConsoleTypes.java b/core/src/flex/management/runtime/AdminConsoleTypes.java deleted file mode 100644 index a63085d..0000000 --- a/core/src/flex/management/runtime/AdminConsoleTypes.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime; - -/** - * The interface defines a number of constants for admin console types. - */ -public interface AdminConsoleTypes -{ - static final int GENERAL_SERVER = 1; - static final int GENERAL_POLLABLE = 2; - static final int GENERAL_OPERATION = 3; - - static final int GRAPH_BY_POLL_INTERVAL = 50; - - static final int ENDPOINT_SCALAR = 100; - static final int ENDPOINT_POLLABLE = 101; - - static final int DESTINATION_GENERAL = 150; - static final int DESTINATION_POLLABLE = 151; -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/messaging/DestinationControl.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/messaging/DestinationControl.java b/core/src/flex/management/runtime/messaging/DestinationControl.java deleted file mode 100644 index 2f40783..0000000 --- a/core/src/flex/management/runtime/messaging/DestinationControl.java +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime.messaging; - -import java.util.Date; - -import flex.management.BaseControl; -import flex.management.runtime.messaging.services.ServiceControl; -import flex.messaging.Destination; -import flex.messaging.services.ServiceAdapter; - -import javax.management.ObjectName; - -/** - * The <code>DestinationControl</code> class is the MBean implementation for - * monitoring and managing a <code>Destination</code> at runtime. - */ -public abstract class DestinationControl extends BaseControl implements - DestinationControlMBean -{ - protected Destination destination; - private ObjectName adapter; - - /** - * Constructs a new <code>DestinationControl</code> instance. - * - * @param destination The <code>Destination</code> managed by this MBean. - * @param parent The parent MBean in the management hierarchy. - */ - public DestinationControl(Destination destination, BaseControl parent) - { - super(parent); - this.destination = destination; - } - - /* - * (non-Javadoc) - * @see flex.management.BaseControlMBean#getId() - */ - public String getId() - { - return destination.getId(); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.DestinationControlMBean#getAdapter() - */ - public ObjectName getAdapter() - { - return adapter; - } - - /** - * Sets the <code>ObjectName</code> for the adapter associated with the managed destination. - * - * @param value The <code>ObjectName</code> for the adapter. - */ - public void setAdapter(ObjectName value) - { - adapter = value; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.DestinationControlMBean#isRunning() - */ - public Boolean isRunning() - { - return Boolean.valueOf(destination.isStarted()); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.DestinationControlMBean#getStartTimestamp() - */ - public Date getStartTimestamp() - { - return startTimestamp; - } - - /* - * (non-Javadoc) - * @see javax.management.MBeanRegistration#preDeregister() - */ - public void preDeregister() throws Exception - { - ServiceControl parent = (ServiceControl)getParentControl(); - parent.removeDestination(getObjectName()); - - // Unregister adapter of the destination - ServiceAdapter child = destination.getAdapter(); - if (child.getControl() != null) - { - child.getControl().unregister(); - child.setControl(null); - child.setManaged(false); - } - - super.preDeregister(); - } - -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/messaging/DestinationControlMBean.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/messaging/DestinationControlMBean.java b/core/src/flex/management/runtime/messaging/DestinationControlMBean.java deleted file mode 100644 index e77ac6d..0000000 --- a/core/src/flex/management/runtime/messaging/DestinationControlMBean.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime.messaging; - -import flex.management.BaseControlMBean; - -import java.io.IOException; -import java.util.Date; - -import javax.management.ObjectName; - -/** - * Defines the runtime monitoring and management interface for managed destinations. - */ -public interface DestinationControlMBean extends BaseControlMBean -{ - /** - * Returns the <code>ObjectName</code> for the adapter associated with this - * managed destination. - * - * @return The <code>ObjectName</code> for the adapter. - * @throws IOException Throws IOException. - */ - ObjectName getAdapter() throws IOException;; - - /** - * Returns <code>true</code> if the <code>Destination</code> is running. - * - * @return <code>true</code> if the <code>Destination</code> is running. - * @throws IOException Throws IOException. - */ - Boolean isRunning() throws IOException; - - /** - * Returns the start timestamp for the <code>Destination</code>. - * - * @return The start timestamp for the <code>Destination</code>. - * @throws IOException Throws IOException. - */ - Date getStartTimestamp() throws IOException; -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/messaging/MessageBrokerControl.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/messaging/MessageBrokerControl.java b/core/src/flex/management/runtime/messaging/MessageBrokerControl.java deleted file mode 100644 index 84359c3..0000000 --- a/core/src/flex/management/runtime/messaging/MessageBrokerControl.java +++ /dev/null @@ -1,294 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime.messaging; - -import flex.management.BaseControl; -import flex.management.runtime.AdminConsoleDisplayRegistrar; -import flex.management.runtime.AdminConsoleTypes; -import flex.messaging.MessageBroker; -import flex.messaging.endpoints.AMFEndpoint; -import flex.messaging.endpoints.AbstractEndpoint; -import flex.messaging.endpoints.Endpoint; -import flex.messaging.endpoints.HTTPEndpoint; -import flex.messaging.endpoints.StreamingAMFEndpoint; -import flex.messaging.endpoints.StreamingHTTPEndpoint; - -import java.io.IOException; -import java.util.Date; -import java.util.List; -import java.util.ArrayList; - -import javax.management.ObjectName; - -/** - * The <code>MessageBrokerControl</code> class is the MBean implemenation for monitoring - * and managing a <code>MessageBroker</code> at runtime. - */ -public class MessageBrokerControl extends BaseControl implements MessageBrokerControlMBean -{ - private static final Object classMutex = new Object(); - private static final String TYPE = "MessageBroker"; - private static int instanceCount = 0; - private String id; - private MessageBroker broker; - private List endpointNames; - private List amfEndpoints; - private List httpEndpoints; - private List enterpriseEndpoints; - private List streamingAmfEndpoints; - private List streamingHttpEndpoints; - private List services; - - /** - * Constructs a new <code>MessageBrokerControl</code> instance, assigning its - * backing <code>MessageBroker</code>. - * - * @param broker The <code>MessageBroker</code> managed by this MBean. - */ - public MessageBrokerControl(MessageBroker broker) - { - super(null); - this.broker = broker; - endpointNames = new ArrayList(); - amfEndpoints = new ArrayList(); - httpEndpoints = new ArrayList(); - enterpriseEndpoints = new ArrayList(); - streamingAmfEndpoints = new ArrayList(); - streamingHttpEndpoints = new ArrayList(); - services = new ArrayList(); - synchronized (classMutex) - { - id = TYPE + ++instanceCount; - } - - setRegistrar(new AdminConsoleDisplayRegistrar(this)); - } - - protected void onRegistrationComplete() - { - String name = this.getObjectName().getCanonicalName(); - getRegistrar().registerObject(AdminConsoleTypes.GENERAL_POLLABLE, name, "FlexSessionCount"); - getRegistrar().registerObjects(new int[] {AdminConsoleTypes.GENERAL_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL }, - name, new String[] {"AMFThroughput", "HTTPThroughput", "EnterpriseThroughput"}); - - getRegistrar().registerObject(AdminConsoleTypes.GENERAL_SERVER, name, "MaxFlexSessionsInCurrentHour"); - } - - /* - * (non-Javadoc) - * @see flex.management.BaseControlMBean#getId() - */ - public String getId() - { - return id; - } - - /* - * (non-Javadoc) - * @see flex.management.BaseControlMBean#getType() - */ - public String getType() - { - return TYPE; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#isRunning() - */ - public Boolean isRunning() - { - return Boolean.valueOf(broker.isStarted()); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#getStartTimestamp() - */ - public Date getStartTimestamp() - { - return startTimestamp; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#getEndpoints() - */ - public ObjectName[] getEndpoints() throws IOException - { - int size = endpointNames.size(); - ObjectName[] endpointNameObjects = new ObjectName[size]; - for (int i = 0; i < size; ++i) - { - endpointNameObjects[i] = (ObjectName)endpointNames.get(i); - } - return endpointNameObjects; - } - - /** - * Adds an <code>Endpoint</code> for an endpoint registered with the backing <code>MessageBroker</code>. - * - * @param value The endpoint <code>Endpoint</code>. - */ - public void addEndpoint(Endpoint value) - { - if (value instanceof AMFEndpoint) - amfEndpoints.add(value); - else if (value instanceof HTTPEndpoint) - httpEndpoints.add(value); - else if (value instanceof StreamingAMFEndpoint) - streamingAmfEndpoints.add(value); - else if (value instanceof StreamingHTTPEndpoint) - streamingHttpEndpoints.add(value); - else - enterpriseEndpoints.add(value); - - endpointNames.add(value.getControl().getObjectName()); - } - - /** - * Removes an <code>ObjectName</code> for an endpoint registered with the backing <code>MessageBroker</code>. - * - * @param value The endpoint <code>ObjectName</code>. - */ - public void removeEndpoint(ObjectName value) - { - endpointNames.remove(value); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#getServices() - */ - public ObjectName[] getServices() throws IOException - { - int size = services.size(); - ObjectName[] serviceNames = new ObjectName[size]; - for (int i = 0; i < size; ++i) - { - serviceNames[i] = (ObjectName)services.get(i); - } - return serviceNames; - } - - /** - * Adds an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>. - * - * @param value The service <code>ObjectName</code>. - */ - public void addService(ObjectName value) - { - services.add(value); - } - - /** - * Removes an <code>ObjectName</code> for a service registered with the backing <code>MessageBroker</code>. - * - * @param value The service <code>ObjectName</code>. - */ - public void removeService(ObjectName value) - { - services.remove(value); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#getFlexSessionCount() - */ - public Integer getFlexSessionCount() - { - return broker.getFlexSessionManager().getFlexSessionCount(); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageBrokerControlMBean#getMaxFlexSessionsInCurrentHour() - */ - public Integer getMaxFlexSessionsInCurrentHour() - { - return broker.getFlexSessionManager().getMaxFlexSessionsInCurrentHour(); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPConnectionCount() - */ - public Integer getEnterpriseConnectionCount() throws IOException - { - int connections = 0; - /* - for (int i = 0; i < rtmpEndpoints.size(); i++) - { - connections += (((RTMPEndpoint)rtmpEndpoints.get(i)).getConnectionCount()); - } - */ - return new Integer(connections); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getAMFThroughput() - */ - public Long getAMFThroughput() throws IOException - { - return new Long(calculateEndpointThroughput(amfEndpoints)); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getHTTPThroughput() - */ - public Long getHTTPThroughput() throws IOException - { - return new Long(calculateEndpointThroughput(httpEndpoints)); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getRTMPThroughput() - */ - public Long getEnterpriseThroughput() throws IOException - { - return new Long(calculateEndpointThroughput(enterpriseEndpoints)); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingAMFThroughput() - */ - public Long getStreamingAMFThroughput() throws IOException - { - return new Long(calculateEndpointThroughput(streamingAmfEndpoints)); - } - - /* (non-Javadoc) - * @see flex.management.runtime.messaging.MessageBrokerControlMBean#getStreamingHTTPThroughput() - */ - public Long getStreamingHTTPThroughput() throws IOException - { - return new Long(calculateEndpointThroughput(streamingHttpEndpoints)); - } - - private long calculateEndpointThroughput(List endpoints) - { - long throughput = 0; - - for (int i = 0; i < endpoints.size(); i++) - { - // This method shouldn't be used with Lists containing objects that are not AbstractEndpoints - if (endpoints.get(i) instanceof AbstractEndpoint) - throughput += ((AbstractEndpoint)endpoints.get(i)).getThroughput(); - } - - return throughput; - } -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java b/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java deleted file mode 100644 index 7270133..0000000 --- a/core/src/flex/management/runtime/messaging/MessageBrokerControlMBean.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime.messaging; - -import flex.management.BaseControlMBean; - -import java.io.IOException; -import java.util.Date; -import javax.management.ObjectName; - -/** - * Defines the runtime monitoring and management interface for managed <code>MessageBroker</code>s. - */ -public interface MessageBrokerControlMBean extends BaseControlMBean -{ - /** - * Returns <code>true</code> if the <code>MessageBroker</code> is running. - * - * @return <code>true</code> if the <code>MessageBroker</code> is running. - * @throws IOException Throws IOException. - */ - Boolean isRunning() throws IOException; - - /** - * Returns the start timestamp for the <code>MessageBroker</code>. - * - * @return The start timestamp for the <code>MessageBroker</code>. - * @throws IOException Throws IOException. - */ - Date getStartTimestamp() throws IOException; - - /** - * Returns the <code>ObjectName</code>s for endpoints that are registered with the - * managed <code>MessageBroker</code>. - * - * @return The <code>ObjectName</code>s for endpoints registered with the managed <code>MessageBroker</code>. - * @throws IOException Throws IOException. - */ - ObjectName[] getEndpoints() throws IOException; - - /** - * Returns the <code>ObjectName</code>s for services that are registered with the - * managed <code>MessageBroker</code>. - * - * @return The <code>ObjectName</code>s for services registered with the managed <code>MessageBroker</code>. - * @throws IOException Throws IOException. - */ - ObjectName[] getServices() throws IOException; - - /** - * Returns Flex session count for the <code>MessageBroker</code>. - * - * @return Flex session count for the <code>MessageBroker</code>. - * @throws IOException Throws IOException. - */ - Integer getFlexSessionCount() throws IOException; - - /** - * Returns the maximum concurrent Flex session count for the - * <code>MessageBroker</code> in the current hour. - * - * @return The maximum concurrent Flex session count for the - * <code>MessageBroker</code> over the course of the last hour. - * @throws IOException Throws IOException. - */ - Integer getMaxFlexSessionsInCurrentHour() throws IOException; - - /** - * Returns the number of Enterprise Connections across all - * Enterprise Endpoints. - * - * @return The number of Enterprise Connections - * @throws IOException Throws IOException. - */ - Integer getEnterpriseConnectionCount() throws IOException; - - /** - * Returns the total number of bytes passing through all AMF endpoints. - * - * @return The total number of bytes passing through all AMF endpoints. - * @throws IOException Throws IOException. - */ - Long getAMFThroughput() throws IOException; - - /** - * Returns the total number of bytes passing through all HTTP endpoints. - * - * @return The total number of bytes passing through all HTTP endpoints. - * @throws IOException Throws IOException. - */ - Long getHTTPThroughput() throws IOException; - - /** - * Returns the total number of bytes passing through all Enterprise endpoints. - * - * @return The total number of bytes passing through all Enterprise endpoints. - * @throws IOException Throws IOException. - */ - Long getEnterpriseThroughput() throws IOException; - - /** - * Returns the total number of bytes passing through all streaming AMF endpoints. - * - * @return The total number of bytes passing through all streaming AMF endpoints. - * @throws IOException Throws IOException. - */ - Long getStreamingAMFThroughput() throws IOException; - - /** - * Returns the total number of bytes passing through all streaming HTTP endpoints. - * - * @return The total number of bytes passing through all streaming HTTP endpoints. - * @throws IOException Throws IOException. - */ - Long getStreamingHTTPThroughput() throws IOException; -} http://git-wip-us.apache.org/repos/asf/flex-blazeds/blob/8315f8fa/core/src/flex/management/runtime/messaging/MessageDestinationControl.java ---------------------------------------------------------------------- diff --git a/core/src/flex/management/runtime/messaging/MessageDestinationControl.java b/core/src/flex/management/runtime/messaging/MessageDestinationControl.java deleted file mode 100644 index 9dc7411..0000000 --- a/core/src/flex/management/runtime/messaging/MessageDestinationControl.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You 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 flex.management.runtime.messaging; - -import java.util.Date; -import java.util.concurrent.atomic.AtomicInteger; - -import flex.management.BaseControl; -import flex.management.runtime.AdminConsoleTypes; -import flex.messaging.Destination; - -import javax.management.ObjectName; - -/** - * The <code>MessageDestinationControl</code> class is the MBean implementation for - * monitoring and managing a <code>MessageDestination</code> at runtime. - */ -public class MessageDestinationControl extends DestinationControl implements - MessageDestinationControlMBean -{ - private static final String TYPE = "MessageDestination"; - private ObjectName messageCache; - private ObjectName throttleManager; - private ObjectName subscriptionManager; - - private AtomicInteger serviceMessageCount = new AtomicInteger(0); - private Date lastServiceMessageTimestamp; - private long serviceMessageStart; - private AtomicInteger serviceCommandCount = new AtomicInteger(0); - private Date lastServiceCommandTimestamp; - private long serviceCommandStart; - private AtomicInteger serviceMessageFromAdapterCount = new AtomicInteger(0); - private Date lastServiceMessageFromAdapterTimestamp; - private long serviceMessageFromAdapterStart; - /** - * Constructs a new <code>MessageDestinationControl</code> instance. - * - * @param destination The destination managed by this MBean. - * @param parent The parent MBean in the management hierarchy. - */ - public MessageDestinationControl(Destination destination, BaseControl parent) - { - super(destination, parent); - serviceMessageStart = System.currentTimeMillis(); - serviceCommandStart = serviceMessageStart; - serviceMessageFromAdapterStart = serviceMessageStart; - } - - protected void onRegistrationComplete() - { - String name = this.getObjectName().getCanonicalName(); - - String[] pollablePerInterval = { "ServiceCommandCount", "ServiceMessageCount", - "ServiceMessageFromAdapterCount" }; - String[] pollableGeneral = { "ServiceCommandFrequency", "ServiceMessageFrequency", - "ServiceMessageFromAdapterFrequency", "LastServiceCommandTimestamp", - "LastServiceMessageTimestamp", "LastServiceMessageFromAdapterTimestamp"}; - - getRegistrar().registerObjects( - new int[] {AdminConsoleTypes.DESTINATION_POLLABLE, AdminConsoleTypes.GRAPH_BY_POLL_INTERVAL}, - name, pollablePerInterval); - getRegistrar().registerObjects(AdminConsoleTypes.DESTINATION_POLLABLE, name, - pollableGeneral); - } - - /* - * (non-Javadoc) - * @see flex.management.BaseControlMBean#getType() - */ - public String getType() - { - return TYPE; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageDestinationControlMBean#getMessageCache() - */ - public ObjectName getMessageCache() - { - return messageCache; - } - - /** - * Sets the <code>ObjectName</code> for the message cache used by the managed destination. - * - * @param value The <code>ObjectName</code> for the message cache. - */ - public void setMessageCache(ObjectName value) - { - messageCache = value; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageDestinationControlMBean#getThrottleManager() - */ - public ObjectName getThrottleManager() - { - return throttleManager; - } - - /** - * Sets the <code>ObjectName</code> for the throttle manager used by the managed destination. - * - * @param value The <code>ObjectName</code> for the throttle manager. - */ - public void setThrottleManager(ObjectName value) - { - throttleManager = value; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.MessageDestinationControlMBean#getSubscriptionManager() - */ - public ObjectName getSubscriptionManager() - { - return subscriptionManager; - } - - /** - * Sets the <code>ObjectName</code> for the subscription manager used by the managed destination. - * - * @param value The <code>ObjectName</code> for the subscription manager. - */ - public void setSubscriptionManager(ObjectName value) - { - subscriptionManager = value; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageCount() - */ - public Integer getServiceMessageCount() - { - return Integer.valueOf(serviceMessageCount.get()); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageCount() - */ - public void resetServiceMessageCount() - { - serviceMessageStart = System.currentTimeMillis(); - serviceMessageCount = new AtomicInteger(0); - lastServiceMessageTimestamp = null; - } - - /** - * Increments the count of messages serviced. - */ - public void incrementServiceMessageCount() - { - serviceMessageCount.incrementAndGet(); - lastServiceMessageTimestamp = new Date(); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageTimestamp() - */ - public Date getLastServiceMessageTimestamp() - { - return lastServiceMessageTimestamp; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFrequency() - */ - public Double getServiceMessageFrequency() - { - if (serviceMessageCount.get() > 0) - { - double runtime = differenceInMinutes(serviceMessageStart, System.currentTimeMillis()); - return new Double(serviceMessageCount.get()/runtime); - } - else - { - return new Double(0); - } - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandCount() - */ - public Integer getServiceCommandCount() - { - return Integer.valueOf(serviceCommandCount.get()); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceCommandCount() - */ - public void resetServiceCommandCount() - { - serviceCommandStart = System.currentTimeMillis(); - serviceCommandCount = new AtomicInteger(0); - lastServiceCommandTimestamp = null; - } - - /** - * Increments the count of command messages serviced. - */ - public void incrementServiceCommandCount() - { - serviceCommandCount.incrementAndGet(); - lastServiceCommandTimestamp = new Date(); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceCommandTimestamp() - */ - public Date getLastServiceCommandTimestamp() - { - return lastServiceCommandTimestamp; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceCommandFrequency() - */ - public Double getServiceCommandFrequency() - { - if (serviceCommandCount.get() > 0) - { - double runtime = differenceInMinutes(serviceCommandStart, System.currentTimeMillis()); - return new Double(serviceCommandCount.get()/runtime); - } - else - { - return new Double(0); - } - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterCount() - */ - public Integer getServiceMessageFromAdapterCount() - { - return Integer.valueOf(serviceMessageFromAdapterCount.get()); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#resetServiceMessageFromAdapterCount() - */ - public void resetServiceMessageFromAdapterCount() - { - serviceMessageFromAdapterStart = System.currentTimeMillis(); - serviceMessageFromAdapterCount = new AtomicInteger(0); - lastServiceMessageFromAdapterTimestamp = null; - } - - /** - * Increments the count of messages from adapters processed. - */ - public void incrementServiceMessageFromAdapterCount() - { - serviceMessageFromAdapterCount.incrementAndGet(); - lastServiceMessageFromAdapterTimestamp = new Date(); - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getLastServiceMessageFromAdapterTimestamp() - */ - public Date getLastServiceMessageFromAdapterTimestamp() - { - return lastServiceMessageFromAdapterTimestamp; - } - - /* - * (non-Javadoc) - * @see flex.management.runtime.messaging.MessageDestinationControlMBean#getServiceMessageFromAdapterFrequency() - */ - public Double getServiceMessageFromAdapterFrequency() - { - if (serviceMessageFromAdapterCount.get() > 0) - { - double runtime = differenceInMinutes(serviceMessageFromAdapterStart, System.currentTimeMillis()); - return new Double(serviceMessageFromAdapterCount.get()/runtime); - } - else - { - return new Double(0); - } - } -}
