Java 类javax.management.MBeanOperationInfo 实例源码

项目:phone-simulator    文件:CapManStandardMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
    // new MBeanAttributeInfo("LocalSsn", int.class.getName(), "Local Ssn", true, true, false),
    // new MBeanAttributeInfo("RemoteSsn", int.class.getName(), "Remote Ssn", true, true, false),
    new MBeanAttributeInfo("RemoteAddressDigits", String.class.getName(),
            "Remote address digits. If empty ROUTING_BASED_ON_DPC_AND_SSN is used for CalledPartyAddress (remoteSpc from SCCP), "
                    + "if not empty ROUTING_BASED_ON_GLOBAL_TITLE is used (address and Ssn from CAP)", true, true, false), };

    MBeanParameterInfo[] signString = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(),
            "Index number or value") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {};

    return new MBeanInfo(CapMan.class.getName(), "Cap Management", attributes, null, operations, null);
}
项目:phone-simulator    文件:TestCheckImeiServerStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {

            new MBeanAttributeInfo("AutoEquipmentStatus", EquipmentStatusType.class.getName(), "EquipmentStatus parameter to be automatically send in CheckImeiResponse", true, true, false),
            new MBeanAttributeInfo("AutoEquipmentStatus_Value", String.class.getName(), "EquipmentStatus parameter to be automatically send in CheckImeiResponse", true, false, false),
            new MBeanAttributeInfo("OneNotificationFor100Dialogs", boolean.class.getName(),
                    "If true there will be only one notification per every 100 sent dialogs", true, true, true),
            new MBeanAttributeInfo("CurrentRequestDef", String.class.getName(), "Definition of the current request Dialog",
                    true, false, false),

    };

    MBeanParameterInfo[] putAutoEquipmentStatusParam = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(), "EquipmentStatus value") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo(
                    "putAutoEquipmentStatus",
                    "EquipmentStatus parameter to be automatically send in CheckImeiResponse: "
                            + "0:whiteListed,1:blackListed,2:greyListed",
                    putAutoEquipmentStatusParam, Void.TYPE.getName(), MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("closeCurrentDialog", "Closing the current dialog", null, String.class.getName(), MBeanOperationInfo.ACTION)
    };
    return new MBeanInfo(TestCheckImeiServerMan.class.getName(), "CheckImeiServer test parameters management", attributes, null, operations, null);
}
项目:phone-simulator    文件:TestAtiServerStandardManMBean.java   
@Override
    public MBeanInfo getMBeanInfo() {

        MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
                new MBeanAttributeInfo("ATIReaction", ATIReaction.class.getName(), "ATI response type", true, true, false),
                new MBeanAttributeInfo("ATIReaction_Value", String.class.getName(), "ATI response type", true, false, false), };

        MBeanParameterInfo[] signString = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(), "Index number or value") };

//        MBeanParameterInfo[] performATIParam = new MBeanParameterInfo[] { new MBeanParameterInfo("msg", String.class.getName(), "Message text"),
//                new MBeanParameterInfo("address", String.class.getName(), "SubscriberIdentity: IMSI or MSISDN"), };

        MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
//                new MBeanOperationInfo("performAtiRequest", "Send ATI request", performATIParam, String.class.getName(), MBeanOperationInfo.ACTION),
//                new MBeanOperationInfo("closeCurrentDialog", "Closing the current dialog", null, String.class.getName(), MBeanOperationInfo.ACTION),

                new MBeanOperationInfo("putATIReaction", "ATI response type: "
                        + "1:ReturnSuccess,2:ReturnSuccessSubscriberState,3:ReturnSystemFailureError,4:ReturnDataMissingError,5:ReturnUnknownSubscriberError",
                        signString, Void.TYPE.getName(), MBeanOperationInfo.ACTION),
                };

        return new MBeanInfo(TestAtiServerMan.class.getName(), "AtiServer test parameters management", attributes, null, operations, null);
    }
项目:phone-simulator    文件:TestMapLcsServerStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            new MBeanAttributeInfo("NetworkNodeNumberAddress", String.class.getName(),
                                   "NetworkNodeNumber address parameter for response",
                                   true, true, false), };

    MBeanParameterInfo[] performSRIResponseParam = new MBeanParameterInfo[] { };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performSendRoutingInfoForLCSResponse", "Send Routing Information for LCS response",
                                   performSRIResponseParam, String.class.getName(), MBeanOperationInfo.ACTION),
             };

    return new MBeanInfo(TestMapLcsServerMan.class.getName(), "MapLcsServer test parameters management", attributes, null, operations, null);
}
项目:phone-simulator    文件:TestMapLcsClientStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    // TODO: Put real attributes and operations

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            new MBeanAttributeInfo("AddressNature", AddressNatureType.class.getName(),
                                   "AddressNature parameter for mlcNumber creating",
                                   true, true, false),
            new MBeanAttributeInfo("NumberingPlanType", NumberingPlanMapType.class.getName(),
                                   "NumberingPlanType parameter for mlcNumber creating",
                                   true, true, false),
            new MBeanAttributeInfo("NumberingPlan", String.class.getName(),
                                   "NumberingPlan parameter for mlcNumber creating",
                                   true, true, false), };

    MBeanParameterInfo[] performSRIRequestParam = new MBeanParameterInfo[] {
                   new MBeanParameterInfo("addressIMSI", String.class.getName(), "Address for IMSI") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performSendRoutingInfoForLCSRequest", "Send Routing Information for LCS request",
                                   performSRIRequestParam, String.class.getName(), MBeanOperationInfo.ACTION),
             };

    return new MBeanInfo(TestMapLcsClientMan.class.getName(), "MapLcsClient test parameters management", attributes, null, operations, null);
}
项目:eZooKeeper    文件:JmxConnection.java   
/**
 * TODO: Comment.
 * 
 * @param mbean
 * @param operationName
 * @return
 */
public MBeanOperation getMBeanOperation(MBean mbean, String operationName) {

    if (mbean == null) {
        throw new IllegalArgumentException("null MBean");
    }

    if (operationName == null) {
        throw new IllegalArgumentException("null operationName");
    }

    MBeanOperationInfo operationInfo = mbean.getOperationInfo(operationName);
    MBeanOperation mbeanOperation = new MBeanOperation(operationName);
    mbeanOperation.setInfo(operationInfo);

    return mbeanOperation;
}
项目:eZooKeeper    文件:JmxUtils.java   
public static final String getOperationName(MBeanOperationInfo info) {
    StringBuilder name = new StringBuilder(info.getName());
    name.append('(');

    MBeanParameterInfo[] parameterInfos = info.getSignature();

    if (parameterInfos != null) {

        int parameterCount = parameterInfos.length;
        for (int i = 0; i < parameterCount; i++) {
            MBeanParameterInfo parameterInfo = parameterInfos[i];
            String parameterType = getTypeName(parameterInfo.getType(), parameterInfo.getDescriptor());
            name.append(parameterType);

            if (i < parameterCount - 1) {
                name.append(", ");
            }
        }

    }

    name.append(')');
    return name.toString();
}
项目:eZooKeeper    文件:MBean.java   
/**
 * TODO: Comment.
 * 
 */
private void initOperationCollections() {

    MBeanOperationInfo[] operationInfos = _Info.getOperations();
    int size = 0;
    if (operationInfos != null) {
        size = operationInfos.length;
    }
    _OperationNames = new TreeSet<String>();
    _OperationInfoMap = new HashMap<String, MBeanOperationInfo>(size);

    if (size == 0) {
        return;
    }

    for (MBeanOperationInfo operationInfo : operationInfos) {
        String operationName = JmxUtils.getOperationName(operationInfo);
        _OperationNames.add(operationName);
        _OperationInfoMap.put(operationName, operationInfo);
    }
}
项目:eZooKeeper    文件:MBeanOperationDoc.java   
public static String getImpactString(int impact) {

        switch (impact) {
        case MBeanOperationInfo.ACTION:
            return IMPACT_ACTION;

        case MBeanOperationInfo.ACTION_INFO:
            return IMPACT_ACTION_INFO;

        case MBeanOperationInfo.INFO:
            return IMPACT_INFO;

        case MBeanOperationInfo.UNKNOWN:
        default:
            return IMPACT_UNKNOWN;
        }
    }
项目:eZooKeeper    文件:MBeanDoc.java   
public List<MBeanOperationDoc> getOperations() {

        if (_Operations == null) {
            MBeanOperationInfo[] operationInfos = getInfo().getOperations();

            if (operationInfos == null || operationInfos.length == 0) {
                return Collections.emptyList();
            }

            _Operations = new ArrayList<MBeanOperationDoc>(operationInfos.length);

            for (MBeanOperationInfo operationInfo : operationInfos) {
                MBeanOperationDoc operationDoc = new MBeanOperationDoc(operationInfo);
                _Operations.add(operationDoc);
            }
        }

        return _Operations;
    }
项目:tomcat7    文件:JMXProxyServlet.java   
/**
 * Invokes an operation on an MBean.
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *                   operation. They will be converted to the appropriate
 *                   types to call the reuested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr,
                                       String operation,
                                       String[] parameters)
    throws OperationsException, MBeanException, ReflectionException {
    ObjectName oname=new ObjectName( onameStr );
    MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation);
    MBeanParameterInfo[] signature = methodInfo.getSignature();
    String[] signatureTypes = new String[signature.length];
    Object[] values = new Object[signature.length];
    for (int i = 0; i < signature.length; i++) {
       MBeanParameterInfo pi = signature[i];
       signatureTypes[i] = pi.getType();
       values[i] = registry.convertValue(pi.getType(), parameters[i] );
     }

    return mBeanServer.invoke(oname,operation,values,signatureTypes);
}
项目:tomcat7    文件:Registry.java   
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
项目:lams    文件:MBeanClientInterceptor.java   
/**
 * Routes a method invocation (not a property get/set) to the corresponding
 * operation on the managed resource.
 * @param method the method corresponding to operation on the managed resource.
 * @param args the invocation arguments
 * @return the value returned by the method invocation.
 */
private Object invokeOperation(Method method, Object[] args) throws JMException, IOException {
    MethodCacheKey key = new MethodCacheKey(method.getName(), method.getParameterTypes());
    MBeanOperationInfo info = this.allowedOperations.get(key);
    if (info == null) {
        throw new InvalidInvocationException("Operation '" + method.getName() +
                "' is not exposed on the management interface");
    }
    String[] signature = null;
    synchronized (this.signatureCache) {
        signature = this.signatureCache.get(method);
        if (signature == null) {
            signature = JmxUtils.getMethodSignature(method);
            this.signatureCache.put(method, signature);
        }
    }
    return this.serverToUse.invoke(this.objectName, method.getName(), args, signature);
}
项目:lams    文件:Registry.java   
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    String type=null;
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
项目:apache-tomcat-7.0.73-with-comment    文件:JMXProxyServlet.java   
/**
 * Invokes an operation on an MBean.
 * @param onameStr The name of the MBean.
 * @param operation The name of the operation to invoke.
 * @param parameters An array of Strings containing the parameters to the
 *                   operation. They will be converted to the appropriate
 *                   types to call the reuested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr,
                                       String operation,
                                       String[] parameters)
    throws OperationsException, MBeanException, ReflectionException {
    ObjectName oname=new ObjectName( onameStr );
    MBeanOperationInfo methodInfo = registry.getMethodInfo(oname,operation);
    MBeanParameterInfo[] signature = methodInfo.getSignature();
    String[] signatureTypes = new String[signature.length];
    Object[] values = new Object[signature.length];
    for (int i = 0; i < signature.length; i++) {
       MBeanParameterInfo pi = signature[i];
       signatureTypes[i] = pi.getType();
       values[i] = registry.convertValue(pi.getType(), parameters[i] );
     }

    return mBeanServer.invoke(oname,operation,values,signatureTypes);
}
项目:apache-tomcat-7.0.73-with-comment    文件:Registry.java   
/** Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */ 
public MBeanOperationInfo getMethodInfo( ObjectName oname, String opName )
{
    MBeanInfo info=null;
    try {
        info=server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info( "Can't find metadata " + oname );
        return null;
    }
    MBeanOperationInfo attInfo[]=info.getOperations();
    for( int i=0; i<attInfo.length; i++ ) {
        if( opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
项目:lazycat    文件:JMXProxyServlet.java   
/**
 * Invokes an operation on an MBean.
 * 
 * @param onameStr
 *            The name of the MBean.
 * @param operation
 *            The name of the operation to invoke.
 * @param parameters
 *            An array of Strings containing the parameters to the
 *            operation. They will be converted to the appropriate types to
 *            call the requested operation.
 * @return The value returned by the requested operation.
 */
private Object invokeOperationInternal(String onameStr, String operation, String[] parameters)
        throws OperationsException, MBeanException, ReflectionException {
    ObjectName oname = new ObjectName(onameStr);
    MBeanOperationInfo methodInfo = registry.getMethodInfo(oname, operation);
    MBeanParameterInfo[] signature = methodInfo.getSignature();
    String[] signatureTypes = new String[signature.length];
    Object[] values = new Object[signature.length];
    for (int i = 0; i < signature.length; i++) {
        MBeanParameterInfo pi = signature[i];
        signatureTypes[i] = pi.getType();
        values[i] = registry.convertValue(pi.getType(), parameters[i]);
    }

    return mBeanServer.invoke(oname, operation, values, signatureTypes);
}
项目:jdk8u-jdk    文件:MustBeValidCommand.java   
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
项目:jdk8u-jdk    文件:MXBeanInteropTest2.java   
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
项目:openjdk-jdk10    文件:MustBeValidCommand.java   
public static void main(String[] args) throws Exception {
    // Instantiate the MBean server
    //
    final MBeanAttributeInfo[]    atts   = makeAttInfos(attributes);
    final MBeanConstructorInfo[]  ctors  = makeCtorInfos(constructors);
    final MBeanOperationInfo[]    ops    = makeOpInfos(operations);
    final MBeanNotificationInfo[] notifs =
        makeNotifInfos(notificationclasses);

    for (int i=0; i<mbeanclasses.length;i++) {
        System.out.println("Create an MBeanInfo: " + mbeanclasses[i][0]);
        final MBeanInfo mbi =
            new MBeanInfo(mbeanclasses[i][1],mbeanclasses[i][0],
                          atts, ctors, ops, notifs);
    }

    // Test OK!
    //
    System.out.println("All MBeanInfo successfuly created!");
    System.out.println("Bye! Bye!");
}
项目:openjdk-jdk10    文件:MXBeanInteropTest2.java   
private void printMBeanInfo(MBeanInfo mbInfo) {
    System.out.println("Description " + mbInfo.getDescription());

    for (MBeanConstructorInfo ctor : mbInfo.getConstructors()) {
        System.out.println("Constructor " + ctor.getName());
    }

    for (MBeanAttributeInfo att : mbInfo.getAttributes()) {
        System.out.println("Attribute " + att.getName()
        + " [" + att.getType() + "]");
    }

    for (MBeanOperationInfo oper : mbInfo.getOperations()) {
        System.out.println("Operation " + oper.getName());
    }

    for (MBeanNotificationInfo notif : mbInfo.getNotifications()) {
        System.out.println("Notification " + notif.getName());
    }
}
项目:lazycat    文件:Registry.java   
/**
 * Find the operation info for a method
 * 
 * @param oname
 * @param opName
 * @return the operation info for the specified operation
 */
public MBeanOperationInfo getMethodInfo(ObjectName oname, String opName) {
    MBeanInfo info = null;
    try {
        info = server.getMBeanInfo(oname);
    } catch (Exception e) {
        log.info("Can't find metadata " + oname);
        return null;
    }
    MBeanOperationInfo attInfo[] = info.getOperations();
    for (int i = 0; i < attInfo.length; i++) {
        if (opName.equals(attInfo[i].getName())) {
            return attInfo[i];
        }
    }
    return null;
}
项目:tqdev-metrics    文件:JmxReporter.java   
@Override
public MBeanInfo getMBeanInfo() {

    ArrayList<OpenMBeanAttributeInfoSupport> attributes = new ArrayList<>();

    attributes.add(new OpenMBeanAttributeInfoSupport("enabled", "enabled", SimpleType.BOOLEAN, true, true, true));
    for (String type : registry.getTypes()) {
        attributes.add(new OpenMBeanAttributeInfoSupport(type, type, getCompositeType(type), true, false, false));
    }

    OpenMBeanParameterInfo[] params = new OpenMBeanParameterInfoSupport[0];
    OpenMBeanOperationInfoSupport reset = new OpenMBeanOperationInfoSupport("reset", "Reset all Metrics", params,
            SimpleType.VOID, MBeanOperationInfo.ACTION);

    OpenMBeanInfoSupport PSOMBInfo = new OpenMBeanInfoSupport(this.getClass().getName(), description,
            attributes.toArray(new OpenMBeanAttributeInfoSupport[0]), new OpenMBeanConstructorInfoSupport[0],
            new OpenMBeanOperationInfoSupport[] { reset }, new MBeanNotificationInfo[0]);

    return PSOMBInfo;
}
项目:phone-simulator    文件:TestCheckImeiClientStandardManMBean.java   
@Override
public MBeanInfo getMBeanInfo() {

    MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[] {
            // TODO mnowa: add/correct attributes here
            new MBeanAttributeInfo("Imei", String.class.getName(), "IMEI's digits string", true, true, false),
            new MBeanAttributeInfo("MapProtocolVersion", MapProtocolVersion.class.getName(), "MAP protocol version", true, true, false),
            new MBeanAttributeInfo("MapProtocolVersion_Value", String.class.getName(), "MAP protocol version", true, false, false),
            new MBeanAttributeInfo(
                    "CheckImeiClientAction",
                    CheckImeiClientAction.class.getName(),
                    "The mode of CheckImeiClient work. When manual response user can manually send CheckImei request, when VAL_AUTO_SendCheckImeiRequest the tester sends CheckImei requests without dealay (load test)",
                    true, true, false),
            new MBeanAttributeInfo(
                    "CheckImeiClientAction_Value",
                    String.class.getName(),
                    "The mode of CheckImeiClient work. When manual response user can manually send CheckImei request, when VAL_AUTO_SendCheckImeiRequest the tester sends CheckImei requests without dealay (load test)",
                    true, false, false),
            new MBeanAttributeInfo("MaxConcurrentDialogs", int.class.getName(), "The count of maximum active MAP dialogs when the auto sending mode", true,
                    true, false),
            new MBeanAttributeInfo("OneNotificationFor100Dialogs", boolean.class.getName(),
                    "If true there will be only one notification per every 100 sent dialogs (recommended for the auto sending mode)", true, true, true),

    };

    MBeanParameterInfo[] performCheckImeiParam = new MBeanParameterInfo[] { new MBeanParameterInfo("imei", String.class.getName(), "IMEI's digits string")};
    MBeanParameterInfo[] signString = new MBeanParameterInfo[] { new MBeanParameterInfo("val", String.class.getName(), "Index number or value") };

    MBeanOperationInfo[] operations = new MBeanOperationInfo[] {
            new MBeanOperationInfo("performCheckImeiRequest", "Send CheckIMEI request for provided IMEI", performCheckImeiParam/*signString*/ , String.class.getName(), MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("putMapProtocolVersion", "MAP protocol version: " + "1, 2 or 3", signString, Void.TYPE.getName(),
                    MBeanOperationInfo.ACTION),
            new MBeanOperationInfo("closeCurrentDialog", "Closing the current dialog", null, String.class.getName(), MBeanOperationInfo.ACTION),

            new MBeanOperationInfo("putCheckImeiClientAction",
                    "The mode of CheckImeiClient work. 1:VAL_MANUAL_OPERATION,2:VAL_AUTO_SendCheckImeiRequest", signString, Void.TYPE.getName(),
                    MBeanOperationInfo.ACTION),
    };
    return new MBeanInfo(TestCheckImeiClientMan.class.getName(), "CheckImeiClient test parameters management", attributes, null, operations, null);
}
项目:APacheSynapseSimplePOC    文件:JBoss.java   
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc )
        throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException {
    Object[] params = new Object[1];
    params[ 0 ] = payloadObject;
    System.err.println("Querying MBeans");
    Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null);
    System.err.println("Found " + testMBeans.size() + " MBeans");
    for ( ObjectInstance oi : testMBeans ) {
        MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName());
        for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) {
            try {
                mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {});
                System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS");
                return;
            }
            catch ( Throwable e ) {
                String msg = e.getMessage();
                if ( msg.startsWith("java.lang.ClassNotFoundException:") ) {
                    int start = msg.indexOf('"');
                    int stop = msg.indexOf('"', start + 1);
                    String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>";
                    if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) {
                        int cstart = msg.indexOf(':');
                        int cend = msg.indexOf(' ', cstart + 2);
                        String cls = msg.substring(cstart + 2, cend);
                        System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")");
                    }
                }
                else {
                    System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg);
                    return;
                }
            }
        }
    }
}
项目:eZooKeeper    文件:MBean.java   
/**
 * TODO: Comment.
 * 
 * @param operationName
 * @return
 */
public MBeanOperationInfo getOperationInfo(String operationName) {
    if (_OperationInfoMap == null) {
        initOperationCollections();
    }
    return _OperationInfoMap.get(operationName);
}
项目:truevfs    文件:JmxManagerView.java   
@Override
protected String getDescription(final MBeanOperationInfo info) {
    switch (info.getName()) {
    case "sync":
        return "Synchronizes all file systems and eventually unmounts them.";
    default:
        return null;
    }
}
项目:truevfs    文件:JmxModelView.java   
@Override
protected String getDescription(final MBeanOperationInfo info) {
    switch (info.getName()) {
    case "sync":
        return "Synchronizes this file system and all enclosed file systems and eventually unmounts them.";
    default:
        return null;
    }
}
项目:oscm    文件:SetConfigurationSetting.java   
@Override
public synchronized MBeanInfo getMBeanInfo() {
    MBeanParameterInfo[] parameter = new MBeanParameterInfo[] {
            new MBeanParameterInfo("informationId", "java.lang.String",
                    "The information ID which the value will be changed. e.g. AUTH_MODE"),
            new MBeanParameterInfo("value", "java.lang.String",
                    "The value to be set for the information ID. e.g. INTERNAL, SAML_SP") };

    MBeanOperationInfo[] operations = { new MBeanOperationInfo(
            SET_CONFIGURATION_SETTING, "Set configuration setting",
            parameter, "java.lang.String", MBeanOperationInfo.ACTION) };

    return new MBeanInfo(this.getClass().getName(),
            "Set Configuration Setting MBean", null, null, operations, null);
}
项目:oscm    文件:StartBillingRun.java   
@Override
public synchronized MBeanInfo getMBeanInfo() {
    MBeanParameterInfo[] parameter = new MBeanParameterInfo[] { new MBeanParameterInfo(
            "currentDate", "java.lang.String",
            "The current date for the billing run. Format is "
                    + DATE_FORMAT.toUpperCase()) };

    MBeanOperationInfo[] operations = { new MBeanOperationInfo(
            START_BILLING_RUN, "Start billing run", parameter,
            "java.lang.String", MBeanOperationInfo.ACTION) };

    return new MBeanInfo(this.getClass().getName(), "Billing Run MBean",
            null, null, operations, null);
}
项目:lams    文件:AbstractReflectiveMBeanInfoAssembler.java   
/**
 * Creates an instance of {@code ModelMBeanOperationInfo} for the
 * given method. Populates the parameter info for the operation.
 * @param method the {@code Method} to create a {@code ModelMBeanOperationInfo} for
 * @param name the logical name for the operation (method name or property name);
 * not used by the default implementation but possibly by subclasses
 * @param beanKey the key associated with the MBean in the beans map
 * of the {@code MBeanExporter}
 * @return the {@code ModelMBeanOperationInfo}
 */
