⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mejbwebservicebean.java

📁 一个java写的加密算法
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
/* * Copyright 2004-2005 Sun Microsystems, Inc.  All rights reserved. * Use is subject to license terms. */package com.sun.enterprise.management.agent;import java.security.*;import java.rmi.RemoteException;import java.util.*;import java.io.ObjectInputStream;import javax.ejb.*;import javax.management.*;import javax.management.j2ee.*;import javax.naming.*;import com.sun.enterprise.management.agent.ws.*;import java.io.StringWriter;/** * This is a modification to MEJBBean which supports a WSDL port * to the standard management functions in javax.management.j2ee.Management * *  @author Hans Hrasna */public class MEJBWebServiceBean implements SessionBean {    private SessionContext ctx;    private MEJBUtility mejbUtility = null;    private Hashtable listeners = new Hashtable(); //table of listeners keyed by callbackURI        public void setSessionContext(SessionContext context) {        ctx = context;    }    public void ejbActivate() {    }    public void ejbPassivate() {    }    public void ejbRemove() {    }    public void ejbCreate() throws CreateException {        this.mejbUtility = MEJBUtility.getMEJBUtility();    }    // javax.management.j2ee.Management implementation starts here    /**     * Gets the names of managed objects controlled by the MEJB. This method     * enables any of the following to be obtained: The names of all managed objects,     * the names of a set of managed objects specified by pattern matching on the     * <CODE>ObjectName</CODE> and/or a Query expression, a specific managed object name (equivalent to     * testing whether an managed object is registered). When the object name is     * null or no domain and key properties are specified, all objects are selected (and filtered if a     * query is specified). It returns the set of ObjectNames for the managed objects selected.     * @param name The object name pattern identifying the managed objects to be retrieved. If     * null or no domain and key properties are specified, all the managed objects registered will be retrieved.     * @param query The query expression to be applied for selecting managed objects. If null     * no query expression will be applied for selecting managed objects.     * @return  A set containing the ObjectNames for the managed objects selected.     * If no managed object satisfies the query, an empty list is returned.     */    public Set queryNames(ObjectName name, QueryExp query) throws RemoteException {        try{            return this.mejbUtility.queryNames(name,query);        }catch(Exception ex){            throw new RemoteException(this.toString() +"::queryNames", ex);        }    }	/* WS version */    public Set queryNames(String objectName, String query) throws RemoteException {        ObjectName n = null;        QueryExp q = null;        try {			n = new ObjectName(objectName);            if (query != null) {				//TO FIX !!!				System.out.println("Received query string: " + query);            }	        Set objectNames = this.mejbUtility.queryNames(n,q);            Iterator i = objectNames.iterator();            Set stringNames = new HashSet();             while(i.hasNext()) {                String name = ((ObjectName)i.next()).toString();                stringNames.add(name);            }            return stringNames;        } catch(Exception ex){			System.out.println(ex);            throw new RemoteException(this.toString() +"::queryNames", ex);        }    }			    /**     * Checks whether an MBean, identified by its object name, is already registered with the MBean server.     * @param name 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(ObjectName name) throws RemoteException {        try{            return this.mejbUtility.isRegistered(name);        }catch(Exception ex){            throw new RemoteException(this.toString() +"::isRegistered", ex);        }    }    /* WS version */    public boolean isRegistered(String name) throws RemoteException {	    ObjectName n = null;        try {            n = new ObjectName(name);        } catch(Exception ex){            throw new RemoteException(this.toString() +"::isRegistered", ex);        }        return isRegistered(n);    }	    /** Returns the number of MBeans registered in the MBean server. */    public Integer getMBeanCount() throws RemoteException {        try{            return this.mejbUtility.getMBeanCount();        }catch(Exception ex){            throw new RemoteException(this.toString() +"::getMBeanCount", ex);        }    }    /**     * This method discovers the attributes and operations that an MBean exposes for management.     * @param name The name of the MBean to analyze     * @return  An instance of <CODE>MBeanInfo</CODE> allowing the retrieval of all attributes and operations of this MBean.     * @exception IntrospectionException An exception occurs during introspection.     * @exception InstanceNotFoundException The MBean specified is not found.     * @exception ReflectionException An exception occurred when trying to invoke the getMBeanInfo of a Dynamic MBean.     */    public MBeanInfo getMBeanInfo(ObjectName name) throws javax.management.InstanceNotFoundException,        javax.management.IntrospectionException, javax.management.ReflectionException, RemoteException {        return this.mejbUtility.getMBeanInfo(name);    }    /* WS version */    public String getMBeanInfo(String name) throws RemoteException {        ObjectName objectName = null;        try {            objectName = new ObjectName(name);            MBeanInfo beanInfo = mejbUtility.getMBeanInfo(objectName);            // Marshal the object            String serializedMBeanInfo = MBeanInfoSerializer.marshal(beanInfo);            return serializedMBeanInfo;        } catch(Exception ex){			System.out.println(ex);            throw new RemoteException(this.toString() +"::getAttribute", ex);        }    }    /**     * Gets the value of a specific attribute of a named MBean. The MBean is identified by its object name.     * @param name The object name of the MBean from which the attribute is to be retrieved.     * @param attribute A String specifying the name of the attribute to be retrieved.     * @return  The value of the retrieved attribute.     * @exception AttributeNotFoundException The attribute specified is not accessible in the MBean.     * @exception MBeanException  Wraps an exception thrown by the MBean's getter.     * @exception InstanceNotFoundException The MBean specified is not registered in the MBean server.     * @exception ReflectionException  Wraps a <CODE>java.lang.Exception</CODE> thrown when trying to invoke the setter.     * @exception RuntimeOperationsException Wraps a <CODE>java.lang.IllegalArgumentException</CODE>: The object name in     * parameter is null or the attribute in parameter is null.     */    public Object getAttribute(ObjectName name, String attribute) throws MBeanException,        javax.management.AttributeNotFoundException, javax.management.InstanceNotFoundException,        javax.management.ReflectionException, RemoteException {        return this.mejbUtility.getAttribute(name,attribute);    }    /* WS version */    public Object getAttribute(String name, String attribute) throws RemoteException {        ObjectName n = null;        try {            n = new ObjectName(name);			return getAttribute(n,attribute);        } catch(Exception ex){            throw new RemoteException(this.toString() +"::getAttribute", ex);        }    }    /**     * Enables the values of several attributes of a named MBean. The MBean is identified by its object name.     * @param name The object name of the MBean from which the attributes are retrieved.     * @param attributes A list of the attributes to be retrieved.     * @return The list of the retrieved attributes.     * @exception InstanceNotFoundException The MBean specified is not registered in the MBean server.     * @exception ReflectionException An exception occurred when trying to invoke the getAttributes method of a Dynamic MBean.     * @exception RuntimeOperationsException Wrap a <CODE>java.lang.IllegalArgumentException</CODE>: The object name in     * parameter is null or attributes in parameter is null.     */    public javax.management.AttributeList getAttributes(ObjectName name, String [] attributes)        throws javax.management.InstanceNotFoundException, javax.management.ReflectionException, RemoteException {        return this.mejbUtility.getAttributes(name,attributes);    }    /* WS version */    public String getAttributes(String name, Set attributes) throws RemoteException {		ObjectName n = null;        try {            n = new ObjectName(name);			String [] atts = (String [])(attributes.toArray(new String []{}));            System.out.println("getAttributes for " + name);             for ( int i=0; i<atts.length; i++ ) {                 System.out.println("name = " + atts[i]);             }			AttributeList al = mejbUtility.getAttributes(n, atts);			if (al != null) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -