亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? groovymbean.java

?? Groovy動態語言 運行在JVM中的動態語言 可以方便的處理業務邏輯變化大的業務
?? JAVA
字號:
/*
 $Id: GroovyMBean.java 3747 2006-04-17 12:56:57Z glaforge $

 Copyright 2003 (C) James Strachan and Bob Mcwhirter. All Rights Reserved.

 Redistribution and use of this software and associated documentation
 ("Software"), with or without modification, are permitted provided
 that the following conditions are met:

 1. Redistributions of source code must retain copyright
    statements and notices.  Redistributions must also contain a
    copy of this document.

 2. Redistributions in binary form must reproduce the
    above copyright notice, this list of conditions and the
    following disclaimer in the documentation and/or other
    materials provided with the distribution.

 3. The name "groovy" must not be used to endorse or promote
    products derived from this Software without prior written
    permission of The Codehaus.  For written permission,
    please contact info@codehaus.org.

 4. Products derived from this Software may not be called "groovy"
    nor may "groovy" appear in their names without prior written
    permission of The Codehaus. "groovy" is a registered
    trademark of The Codehaus.

 5. Due credit should be given to The Codehaus -
    http://groovy.codehaus.org/

 THIS SOFTWARE IS PROVIDED BY THE CODEHAUS AND CONTRIBUTORS
 ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
 NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
 THE CODEHAUS OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
 OF THE POSSIBILITY OF SUCH DAMAGE.

 */
package groovy.util;

import groovy.lang.GroovyObjectSupport;
import groovy.lang.GroovyRuntimeException;

import java.util.HashMap;
import java.util.Map;
import java.util.Collection;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.io.IOException;

import javax.management.Attribute;
import javax.management.JMException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import javax.management.MBeanOperationInfo;
import javax.management.MBeanParameterInfo;
import javax.management.ObjectName;
import javax.management.MBeanServerConnection;
import javax.management.MBeanAttributeInfo;


/**
 * A GroovyObject facade for an underlying MBean which acts like a normal
 * groovy object but which is actually implemented via
 * an underlying JMX MBean.
 * Properties and normal method invocations
 * delegate to the MBeanServer to the actual MBean.
 *
 * @author <a href="mailto:james@coredevelopers.net">James Strachan</a>
 * @author Steve Button
 * @version $Revision: 3747 $
 */
public class GroovyMBean extends GroovyObjectSupport {

    private MBeanServerConnection server;
    private ObjectName name;
    private MBeanInfo beanInfo;
    private Map operations = new HashMap();


    public GroovyMBean(MBeanServerConnection server, ObjectName name) throws JMException, IOException {
        this.server = server;
        this.name = name;
        this.beanInfo = server.getMBeanInfo(name);


        MBeanOperationInfo[] operationInfos = beanInfo.getOperations();
        for (int i = 0; i < operationInfos.length; i++) {
            MBeanOperationInfo info = operationInfos[i];
            String signature[] = createSignature(info);

            // Include a simple fix here to support overloaded operations on the MBean.
            // Construct a simple key for an operation by adding the number of parameters it uses
            String operationKey = createOperationKey(info.getName(), signature.length);
            operations.put(operationKey, signature);
        }

    }

    public MBeanServerConnection server() {
        return server;
    }

    public ObjectName name() {
        return name;
    }

    public MBeanInfo info() {
        return beanInfo;
    }

    public Object getProperty(String property) {
        try {
            return server.getAttribute(name, property);
        }
        catch (MBeanException e) {
            throw new GroovyRuntimeException("Could not access property: " + property + ". Reason: " + e, e.getTargetException());
        }
        catch (Exception e) {
            throw new GroovyRuntimeException("Could not access property: " + property + ". Reason: " + e, e);
        }
    }

    public void setProperty(String property, Object value) {
        try {
            server.setAttribute(name, new Attribute(property, value));
        }
        catch (MBeanException e) {
            throw new GroovyRuntimeException("Could not set property: " + property + ". Reason: " + e, e.getTargetException());
        }
        catch (Exception e) {
            throw new GroovyRuntimeException("Could not set property: " + property + ". Reason: " + e, e);
        }
    }

