Java Code Examples for javax.management.DynamicMBean#invoke()

The following examples show how to use javax.management.DynamicMBean#invoke() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultMBeanServerInterceptor.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 2
Source File: DynamicMBeanFactoryOperationsTest.java    From datakernel with Apache License 2.0 6 votes vote down vote up
@Test
public void itShouldInvokeAnnotanedOperationsThroughDynamicMBeanInterface() throws Exception {
	BeanStubWithOperations bean = new BeanStubWithOperations();
	DynamicMBean mbean = DynamicMBeanFactory.create()
			.createDynamicMBean(singletonList(bean), defaultSettings(), false);

	mbean.invoke("increment", null, null);
	mbean.invoke("increment", null, null);

	mbean.invoke("addInfo", new Object[]{"data1"}, new String[]{String.class.getName()});
	mbean.invoke("addInfo", new Object[]{"data2"}, new String[]{String.class.getName()});

	mbean.invoke("multiplyAndAdd", new Object[]{120, 150}, new String[]{"long", "long"});

	assertEquals(bean.getCount(), 2);
	assertEquals(bean.getInfo(), "data1data2");
	assertEquals(bean.getSum(), 120 * 150);
}
 
Example 3
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 4
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 5
Source File: DefaultMBeanServerInterceptor.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 6
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 7
Source File: DefaultMBeanServerInterceptor.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 8
Source File: DefaultMBeanServerInterceptor.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 9
Source File: DefaultMBeanServerInterceptor.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 10
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 11
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 12
Source File: DefaultMBeanServerInterceptor.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 13
Source File: DefaultMBeanServerInterceptor.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 14
Source File: DefaultMBeanServerInterceptor.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 15
Source File: DefaultMBeanServerInterceptor.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 16
Source File: DefaultMBeanServerInterceptor.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
public Object invoke(ObjectName name, String operationName,
                     Object params[], String signature[])
        throws InstanceNotFoundException, MBeanException,
               ReflectionException {

    name = nonDefaultDomain(name);

    DynamicMBean instance = getMBean(name);
    checkMBeanPermission(instance, operationName, name, "invoke");
    try {
        return instance.invoke(operationName, params, signature);
    } catch (Throwable t) {
        rethrowMaybeMBeanException(t);
        throw new AssertionError();
    }
}
 
Example 17
Source File: JmxExporterSpiTest.java    From ignite with Apache License 2.0 5 votes vote down vote up
/** */
public TabularDataSupport filteredSystemView(IgniteEx g, String name, Map<String, Object> filter) {
    try {
        DynamicMBean mbean = metricRegistry(g.name(), VIEWS, name);

        MBeanOperationInfo[] opers = mbean.getMBeanInfo().getOperations();

        assertEquals(1, opers.length);

        assertEquals(FILTER_OPERATION, opers[0].getName());

        MBeanParameterInfo[] paramInfo = opers[0].getSignature();

        Object params[] = new Object[paramInfo.length];
        String signature[] = new String[paramInfo.length];

        for (int i = 0; i < paramInfo.length; i++) {
            params[i] = filter.get(paramInfo[i].getName());
            signature[i] = paramInfo[i].getType();
        }

        return (TabularDataSupport)mbean.invoke(FILTER_OPERATION, params, signature);
    }
    catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 18
Source File: DynamicMBeanFactoryOperationsTest.java    From datakernel with Apache License 2.0 5 votes vote down vote up
@Ignore("does not work concurrently yet")
@Test
public void itShouldBroadcastOperationCallToAllBean() throws Exception {
	BeanStubWithOperations bean_1 = new BeanStubWithOperations();
	BeanStubWithOperations bean_2 = new BeanStubWithOperations();
	DynamicMBean mbean = DynamicMBeanFactory.create()
			.createDynamicMBean(asList(bean_1, bean_2), defaultSettings(), false);

	// set manually init value for second bean to be different from first
	bean_2.inc();
	bean_2.inc();
	bean_2.inc();
	bean_2.addInfo("second");
	bean_2.multiplyAndAdd(10, 15);

	mbean.invoke("increment", null, null);
	mbean.invoke("increment", null, null);

	mbean.invoke("addInfo", new Object[]{"data1"}, new String[]{String.class.getName()});
	mbean.invoke("addInfo", new Object[]{"data2"}, new String[]{String.class.getName()});

	mbean.invoke("multiplyAndAdd", new Object[]{120, 150}, new String[]{"long", "long"});

	// check first bean
	assertEquals(bean_1.getCount(), 2);
	assertEquals(bean_1.getInfo(), "data1data2");
	assertEquals(bean_1.getSum(), 120 * 150);

	// check second bean
	assertEquals(bean_2.getCount(), 2 + 3);
	assertEquals(bean_2.getInfo(), "second" + "data1data2");
	assertEquals(bean_2.getSum(), 10 * 15 + 120 * 150);
}