Example usage for org.springframework.util MethodInvoker setTargetClass

List of usage examples for org.springframework.util MethodInvoker setTargetClass

Introduction

In this page you can find the example usage for org.springframework.util MethodInvoker setTargetClass.

Prototype

public void setTargetClass(@Nullable Class<?> targetClass) 

Source Link

Document

Set the target class on which to call the target method.

Usage

From source file:org.openspaces.core.space.mode.SpaceModeContextLoader.java

/**
 * A hack to only send the application event on the child application context we are loading,
 * without propogating it to the parent application context (when using {@link
 * ApplicationContext#publishEvent(org.springframework.context.ApplicationEvent)} which will
 * create a recursive event calling./*from w w w .  ja  v  a2s . com*/
 */
protected void publishEvent(ApplicationEvent applicationEvent) {
    if (applicationContext == null) {
        return;
    }
    ApplicationEventMulticaster eventMulticaster;
    try {
        MethodInvoker methodInvoker = new MethodInvoker();
        methodInvoker.setTargetClass(AbstractApplicationContext.class);
        methodInvoker.setTargetMethod("getApplicationEventMulticaster");
        methodInvoker.setTargetObject(applicationContext);
        methodInvoker.setArguments(null);
        methodInvoker.prepare();
        eventMulticaster = (ApplicationEventMulticaster) methodInvoker.invoke();
    } catch (Exception e) {
        logger.warn("Failed to get application event multicaster to publish event to child application context",
                e);
        return;
    }
    eventMulticaster.multicastEvent(applicationEvent);
}

From source file:org.pssframework.jmx.MBeanServerConnectionInterceptor.java

private Object processed(MethodInvocation invocation) throws Throwable {
    MethodInvoker invoker = new MethodInvoker();
    invoker.setArguments(invocation.getArguments());
    invoker.setTargetObject(connection);
    invoker.setTargetClass(this.connection.getClass());
    invoker.setTargetMethod(invocation.getMethod().getName());
    invoker.prepare();// ww w.j  a  v a  2  s . c o  m
    return invoker.invoke();
}