001: /*
002: * Copyright (C) The MX4J Contributors.
003: * All rights reserved.
004: *
005: * This software is distributed under the terms of the MX4J License version 1.0.
006: * See the terms of the MX4J License in the documentation provided with this software.
007: */
008:
009: package javax.management;
010:
011: import java.io.ObjectInputStream;
012: import java.util.Set;
013: import javax.management.loading.ClassLoaderRepository;
014:
015: /**
016: * A local client can create, register, unregister and access registered MBeans by means of this interface, that is
017: * the core component of JMX.
018: * An implementation of this interface can only be obtained from {@link MBeanServerFactory}.
019: * Almost all methods require an {@link MBeanPermission} to be invoked under SecurityManager.
020: *
021: * @version $Revision: 1.8 $
022: */
023: public interface MBeanServer extends MBeanServerConnection {
024: public void addNotificationListener(ObjectName observed,
025: NotificationListener listener, NotificationFilter filter,
026: Object handback) throws InstanceNotFoundException;
027:
028: public void addNotificationListener(ObjectName observed,
029: ObjectName listener, NotificationFilter filter,
030: Object handback) throws InstanceNotFoundException;
031:
032: public void removeNotificationListener(ObjectName observed,
033: ObjectName listener) throws InstanceNotFoundException,
034: ListenerNotFoundException;
035:
036: public void removeNotificationListener(ObjectName observed,
037: NotificationListener listener)
038: throws InstanceNotFoundException, ListenerNotFoundException;
039:
040: public void removeNotificationListener(ObjectName observed,
041: ObjectName listener, NotificationFilter filter,
042: Object handback) throws InstanceNotFoundException,
043: ListenerNotFoundException;
044:
045: public void removeNotificationListener(ObjectName observed,
046: NotificationListener listener, NotificationFilter filter,
047: Object handback) throws InstanceNotFoundException,
048: ListenerNotFoundException;
049:
050: public MBeanInfo getMBeanInfo(ObjectName objectName)
051: throws InstanceNotFoundException, IntrospectionException,
052: ReflectionException;
053:
054: public boolean isInstanceOf(ObjectName objectName, String className)
055: throws InstanceNotFoundException;
056:
057: public String[] getDomains();
058:
059: public String getDefaultDomain();
060:
061: public ObjectInstance createMBean(String className,
062: ObjectName objectName) throws ReflectionException,
063: InstanceAlreadyExistsException, MBeanRegistrationException,
064: MBeanException, NotCompliantMBeanException;
065:
066: public ObjectInstance createMBean(String className,
067: ObjectName objectName, ObjectName loaderName)
068: throws ReflectionException, InstanceAlreadyExistsException,
069: MBeanRegistrationException, MBeanException,
070: NotCompliantMBeanException, InstanceNotFoundException;
071:
072: public ObjectInstance createMBean(String className,
073: ObjectName objectName, Object[] args, String[] parameters)
074: throws ReflectionException, InstanceAlreadyExistsException,
075: MBeanRegistrationException, MBeanException,
076: NotCompliantMBeanException;
077:
078: public ObjectInstance createMBean(String className,
079: ObjectName objectName, ObjectName loaderName,
080: Object[] args, String[] parameters)
081: throws ReflectionException, InstanceAlreadyExistsException,
082: MBeanRegistrationException, MBeanException,
083: NotCompliantMBeanException, InstanceNotFoundException;
084:
085: public void unregisterMBean(ObjectName objectName)
086: throws InstanceNotFoundException,
087: MBeanRegistrationException;
088:
089: public Object getAttribute(ObjectName objectName, String attribute)
090: throws MBeanException, AttributeNotFoundException,
091: InstanceNotFoundException, ReflectionException;
092:
093: public void setAttribute(ObjectName objectName, Attribute attribute)
094: throws InstanceNotFoundException,
095: AttributeNotFoundException, InvalidAttributeValueException,
096: MBeanException, ReflectionException;
097:
098: public AttributeList getAttributes(ObjectName objectName,
099: String[] attributes) throws InstanceNotFoundException,
100: ReflectionException;
101:
102: public AttributeList setAttributes(ObjectName objectName,
103: AttributeList attributes) throws InstanceNotFoundException,
104: ReflectionException;
105:
106: public Object invoke(ObjectName objectName, String methodName,
107: Object[] args, String[] parameters)
108: throws InstanceNotFoundException, MBeanException,
109: ReflectionException;
110:
111: public Integer getMBeanCount();
112:
113: public boolean isRegistered(ObjectName objectname);
114:
115: public ObjectInstance getObjectInstance(ObjectName objectName)
116: throws InstanceNotFoundException;
117:
118: public Set queryMBeans(ObjectName patternName, QueryExp filter);
119:
120: public Set queryNames(ObjectName patternName, QueryExp filter);
121:
122: /**
123: * Instantiates an object of the given class using the MBeanServer's {@link ClassLoaderRepository}.
124: * The given class should have a public parameterless constructor.
125: *
126: * @param className The class name of the object to be instantiated.
127: * @return The newly instantiated object.
128: * @throws ReflectionException Wraps a Java reflection exception thrown while trying to create the instance
129: * @throws MBeanException Thrown if the constructor of the object throws an exception
130: */
131: public Object instantiate(String className)
132: throws ReflectionException, MBeanException;
133:
134: /**
135: * Instantiates an object of the given class using the specified ClassLoader MBean.
136: * If <code>loaderName</code> is null, the classloader of the MBeanServer will be used.
137: * The given class should have a public parameterless constructor.
138: *
139: * @param className The class name of the MBean to be instantiated.
140: * @param loaderName The object name of the class loader to be used.
141: * @return The newly instantiated object.
142: * @throws ReflectionException Wraps a Java reflection exception thrown while trying to create the instance
143: * @throws MBeanException Thrown if the constructor of the object throws an exception
144: * @throws InstanceNotFoundException The specified classloader MBean is not registered in the MBeanServer.
145: */
146: public Object instantiate(String className, ObjectName loaderName)
147: throws ReflectionException, MBeanException,
148: InstanceNotFoundException;
149:
150: /**
151: * Instantiates an object of the given class using the MBeanServer's {@link ClassLoaderRepository}.
152: * The given class should have a public constructor matching the given signature, and will be called
153: * passing the given arguments.
154: *
155: * @param className The class name of the object to be instantiated.
156: * @param args The arguments passed to the constructor.
157: * @param parameters The signature of the constructor.
158: * @return The newly instantiated object.
159: * @throws ReflectionException Wraps a Java reflection exception thrown while trying to create the instance
160: * @throws MBeanException Thrown if the constructor of the object throws an exception
161: */
162: public Object instantiate(String className, Object[] args,
163: String[] parameters) throws ReflectionException,
164: MBeanException;
165:
166: /**
167: * Instantiates an object of the given class using the specified ClassLoader MBean.
168: * If <code>loaderName</code> is null, the classloader of the MBeanServer will be used.
169: * The given class should have a public constructor matching the given signature, and will be called
170: * passing the given arguments.
171: *
172: * @param className The class name of the MBean to be instantiated.
173: * @param loaderName The object name of the class loader to be used.
174: * @param args The arguments passed to the constructor.
175: * @param parameters The signature of the constructor.
176: * @return The newly instantiated object.
177: * @throws ReflectionException Wraps a Java reflection exception thrown while trying to create the instance
178: * @throws MBeanException Thrown if the constructor of the object throws an exception
179: * @throws InstanceNotFoundException The specified classloader MBean is not registered in the MBeanServer.
180: */
181: public Object instantiate(String className, ObjectName loaderName,
182: Object[] args, String[] parameters)
183: throws ReflectionException, MBeanException,
184: InstanceNotFoundException;
185:
186: /**
187: * Registers the given MBean with the given ObjectName.
188: * The ObjectName may be null, but the MBean should then implement {@link MBeanRegistration}.
189: *
190: * @param mbean The MBean to be registered.
191: * @param objectName The ObjectName of the MBean, may be null.
192: * @return An ObjectInstance, containing the ObjectName and the Java class name of the newly registered MBean.
193: * @throws InstanceAlreadyExistsException An MBean with the same ObjectName is already registered in the MBeanServer.
194: * @throws MBeanRegistrationException Thrown if a problem is encountered during registration.
195: * @throws NotCompliantMBeanException The given MBean is not a JMX compliant MBean
196: */
197: public ObjectInstance registerMBean(Object mbean,
198: ObjectName objectName)
199: throws InstanceAlreadyExistsException,
200: MBeanRegistrationException, NotCompliantMBeanException;
201:
202: /**
203: * @deprecated Use {@link #getClassLoader} to obtain the classloader for deserialization.
204: */
205: public ObjectInputStream deserialize(String className,
206: ObjectName loaderName, byte[] bytes)
207: throws InstanceNotFoundException, OperationsException,
208: ReflectionException;
209:
210: /**
211: * @deprecated Use {@link #getClassLoaderRepository} to obtain the ClassLoaderRepository for deserialization.
212: */
213: public ObjectInputStream deserialize(String className, byte[] bytes)
214: throws OperationsException, ReflectionException;
215:
216: /**
217: * @deprecated Use {@link #getClassLoaderFor} to obtain the classloader for deserialization.
218: */
219: public ObjectInputStream deserialize(ObjectName objectName,
220: byte[] bytes) throws InstanceNotFoundException,
221: OperationsException;
222:
223: /**
224: * Returns the ClassLoader that was used for loading the named MBean.
225: *
226: * @param mbeanName The ObjectName of the MBean.
227: * @return The ClassLoader used to load the names MBean.
228: * @throws InstanceNotFoundException If the named MBean is not found.
229: * @since JMX 1.2
230: */
231: public ClassLoader getClassLoaderFor(ObjectName mbeanName)
232: throws InstanceNotFoundException;
233:
234: /**
235: * Returns the named classloader MBean. If the given <code>loaderName</code> is null, the classloader
236: * of the MBeanServer will be used.
237: *
238: * @param loaderName The ObjectName of the classloader MBean, or null.
239: * @return The named classloader MBean.
240: * @throws InstanceNotFoundException If the named classloader MBean is not found.
241: * @since JMX 1.2
242: */
243: public ClassLoader getClassLoader(ObjectName loaderName)
244: throws InstanceNotFoundException;
245:
246: /**
247: * Returns the ClassLoaderRepository for this MBeanServer.
248: *
249: * @since JMX 1.2
250: */
251: public ClassLoaderRepository getClassLoaderRepository();
252: }
|