    public Object invokeMethod(String method, Object arguments) {
        // Moved this outside the try block so we can obtain the number of parameters
        // specified in the arguments array, which is needed to find the correct method.
        Object[] argArray = null;
        if (arguments instanceof Object[]) {
            argArray = (Object[]) arguments;
        } else {
            argArray = new Object[]{arguments};
        }
        // Locate the specific method based on the name and number of parameters
        String operationKey = createOperationKey(method, argArray.length);
        String[] signature = (String[]) operations.get(operationKey);

        if (signature != null) {
            try {
                return server.invoke(name, method, argArray, signature);
            }
            catch (MBeanException e) {
                throw new GroovyRuntimeException("Could not invoke method: " + method + ". Reason: " + e, e.getTargetException());
            }
            catch (Exception e) {
                throw new GroovyRuntimeException("Could not invoke method: " + method + ". Reason: " + e, e);
            }
        } else {
            return super.invokeMethod(method, arguments);
        }
    }

    protected String[] createSignature(MBeanOperationInfo info) {
        MBeanParameterInfo[] params = info.getSignature();
        String[] answer = new String[params.length];
        for (int i = 0; i < params.length; i++) {
            answer[i] = params[i].getType();
        }
        return answer;
    }

    /**
     * Construct a simple key based on the method name and the number of parameters
     *
     * @param operation - the mbean operation name
     * @param params    - the number of parameters the operation supports
     * @return simple unique identifier for a method
     */
    protected String createOperationKey(String operation, int params) {
        // This could be changed to support some hash of the parameter types, etc.
        return operation + "_" + params;
    }

    /**
     * List of the names of each of the attributes on the MBean
     *
     * @return list of attribute names
     */
    public Collection listAttributeNames() {
        ArrayList list = new ArrayList();
        try {
            MBeanAttributeInfo[] attrs = beanInfo.getAttributes();
            for (int i = 0; i < attrs.length; i++) {
                MBeanAttributeInfo attr = attrs[i];
                list.add(attr.getName());
            }
        }
        catch (Throwable t) {
        }
        finally {
        }
        return list;
    }

