Mr Lind-fors back in full fors hope you pay your debt back to the group that brought you the book in the first place ;-)
marcf |-----Original Message----- |From: [EMAIL PROTECTED] |[mailto:[EMAIL PROTECTED]]On Behalf Of Juha |Lindfors |Sent: Sunday, December 02, 2001 9:21 PM |To: [EMAIL PROTECTED] |Subject: [JBoss-dev] CVS update: jmx/src/main/org/jboss/mx/server |MBeanServerImpl.java | | | User: juhalindfors | Date: 01/12/02 18:20:55 | | Added: src/main/org/jboss/mx/server MBeanServerImpl.java | Log: | | | Revision Changes Path | 1.1 |jmx/src/main/org/jboss/mx/server/MBeanServerImpl.java | | Index: MBeanServerImpl.java | =================================================================== | /* | * LGPL | */ | package org.jboss.mx.server; | | | import javax.management.InstanceNotFoundException; | import javax.management.ReflectionException; | import javax.management.MBeanException; | import javax.management.ObjectName; | import javax.management.ObjectInstance; | import javax.management.Attribute; | import javax.management.AttributeList; | import javax.management.MBeanServer; | import javax.management.NotificationListener; | import javax.management.NotificationFilter; | import javax.management.InstanceAlreadyExistsException; | import javax.management.NotCompliantMBeanException; | import javax.management.MBeanRegistrationException; | import javax.management.OperationsException; | import javax.management.IntrospectionException; | import javax.management.AttributeNotFoundException; | import javax.management.InvalidAttributeValueException; | import javax.management.ListenerNotFoundException; | import javax.management.RuntimeErrorException; | import javax.management.QueryExp; | import javax.management.MBeanInfo; | import javax.management.DynamicMBean; | import javax.management.loading.DefaultLoaderRepository; | | import java.lang.reflect.Constructor; | import java.lang.reflect.InvocationTargetException; | import java.io.ObjectInputStream; | | import org.jboss.mx.server.registry.BasicMBeanRegistry; | import org.jboss.mx.server.registry.MBeanRegistry; | import org.jboss.mx.server.registry.MBeanEntry; | | public class MBeanServerImpl implements MBeanServer { | | protected String defaultDomain = "DefaultDomain"; | protected MBeanRegistry registry = null; | | public MBeanServerImpl(String defaultDomain) { | this.defaultDomain = defaultDomain; | this.registry = new BasicMBeanRegistry(); | } | | | public Object instantiate(String className) throws |ReflectionException, MBeanException { | try { | Class clazz = DefaultLoaderRepository.loadClass(className); | return clazz.newInstance(); | } | catch (ClassNotFoundException e) { | throw new ReflectionException(e, "Class not found: " + |className); | } | catch (InstantiationException e) { | throw new ReflectionException(e, "Cannot instantiate |with no-args constructor: " + className); | } | catch (IllegalAccessException e) { | throw new ReflectionException(e, "Illegal access to |default constructor: " + className); | } | } | | public Object instantiate(String className, ObjectName loaderName) | throws ReflectionException, MBeanException, |InstanceNotFoundException { | return null; | } | | public Object instantiate(String className, Object[] params, |String[] signature) | throws ReflectionException, MBeanException { | try { | Class clazz = DefaultLoaderRepository.loadClass(className); | | Class[] sign = new Class[signature.length]; | for (int i = 0; i < signature.length; ++i) { | try { | sign[i] = DefaultLoaderRepository.loadClass(signature[i]); | } | catch (ClassNotFoundException e) { | throw new ReflectionException(e, "Constructor |parameter class not found: " + signature[i]); | } | } | | Constructor constructor = clazz.getConstructor(sign); | return constructor.newInstance(params); | } | catch (ClassNotFoundException e) { | throw new ReflectionException(e, "Class not found: " + |className); | } | catch (InstantiationException e) { | throw new ReflectionException(e, "Cannot instantiate |with specified constructor: " + className); | } | catch (IllegalAccessException e) { | throw new ReflectionException(e, "Illegal access to |specified constructor: " + className); | } | catch (NoSuchMethodException e) { | throw new ReflectionException(e, "Specified constructor |not found for class " + className); | } | catch (InvocationTargetException e) { | Throwable t = e.getTargetException(); | if (t instanceof Exception) | throw new MBeanException((Exception)t, "Constructor |has thrown an exception: " + t.getMessage()); | else | throw new RuntimeErrorException((Error)t, "Error |thrown from the specified constructor: " + t.getMessage()); | } | } | | | public java.lang.Object instantiate(String className, |ObjectName loaderName, Object[] params, String[] signature) | throws ReflectionException, MBeanException, |InstanceNotFoundException { | return null; | } | | public ObjectInstance createMBean(String className, ObjectName name) | throws ReflectionException, InstanceAlreadyExistsException, |MBeanRegistrationException, MBeanException, NotCompliantMBeanException { | Object mbean = instantiate(className); | registerMBean(mbean, name); | return new ObjectInstance(name, className); | } | | public ObjectInstance createMBean(String className, |ObjectName name, ObjectName loaderName) | throws ReflectionException, InstanceAlreadyExistsException, |MBeanRegistrationException, MBeanException, |NotCompliantMBeanException, InstanceNotFoundException { | Object mbean = instantiate(className, loaderName); | registerMBean(mbean, name); | return new ObjectInstance(name, className); | } | | public ObjectInstance createMBean(String className, |ObjectName name, Object[] params, String[] signature) | throws ReflectionException, InstanceAlreadyExistsException, |MBeanRegistrationException, MBeanException, NotCompliantMBeanException { | Object mbean = instantiate(className, params, signature); | registerMBean(mbean, name); | return new ObjectInstance(name, className); | } | | public ObjectInstance createMBean(String className, |ObjectName name, ObjectName loaderName, Object[] params, String[] |signature) | throws ReflectionException, InstanceAlreadyExistsException, |MBeanRegistrationException, MBeanException, |NotCompliantMBeanException, InstanceNotFoundException { | return null; | } | | | public ObjectInstance registerMBean(Object object, ObjectName name) | throws InstanceAlreadyExistsException, |MBeanRegistrationException, NotCompliantMBeanException { | if (isRegistered(name)) | throw new InstanceAlreadyExistsException("MBean " + |name + " already registered."); | | MBeanEntry entry = null; | | if (isStandardMBean(object)) | throw new Error("StandardMBean NYI"); | | else if (DynamicMBean.class.isAssignableFrom(object.getClass())) { | entry = new MBeanEntry(name, object); | registry.add(entry); | } | else | throw new NotCompliantMBeanException(object + " is not |compliant MBean."); | | return new ObjectInstance(name, entry.getClassName()); | } | | public void unregisterMBean(ObjectName name) throws |InstanceNotFoundException, MBeanRegistrationException { | registry.remove(name); | } | | public ObjectInstance getObjectInstance(ObjectName name) |throws InstanceNotFoundException { | if (!isRegistered(name)) | throw new InstanceNotFoundException(name + " not registered."); | | return null;//new ObjectInstance(name, |registry.get(name).getClassName()); | } | | public java.util.Set queryMBeans(ObjectName name, QueryExp query) { | return null; | } | | public java.util.Set queryNames(ObjectName name, QueryExp query) { | return null; | } | | public boolean isRegistered(ObjectName name) { | return registry.contains(name); | } | | public java.lang.Integer getMBeanCount() { | return new Integer(registry.getSize()); | } | | public Object getAttribute(ObjectName name, String attribute) | throws MBeanException, AttributeNotFoundException, |InstanceNotFoundException, ReflectionException { | //DynamicMBean mbean = registry.get(name).getInvocationInterface(); | return null;//mbean.getAttribute(attribute); | } | | public AttributeList getAttributes(ObjectName name, String[] |attributes) | throws InstanceNotFoundException, ReflectionException { | //DynamicMBean mbean = registry.get(name).getInvocationInterface(); | return null;//mbean.getAttributes(attributes); | } | | public void setAttribute(ObjectName name, Attribute attribute) | throws InstanceNotFoundException, AttributeNotFoundException, |InvalidAttributeValueException, MBeanException, ReflectionException { | //DynamicMBean mbean = registry.get(name).getInvocationInterface(); | //mbean.setAttribute(attribute); | } | | public AttributeList setAttributes(ObjectName name, |AttributeList attributes) | throws InstanceNotFoundException, ReflectionException { | //DynamicMBean mbean = registry.get(name).getInvocationInterface(); | return null;//mbean.setAttributes(attributes); | } | | public Object invoke(ObjectName name, String operationName, |Object[] params, String[] signature) | throws InstanceNotFoundException, MBeanException, |ReflectionException { | DynamicMBean mbean = registry.get(name).getInvocationInterface(); | return mbean.invoke(operationName, params, signature); | } | | public String getDefaultDomain() { | return defaultDomain; | } | | public void addNotificationListener(ObjectName name, |NotificationListener listener, NotificationFilter filter, Object |handback) throws InstanceNotFoundException { | throw new Error("NYI"); | } | | public void addNotificationListener(ObjectName name, |ObjectName listener, NotificationFilter filter, Object handback) |throws InstanceNotFoundException { | throw new Error("NYI"); | } | | public void removeNotificationListener(ObjectName name, |NotificationListener listener) | throws InstanceNotFoundException, ListenerNotFoundException { | throw new Error("NYI"); | } | | public void removeNotificationListener(ObjectName name, |ObjectName listener) | throws InstanceNotFoundException, ListenerNotFoundException { | throw new Error("NYI"); | } | | public MBeanInfo getMBeanInfo(ObjectName name) throws |InstanceNotFoundException, IntrospectionException, ReflectionException { | return |null;//registry.get(name).getInvocationInterface().getMBeanInfo(); | } | | public boolean isInstanceOf(ObjectName name, java.lang.String |className) throws InstanceNotFoundException { | throw new Error("NYI"); | } | | public ObjectInputStream deserialize(ObjectName name, byte[] |data) throws InstanceNotFoundException, OperationsException { | | return null; | } | | public ObjectInputStream deserialize(String className, byte[] |data) throws OperationsException, ReflectionException { | return null; | | } | | | public ObjectInputStream deserialize(String className, |ObjectName loaderName, byte[] data) | throws InstanceNotFoundException, OperationsException, |ReflectionException { | return null; | } | | | | protected boolean isStandardMBean(Object object) { | | return false; | } | | } | | | | | |_______________________________________________ |Jboss-development mailing list |[EMAIL PROTECTED] |https://lists.sourceforge.net/lists/listinfo/jboss-development _______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development