📄 mejbwebservicebean.java
字号:
* Instantiates and registers an MBean in the MBean server. The class loader to be used is identified by its object * name. An object name is associated to the MBean. If the object name * of the loader is not specified, the ClassLoader that loaded the MBean server will be used. * If the MBean object name given is null, the MBean can automatically provide its * own name by implementing the { javax.management.MBeanRegistration MBeanRegistration} interface. The call returns * an <CODE>ObjectInstance</CODE> object representing the newly created MBean. * @param className The class name of the MBean to be instantiated. * @param name The object name of the MBean. May be null. * @param params An array containing the parameters of the constructor to be invoked. * @param signature An array containing the signature of the constructor to be invoked. * @param loaderName The object name of the class loader to be used. * @return An <CODE>ObjectInstance</CODE>, containing the <CODE>ObjectName</CODE> and the Java class name * of the newly instantiated MBean. * @exception ReflectionException Wraps a <CODE>java.lang.ClassNotFoundException</CODE> or a * <CODE>java.lang.Exception</CODE> that occurred when trying to invoke the MBean's constructor. * @exception InstanceAlreadyExistsException The MBean is already under the control of the MBean server. * @exception MBeanRegistrationException The <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE> interface) method * of the MBean has thrown an exception. The MBean will not be registered. * @exception MBeanException The constructor of the MBean has thrown an exception * @exception InstanceNotFoundException The specified class loader is not registered in the MBean server. * @exception RuntimeOperationsException Wraps a <CODE>java.lang.IllegalArgumentException</CODE>: The className passed in * parameter is null, the <CODE>ObjectName</CODE> passed in parameter contains a pattern or no <CODE>ObjectName</CODE> is * specified for the MBean. */ public ObjectInstance createMBean(String className, ObjectName name, ObjectName loaderName, Object[] params, String[] signature) throws javax.management.ReflectionException, javax.management.InstanceAlreadyExistsException, MBeanRegistrationException, MBeanException, NotCompliantMBeanException, javax.management.InstanceNotFoundException, RemoteException { return this.mejbUtility.createMBean(className, name, loaderName, params, signature); } /** * Registers a pre-existing object as an MBean with the MBean server. If the object name given is * null, the MBean may automatically provide its own name by implementing the * { javax.management.MBeanRegistration MBeanRegistration} interface. * The call returns an <CODE>ObjectInstance</CODE> object representing the registered MBean. * @param object The MBean to be registered as an MBean. * @param name The object name of the MBean. May be null. * @return The <CODE>ObjectInstance</CODE> for the MBean that has been registered. * @exception InstanceAlreadyExistsException The MBean is already under the control of the MBean server. * @exception MBeanRegistrationException The <CODE>preRegister</CODE> (<CODE>MBeanRegistration</CODE> interface) method * of the MBean has thrown an exception. The MBean will not be registered. * @exception NotCompliantMBeanException This object is not a JMX compliant MBean * @exception RuntimeOperationsException Wraps a <CODE>java.lang.IllegalArgumentException</CODE>: The object passed in * parameter is null or no object name is specified. */ public ObjectInstance registerMBean(Object object, ObjectName name) throws javax.management.InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, RemoteException { return this.mejbUtility.registerMBean(object, name); } /** * De-registers an MBean from the MBean server. The MBean is identified by * its object name. Once the method has been invoked, the MBean may no longer be accessed by its object name. * @param name The object name of the MBean to be de-registered. * @exception InstanceNotFoundException The MBean specified is not registered in the MBean server. * @exception MBeanRegistrationException The preDeregister ((<CODE>MBeanRegistration</CODE> interface) method of the MBean * has thrown an exception. * @exception RuntimeOperationsException Wraps a <CODE>java.lang.IllegalArgumentException</CODE>: The object name in * parameter is null or the MBean you are when trying to de-register is the { javax.management.MBeanServerDelegate * MBeanServerDelegate} MBean. */ public void unregisterMBean(ObjectName name) throws InstanceNotFoundException, MBeanRegistrationException, RemoteException { this.mejbUtility.unregisterMBean(name); } /** * Gets the <CODE>ObjectInstance</CODE> for a given MBean registered with the MBean server. * @param name The object name of the MBean. * @return The <CODE>ObjectInstance</CODE> associated to the MBean specified by <VAR>name</VAR>. * @exception InstanceNotFoundException The MBean specified is not registered in the MBean server. */ public ObjectInstance getObjectInstance(ObjectName name) throws javax.management.InstanceNotFoundException, RemoteException { return this.mejbUtility.getObjectInstance(name); } /** * Gets MBeans controlled by the MBean server. This method allows any * of the following to be obtained: All MBeans, a set of MBeans specified * by pattern matching on the <CODE>ObjectName</CODE> and/or a Query expression, a * specific MBean. When the object name is null or no domain and key properties are specified, all objects are to be * selected (and filtered if a query is specified). It returns the * set of <CODE>ObjectInstance</CODE> objects (containing the <CODE>ObjectName</CODE> and the Java Class name) * for the selected MBeans. * @param name The object name pattern identifying the MBeans to be retrieved. If * null or no domain and key properties are specified, all the MBeans registered will be retrieved. * @param query The query expression to be applied for selecting MBeans. If null * no query expression will be applied for selecting MBeans. * @return A set containing the <CODE>ObjectInstance</CODE> objects for the selected MBeans. * If no MBean satisfies the query an empty list is returned. */ public Set queryMBeans(ObjectName name, QueryExp query) throws RemoteException { return this.mejbUtility.queryMBeans(name, query); } /** * Returns the default domain used for naming the MBean. The default domain name is used as the domain part in the * ObjectName of MBeans if no domain is specified by the user. */ //public String getDefaultDomain() throws RemoteException; /** * Enables to add a listener to a registered MBean. * @param name The name of the MBean on which the listener should be added. * @param listener The listener object which will handle the notifications emitted by the registered MBean. * @param filter The filter object. If filter is null, no filtering will be performed before handling notifications. * @param handback The context to be sent to the listener when a notification is emitted. * @exception InstanceNotFoundException The MBean name provided does not match any of the registered MBeans. */ public void addNotificationListener(ObjectName name, NotificationListener listener, NotificationFilter filter, Object handback) throws javax.management.InstanceNotFoundException, RemoteException { this.mejbUtility.addNotificationListener(name, listener, filter, handback); } /** * Enables to add a listener to a registered MBean. * @param name The name of the MBean on which the listener should be added. * @param listener The object name of the listener which will handle the notifications emitted by the registered MBean. * @param filter The filter object. If filter is null, no filtering will be performed before handling notifications. * @param handback The context to be sent to the listener when a notification is emitted. * @exception InstanceNotFoundException The MBean name of the notification listener or of the notification broadcaster * does not match any of the registered MBeans. */ public void addNotificationListener(ObjectName name, ObjectName listener, NotificationFilter filter, Object handback) throws javax.management.InstanceNotFoundException, RemoteException { this.mejbUtility.addNotificationListener(name, listener, filter, handback); } /** * Enables to remove a listener from a registered MBean. * @param name The name of the MBean on which the listener should be removed. * @param listener The listener object which will handle the notifications emitted by the registered MBean. * This method will remove all the information related to this listener. * @exception InstanceNotFoundException The MBean name provided does not match any of the registered MBeans. * @exception ListenerNotFoundException The listener is not registered in the MBean. */ public void removeNotificationListener(ObjectName name, NotificationListener listener) throws javax.management.InstanceNotFoundException, javax.management.ListenerNotFoundException, RemoteException { this.mejbUtility.removeNotificationListener(name, listener); } /** * Enables to remove a listener from a registered MBean. * @param name The name of the MBean on which the listener should be removed. * @param listener The object name of the listener which will handle the notifications emitted by the registered MBean. * This method will remove all the information related to this listener. * @exception InstanceNotFoundException The MBean name provided does not match any of the registered MBeans. * @exception ListenerNotFoundException The listener is not registered in the MBean. */ public void removeNotificationListener(ObjectName name, ObjectName listener) throws javax.management.InstanceNotFoundException, javax.management.ListenerNotFoundException, RemoteException { this.mejbUtility.removeNotificationListener(name, listener); } /** * Returns true if the MBean specified is an instance of the specified class, false otherwise. * @param name The <CODE>ObjectName</CODE> of the MBean. * @param className The name of the class. * @return true if the MBean specified is an instance of the specified class, false otherwise. * @exception InstanceNotFoundException The MBean specified is not registered in the MBean server. */ public boolean isInstanceOf(ObjectName name, String className) throws javax.management.InstanceNotFoundException, RemoteException { return this.mejbUtility.isInstanceOf(name, className); } /* WS version */ public void addNotificationListener( String objectName, String callbackUri, String filter, String handbackObject ) throws RemoteException { //notificationListenerRegistry.put( objectName, // callbackUri + "/" + handbackObject ); // A Simple test to make sure it works, once this works, we should // do the registration with different resources and then each // resource can maintain their registry of callbackURIs and // do the notification as shown here. HttpNotifier notifier = new HttpNotifier(callbackUri + "/" + handbackObject ); listeners.put(callbackUri, notifier); //new HttpNotifier("http://dalhi.sfbay:40094/ABC/HandbackForABC");/* try { ObjectName n = new ObjectName(objectName); notifier.handleNotification( new javax.management.Notification( "ABCEvent", n, (long) 20201, "This is an ABC Event....." ), handbackObject); } catch(Exception ex){ throw new RemoteException(this.toString() +"::isRegistered", ex); }*/ ObjectName n = null; try { n = new ObjectName(objectName); mejbUtility.addNotificationListener(n, (NotificationListener)notifier, null, handbackObject); } catch(Exception ex){ throw new RemoteException(this.toString() +"::addNotificationListener", ex); } } /* WS version */ public void removeNotificationListener(String objectName, String callbackUri) throws javax.management.InstanceNotFoundException, javax.management.ListenerNotFoundException, RemoteException { HttpNotifier listener = (HttpNotifier)listeners.get(callbackUri); ObjectName n; try { n = new ObjectName(objectName); this.mejbUtility.removeNotificationListener(n, listener); } catch(Exception ex){ throw new RemoteException(this.toString() +"::removeNotificationListener", ex); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -