List of usage examples for org.springframework.util MethodInvoker setTargetClass
public void setTargetClass(@Nullable Class<?> targetClass)
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(); }