protected ModelMBeanOperationInfo createModelMBeanOperationInfo(Method method, String name, String beanKey) {
    MBeanParameterInfo[] params = getOperationParameters(method, beanKey);
    if (params.length == 0) {
        return new ModelMBeanOperationInfo(getOperationDescription(method, beanKey), method);
    }
    else {
        return new ModelMBeanOperationInfo(method.getName(),
            getOperationDescription(method, beanKey),
            getOperationParameters(method, beanKey),
            method.getReturnType().getName(),
            MBeanOperationInfo.UNKNOWN);
    }
}
项目:OpenJSharp    文件:MBeanIntrospector.java   
public void visitOperation(String operationName,
        M operation) {
    MBeanOperationInfo mboi =
            getMBeanOperationInfo(operationName, operation);

    ops.add(mboi);
}
项目:OpenJSharp    文件:MBeanIntrospector.java   
/** Make an MBeanInfo based on the attributes and operations
 *  found in the interface. */
MBeanInfo makeMBeanInfo(Class<?> mbeanInterface,
        String description) {
    final MBeanAttributeInfo[] attrArray =
            attrs.toArray(new MBeanAttributeInfo[0]);
    final MBeanOperationInfo[] opArray =
            ops.toArray(new MBeanOperationInfo[0]);
    final String interfaceClassName =
            "interfaceClassName=" + mbeanInterface.getName();
    final Descriptor classNameDescriptor =
            new ImmutableDescriptor(interfaceClassName);
    final Descriptor mbeanDescriptor = getBasicMBeanDescriptor();
    final Descriptor annotatedDescriptor =
            Introspector.descriptorForElement(mbeanInterface);
    final Descriptor descriptor =
        DescriptorCache.getInstance().union(
            classNameDescriptor,
            mbeanDescriptor,
            annotatedDescriptor);

    return new MBeanInfo(mbeanInterface.getName(),
            description,
            attrArray,
            null,
            opArray,
            null,
            descriptor);
}
项目:OpenJSharp    文件:ModelMBeanInfoSupport.java   
public ModelMBeanOperationInfo getOperation(String inName)
throws MBeanException, RuntimeOperationsException {
    ModelMBeanOperationInfo retInfo = null;
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getOperation(String)", "Entry");
    }
    if (inName == null) {
        throw new RuntimeOperationsException(
                new IllegalArgumentException("inName is null"),
                "Exception occurred trying to get the " +
                "ModelMBeanOperationInfo of the MBean");
    }
    MBeanOperationInfo[] operList = modelMBeanOperations; //this.getOperations();
    int numOpers = 0;
    if (operList != null) numOpers = operList.length;

    for (int i=0; (i < numOpers) && (retInfo == null); i++) {
        if (inName.equals(operList[i].getName())) {
            retInfo = ((ModelMBeanOperationInfo) operList[i].clone());
        }
    }
    if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
        MODELMBEAN_LOGGER.logp(Level.FINER,
                ModelMBeanInfoSupport.class.getName(),
                "getOperation(String)", "Exit");
    }

    return retInfo;
}
项目:OpenJSharp    文件:ModelMBeanInfoSupport.java   
/**
 * Deserializes a {@link ModelMBeanInfoSupport} from an {@link ObjectInputStream}.
 */
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException {
    if (compat) {
        // Read an object serialized in the old serial form
        //
        ObjectInputStream.GetField fields = in.readFields();
        modelMBeanDescriptor =
                (Descriptor) fields.get("modelMBeanDescriptor", null);
        if (fields.defaulted("modelMBeanDescriptor")) {
            throw new NullPointerException("modelMBeanDescriptor");
        }
        modelMBeanAttributes =
                (MBeanAttributeInfo[]) fields.get("mmbAttributes", null);
        if (fields.defaulted("mmbAttributes")) {
            throw new NullPointerException("mmbAttributes");
        }
        modelMBeanConstructors =
                (MBeanConstructorInfo[]) fields.get("mmbConstructors", null);
        if (fields.defaulted("mmbConstructors")) {
            throw new NullPointerException("mmbConstructors");
        }
        modelMBeanNotifications =
                (MBeanNotificationInfo[]) fields.get("mmbNotifications", null);
        if (fields.defaulted("mmbNotifications")) {
            throw new NullPointerException("mmbNotifications");
        }
        modelMBeanOperations =
                (MBeanOperationInfo[]) fields.get("mmbOperations", null);
        if (fields.defaulted("mmbOperations")) {
            throw new NullPointerException("mmbOperations");
        }
    } else {
        // Read an object serialized in the new serial form
        //
        in.defaultReadObject();
    }
}
项目:OpenJSharp    文件:OpenMBeanInfoSupport.java   
private static MBeanOperationInfo[]
        operationArray(OpenMBeanOperationInfo[] src) {
    if (src == null)
        return null;
    MBeanOperationInfo[] dst = new MBeanOperationInfo[src.length];
    System.arraycopy(src, 0, dst, 0, src.length);
    return dst;
}
项目:ysoserial-modified    文件:JBoss.java   
private static void doExploit ( final Object payloadObject, MBeanServerConnection mbc )
        throws IOException, InstanceNotFoundException, IntrospectionException, ReflectionException {
    Object[] params = new Object[1];
    params[ 0 ] = payloadObject;
    System.err.println("Querying MBeans");
    Set<ObjectInstance> testMBeans = mbc.queryMBeans(null, null);
    System.err.println("Found " + testMBeans.size() + " MBeans");
    for ( ObjectInstance oi : testMBeans ) {
        MBeanInfo mBeanInfo = mbc.getMBeanInfo(oi.getObjectName());
        for ( MBeanOperationInfo opInfo : mBeanInfo.getOperations() ) {
            try {
                mbc.invoke(oi.getObjectName(), opInfo.getName(), params, new String[] {});
                System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS");
                return;
            }
            catch ( Throwable e ) {
                String msg = e.getMessage();
                if ( msg.startsWith("java.lang.ClassNotFoundException:") ) {
                    int start = msg.indexOf('"');
                    int stop = msg.indexOf('"', start + 1);
                    String module = ( start >= 0 && stop > 0 ) ? msg.substring(start + 1, stop) : "<unknown>";
                    if ( !"<unknown>".equals(module) && !"org.jboss.as.jmx:main".equals(module) ) {
                        int cstart = msg.indexOf(':');
                        int cend = msg.indexOf(' ', cstart + 2);
                        String cls = msg.substring(cstart + 2, cend);
                        System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> FAIL CNFE " + cls + " (" + module + ")");
                    }
                }
                else {
                    System.err.println(oi.getObjectName() + ":" + opInfo.getName() + " -> SUCCESS|ERROR " + msg);
                    return;
                }
            }
        }
    }
}
项目:hashsdn-controller    文件:AbstractDynamicWrapper.java   
public AbstractDynamicWrapper(final Module module, final boolean writable, final ModuleIdentifier moduleIdentifier,
        final ObjectName thisWrapperObjectName, final MBeanOperationInfo[] operations,
        final MBeanServer internalServer, final MBeanServer configMBeanServer) {
    this.module = module;
    this.moduleIdentifier = moduleIdentifier;
    this.internalServer = internalServer;
    this.objectNameInternal = thisWrapperObjectName;
    // register the actual instance into an mbean server.
    registerActualModule(objectNameInternal, configMBeanServer);
    Set<Class<?>> jmxInterfaces = InterfacesHelper.getMXInterfaces(module.getClass());
    this.attributeHolderMap = buildMBeanInfo(writable, moduleIdentifier, jmxInterfaces, objectNameInternal);
    this.mbeanInfo = generateMBeanInfo(module, attributeHolderMap, operations, jmxInterfaces);
}
项目:jdk8u-jdk    文件:MBeanIntrospector.java   
public void visitOperation(String operationName,
        M operation) {
    MBeanOperationInfo mboi =
            getMBeanOperationInfo(operationName, operation);

    ops.add(mboi);
}
项目:jdk8u-jdk    文件:MBeanIntrospector.java   
/** Make an MBeanInfo based on the attributes and operations
 *  found in the interface. */
MBeanInfo makeMBeanInfo(Class<?> mbeanInterface,
        String description) {
    final MBeanAttributeInfo[] attrArray =
            attrs.toArray(new MBeanAttributeInfo[0]);
    final MBeanOperationInfo[] opArray =
            ops.toArray(new MBeanOperationInfo[0]);
    final String interfaceClassName =
            "interfaceClassName=" + mbeanInterface.getName();
    final Descriptor classNameDescriptor =
            new ImmutableDescriptor(interfaceClassName);
    final Descriptor mbeanDescriptor = getBasicMBeanDescriptor();
    final Descriptor annotatedDescriptor =
            Introspector.descriptorForElement(mbeanInterface);
    final Descriptor descriptor =
        DescriptorCache.getInstance().union(
            classNameDescriptor,
            mbeanDescriptor,
            annotatedDescriptor);

    return new MBeanInfo(mbeanInterface.getName(),
            description,
            attrArray,
            null,
            opArray,
            null,
            descriptor);
}