    /**
     * The values of each of the attributes on the MBean
     *
     * @return list of values of each attribute
     */
    public List listAttributeValues() {
        ArrayList list = new ArrayList();
        Collection names = listAttributeNames();
        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
            String name = (String) iterator.next();
            try {
                Object val = this.getProperty(name);
                if (val != null) {
                    list.add(name + " : " + val.toString());
                }
            }
            catch (RuntimeException e) {
                // todo: fix this behaviour properly
                // Do nothing here, just handle the error silently.
                //e.printStackTrace();
            }
        }
        return list;
    }


    /**
     * List of string representations of all of the attributes on the MBean.
     *
     * @return list of descriptions of each attribute on the mbean
     */
    public Collection listAttributeDescriptions() {
        ArrayList list = new ArrayList();
        try {
            MBeanAttributeInfo[] attrs = beanInfo.getAttributes();
            for (int i = 0; i < attrs.length; i++) {
                MBeanAttributeInfo attr = attrs[i];
                list.add(describeAttribute(attr));
            }
        }
        catch (Throwable t) {
        }
        finally {
        }
        return list;
    }

    /**
     * Description of the specified attribute name.
     *
     * @param attr - the attribute
     * @return String the description
     */
    protected String describeAttribute(MBeanAttributeInfo attr) {
        StringBuffer buf = new StringBuffer();
        buf.append("(");
        if (attr.isReadable()) {
            buf.append("r");
        }
        if (attr.isWritable()) {
            buf.append("w");
        }
        buf.append(") ")
                .append(attr.getType())
                .append(" ")
                .append(attr.getName());
        return buf.toString();
    }

    /**
     * Description of the specified attribute name.
     *
     * @param attributeName - stringified name of the attribute
     * @return the description
     */
    public String describeAttribute(String attributeName) {
        String ret = "Attribute not found";
        try {
            MBeanAttributeInfo[] attributes = beanInfo.getAttributes();
            for (int i = 0; i < attributes.length; i++) {
                MBeanAttributeInfo attribute = attributes[i];
                if (attribute.getName().equals(attributeName)) {
                    return describeAttribute(attribute);
                }
            }
        }
        catch (Throwable t) {
        }
        return ret;
    }

    /**
     * Names of all the operations available on the MBean.
     *
     * @return all the operations on the MBean
     */
    public Collection listOperationNames() {
        ArrayList list = new ArrayList();
        try {
            MBeanOperationInfo[] operations = beanInfo.getOperations();
            for (int i = 0; i < operations.length; i++) {
                MBeanOperationInfo operation = operations[i];
                list.add(operation.getName());
            }
        }
        catch (Throwable t) {
        }
        return list;
    }


    /**
     * Description of all of the operations available on the MBean.
     *
     * @return full description of each operation on the MBean
     */
    public Collection listOperationDescriptions() {
        ArrayList list = new ArrayList();
        try {
            MBeanOperationInfo[] operations = beanInfo.getOperations();
            for (int i = 0; i < operations.length; i++) {
                MBeanOperationInfo operation = operations[i];
                list.add(describeOperation(operation));
            }
        }
        catch (Throwable t) {
        }
        return list;
    }

    /**
     * Get the dessciptions of the named operation.  This returns a Collection since
     * operations can be overloaded and one operationName can have multiple forms.
     *
     * @param operationName
     * @return Collection of operation description
     */
    public List describeOperation(String operationName) {
        ArrayList list = new ArrayList();
        try {
            MBeanOperationInfo[] operations = beanInfo.getOperations();
            for (int i = 0; i < operations.length; i++) {
                MBeanOperationInfo operation = operations[i];
                if (operation.getName().equals(operationName)) {
                    list.add(describeOperation(operation));
                }
            }
        }
        catch (Throwable t) {
        }
        return list;
    }

    /**
     * Dessciption of the named operation.
     *
     * @param operation
     * @return description
     */
    protected String describeOperation(MBeanOperationInfo operation) {
        StringBuffer buf = new StringBuffer();
        buf.append(operation.getReturnType())
                .append(" ")
                .append(operation.getName())
                .append("(");

        MBeanParameterInfo[] params = operation.getSignature();
        for (int j = 0; j < params.length; j++) {
            MBeanParameterInfo param = params[j];
            if (j != 0) {
                buf.append(", ");
            }
            buf.append(param.getType())
                    .append(" ")
                    .append(param.getName());
        }
        buf.append(")");
        return buf.toString();
    }


    /**
     * Return an end user readable representation of the underlying MBean
     * @return the user readable description
     */
    public String toString() {
        StringBuffer buf = new StringBuffer();
        buf.append("MBean Name:")
                .append("\n  ")
                .append(name.getCanonicalName())
                .append("\n  ");
        if (!listAttributeDescriptions().isEmpty()) {
            buf.append("\nAttributes:");
            for (Iterator iterator = listAttributeDescriptions().iterator(); iterator.hasNext();) {
                buf.append("\n  ")
                        .append((String) iterator.next());
            }
        }
        if (!listOperationDescriptions().isEmpty()) {
            buf.append("\nOperations:");
            for (Iterator iterator = listOperationDescriptions().iterator(); iterator.hasNext();) {
                buf.append("\n  ")
                        .append((String) iterator.next());
            }
        }
        return buf.toString();
  }
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品一区二区你懂的| 一区二区国产盗摄色噜噜| 6080日韩午夜伦伦午夜伦| 在线观看日产精品| 在线一区二区视频| 欧美伊人久久久久久久久影院 | 午夜亚洲国产au精品一区二区| 国产精品国产三级国产aⅴ中文| 中文字幕乱码久久午夜不卡| 国产色产综合产在线视频| 久久久精品免费免费| 欧美韩国日本一区| 国产精品国产三级国产| 夜夜嗨av一区二区三区网页| 亚洲综合激情另类小说区| 亚洲一区二区欧美激情| 日本少妇一区二区| 国产综合色产在线精品| 丁香啪啪综合成人亚洲小说| 不卡在线视频中文字幕| 欧美日精品一区视频| 777xxx欧美| 欧美韩日一区二区三区| 一区二区三区四区中文字幕| 爽好多水快深点欧美视频| 久久99最新地址| 93久久精品日日躁夜夜躁欧美| 欧美性生活一区| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 欧美成人性福生活免费看| 久久蜜桃av一区精品变态类天堂 | 欧美系列亚洲系列| 日韩免费看的电影| 亚洲欧洲性图库| 午夜天堂影视香蕉久久| 国产馆精品极品| 欧美日韩精品欧美日韩精品 | 亚洲色图20p| 男人的天堂亚洲一区| 成人免费的视频| 在线成人av网站| 国产精品二区一区二区aⅴ污介绍| 午夜一区二区三区视频| 成人免费毛片高清视频| 在线综合+亚洲+欧美中文字幕| 国产日韩欧美综合一区| 日韩综合一区二区| av在线播放一区二区三区| 日韩美女天天操| 亚洲国产美女搞黄色| 成人国产精品免费网站| 日韩一二三区视频| 亚洲一区二区欧美激情| jvid福利写真一区二区三区| 日韩亚洲欧美中文三级| 亚洲国产成人av网| gogo大胆日本视频一区| 国产校园另类小说区| 日韩av成人高清| 欧美色区777第一页| 国产精品看片你懂得| 国内成+人亚洲+欧美+综合在线| 欧美性xxxxx极品少妇| 成人免费在线观看入口| 波多野结衣在线一区| 久久久久国产精品麻豆ai换脸| 美国十次综合导航| 91精品国产欧美一区二区成人| 亚洲一区二区在线观看视频 | 偷拍一区二区三区| 欧美午夜在线一二页| 亚洲人吸女人奶水| 99视频在线精品| 国产精品成人网| 99国产精品一区| 中文字幕在线不卡一区二区三区| 国产成人精品综合在线观看| 久久精品视频一区| 国产精品自拍在线| 日本一区二区久久| 不卡免费追剧大全电视剧网站| 国产女主播视频一区二区| 国产寡妇亲子伦一区二区| 国产无一区二区| 成人国产亚洲欧美成人综合网 | 欧美日韩免费高清一区色橹橹| 一区二区三区日韩欧美| 精品视频资源站| 日韩中文字幕不卡| 精品日韩在线观看| 国产v日产∨综合v精品视频| 国产精品久久久久久久久免费丝袜 | 三级在线观看一区二区| 欧美日韩一区三区四区| 日韩av中文在线观看| 精品乱人伦一区二区三区| 国产成人在线视频免费播放| 中文av字幕一区| 在线观看av不卡| 欧美aaaaaa午夜精品| 日本一区二区成人| 欧美日韩一区二区在线观看视频| 热久久一区二区| 国产视频视频一区| 色一情一乱一乱一91av| 免费成人av资源网| 国产精品欧美一级免费| 欧美日韩1234| 国产又黄又大久久| 亚洲一线二线三线视频| 久久综合狠狠综合久久综合88| 99视频一区二区| 久久99精品一区二区三区三区| 国产精品毛片a∨一区二区三区| 欧美美女网站色| 国产91在线看| 秋霞电影网一区二区| 国产精品美女久久久久久| 91精品视频网| 91丝袜呻吟高潮美腿白嫩在线观看| 日韩高清一级片| 中文字幕欧美一区| 亚洲精品在线免费观看视频| 91福利视频在线| 国产不卡视频一区| 欧美aaaaa成人免费观看视频| 亚洲图片你懂的| 久久婷婷国产综合国色天香| 欧美日韩高清影院| 99re这里只有精品首页| 黑人巨大精品欧美黑白配亚洲| 亚洲主播在线播放| 国产精品久久久久一区二区三区 | 国产女人18毛片水真多成人如厕 | 7777精品伊人久久久大香线蕉 | 欧美日韩视频专区在线播放| 菠萝蜜视频在线观看一区| 激情综合网最新| 日韩不卡一区二区| 亚洲第一综合色| 亚洲精品视频一区二区| 日本一区二区三区国色天香| 久久色.com| 欧美sm极限捆绑bd| 日韩欧美国产精品| 91精品国产91综合久久蜜臀| 欧美综合色免费| 一本到不卡免费一区二区| 不卡视频免费播放| 成人高清免费观看| 成人免费观看男女羞羞视频| 国产激情一区二区三区| 国产乱码一区二区三区| 激情偷乱视频一区二区三区| 另类人妖一区二区av| 激情综合网最新| 国产一区二区中文字幕| 国产精品一色哟哟哟| 国产一区二区导航在线播放| 国产在线视频精品一区| 美女一区二区视频| 国内不卡的二区三区中文字幕| 国产美女视频一区| 国产99久久精品| 91在线观看地址| 欧美午夜影院一区| 欧美一区二区精品| 久久久久综合网| 国产精品的网站| 亚洲第一主播视频| 另类小说视频一区二区| 国产成人精品1024| thepron国产精品| 欧美日韩黄色影视| 日韩精品中文字幕在线不卡尤物| 久久这里只有精品首页| 国产精品视频麻豆| 亚洲v中文字幕| 国产在线精品一区二区夜色| eeuss鲁一区二区三区| 欧美午夜视频网站| 精品人在线二区三区| 国产亚洲美州欧州综合国| 亚洲精品国产一区二区三区四区在线| 亚洲一二三区不卡| 捆绑调教美女网站视频一区| 成人国产精品免费观看视频| 欧美久久久久免费| 久久精品视频一区二区三区| 亚洲宅男天堂在线观看无病毒| 久久国产精品99久久久久久老狼| 北条麻妃国产九九精品视频| 欧美日韩精品二区第二页| 国产欧美一区二区在线| 亚洲一区欧美一区| 国产精品一级在线| 欧美午夜精品一区二区三区| 久久婷婷国产综合精品青草| 午夜精品一区二区三区免费视频 | 色系网站成人免费|