org.springframework.aop.framework.AdvisedSupport Java Examples
The following examples show how to use
org.springframework.aop.framework.AdvisedSupport.
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: Spring2.java From ysoserial with MIT License | 6 votes |
public Object getObject ( final String command ) throws Exception { final Object templates = Gadgets.createTemplatesImpl(command); AdvisedSupport as = new AdvisedSupport(); as.setTargetSource(new SingletonTargetSource(templates)); final Type typeTemplatesProxy = Gadgets.createProxy( (InvocationHandler) Reflections.getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as), Type.class, Templates.class); final Object typeProviderProxy = Gadgets.createMemoitizedProxy( Gadgets.createMap("getType", typeTemplatesProxy), forName("org.springframework.core.SerializableTypeWrapper$TypeProvider")); Object mitp = Reflections.createWithoutConstructor(forName("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider")); Reflections.setFieldValue(mitp, "provider", typeProviderProxy); Reflections.setFieldValue(mitp, "methodName", "newTransformer"); return mitp; }
Example #2
Source File: Spring2.java From ysoserial-modified with MIT License | 6 votes |
public Object getObject ( CmdExecuteHelper cmdHelper ) throws Exception { final Object templates = Gadgets.createTemplatesImpl(cmdHelper.getCommandArray()); AdvisedSupport as = new AdvisedSupport(); as.setTargetSource(new SingletonTargetSource(templates)); final Type typeTemplatesProxy = Gadgets.createProxy( (InvocationHandler) Reflections.getFirstCtor("org.springframework.aop.framework.JdkDynamicAopProxy").newInstance(as), Type.class, Templates.class); final Object typeProviderProxy = Gadgets.createMemoitizedProxy( Gadgets.createMap("getType", typeTemplatesProxy), forName("org.springframework.core.SerializableTypeWrapper$TypeProvider")); Object mitp = Reflections.createWithoutConstructor(forName("org.springframework.core.SerializableTypeWrapper$MethodInvokeTypeProvider")); Reflections.setFieldValue(mitp, "provider", typeProviderProxy); Reflections.setFieldValue(mitp, "methodName", "newTransformer"); return mitp; }
Example #3
Source File: JSON1.java From ysoserial-modified with MIT License | 5 votes |
/** * Will call all getter methods on payload that are defined in the given interfaces */ 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); }
Example #4
Source File: ReflectUtil.java From dog with GNU Lesser General Public License v3.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }
Example #5
Source File: MethodCheckingCallback.java From servicecomb-pack with Apache License 2.0 | 5 votes |
private Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object result = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return result; }
Example #6
Source File: MethodCheckingCallback.java From servicecomb-pack with Apache License 2.0 | 5 votes |
private Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object result = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget(); return result; }
Example #7
Source File: SpringAopHelper.java From azeroth with Apache License 2.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }
Example #8
Source File: SpringAopHelper.java From azeroth with Apache License 2.0 | 5 votes |
private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport) advised.get(aopProxy)).getTargetSource().getTarget(); return target; }
Example #9
Source File: AopTargetUtil.java From tcc-transaction with Apache License 2.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }
Example #10
Source File: AopTargetUtil.java From tcc-transaction with Apache License 2.0 | 5 votes |
private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget(); return target; }
Example #11
Source File: Jaxb2RootElementHttpMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Before public void setUp() { converter = new Jaxb2RootElementHttpMessageConverter(); rootElement = new RootElement(); DefaultAopProxyFactory proxyFactory = new DefaultAopProxyFactory(); AdvisedSupport advisedSupport = new AdvisedSupport(); advisedSupport.setTarget(rootElement); advisedSupport.setProxyTargetClass(true); AopProxy proxy = proxyFactory.createAopProxy(advisedSupport); rootElementCglib = (RootElement) proxy.getProxy(); }
Example #12
Source File: AopTargetUtils.java From spring-data-jpa-extra with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private static <T> T getCglibProxyTargetObject(Object proxy) { try { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); return (T) (((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget()); } catch (Exception e) { throw new RuntimeException(e); } }
Example #13
Source File: AopTargetUtil.java From galaxy with Apache License 2.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }
Example #14
Source File: AopTargetUtil.java From galaxy with Apache License 2.0 | 5 votes |
private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget(); return target; }
Example #15
Source File: SpringAopHelper.java From jeesuite-libs with Apache License 2.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }
Example #16
Source File: SpringAopHelper.java From jeesuite-libs with Apache License 2.0 | 5 votes |
private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget(); return target; }
Example #17
Source File: AopTargetUtils.java From shardingsphere-elasticjob-lite with Apache License 2.0 | 5 votes |
private static Object getProxyTargetObjectForCglibAndSpring4(final Object proxy) { Field h; try { h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); return ((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON throw new JobSystemException(ex); } }
Example #18
Source File: AopTargetUtils.java From shardingsphere-elasticjob-lite with Apache License 2.0 | 5 votes |
private static Object getTargetObject(final Object object) { try { Field advised = object.getClass().getDeclaredField("advised"); advised.setAccessible(true); return ((AdvisedSupport) advised.get(object)).getTargetSource().getTarget(); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON throw new JobSystemException(ex); } }
Example #19
Source File: CreateAopProxyInterceptor.java From skywalking with Apache License 2.0 | 5 votes |
@Override public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes, Object ret) throws Throwable { AdvisedSupport advisedSupport = (AdvisedSupport) allArguments[0]; Class targetClass = advisedSupport.getTargetClass(); if (targetClass != null && EnhancedInstance.class.isAssignableFrom(targetClass)) { return true; } return ret; }
Example #20
Source File: JSON1.java From ysoserial with MIT License | 5 votes |
/** * Will call all getter methods on payload that are defined in the given interfaces */ 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.newInstance("org.springframework.aop.framework.JdkDynamicAopProxy", as); InvocationHandler cdsInvocationHandler = Gadgets.createMemoizedInvocationHandler(Gadgets.createMap("getCompositeType", rt)); InvocationHandler invocationHandler = (InvocationHandler) Reflections.newInstance("com.sun.corba.se.spi.orbutil.proxy.CompositeInvocationHandlerImpl"); ((Map) Reflections.getFieldValue(invocationHandler, "classToInvocationHandler")).put(CompositeData.class, cdsInvocationHandler); Reflections.setFieldValue(invocationHandler, "defaultHandler", 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); }
Example #21
Source File: DelayQueueScaner.java From summerframework with Apache License 2.0 | 5 votes |
private AdvisedSupport getAdvisedSupport(Object proxy) throws Exception { Field h; if (AopUtils.isJdkDynamicProxy(proxy)) { h = proxy.getClass().getSuperclass().getDeclaredField("h"); } else { h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); } h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor); }
Example #22
Source File: Jaxb2RootElementHttpMessageConverterTests.java From spring-analysis-note with MIT License | 5 votes |
@Before public void setup() { converter = new Jaxb2RootElementHttpMessageConverter(); rootElement = new RootElement(); DefaultAopProxyFactory proxyFactory = new DefaultAopProxyFactory(); AdvisedSupport advisedSupport = new AdvisedSupport(); advisedSupport.setTarget(rootElement); advisedSupport.setProxyTargetClass(true); AopProxy proxy = proxyFactory.createAopProxy(advisedSupport); rootElementCglib = (RootElement) proxy.getProxy(); }
Example #23
Source File: ReflectUtil.java From dog with GNU Lesser General Public License v3.0 | 5 votes |
private static Object getJdkDynamicProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getSuperclass().getDeclaredField("h"); h.setAccessible(true); AopProxy aopProxy = (AopProxy) h.get(proxy); Field advised = aopProxy.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport)advised.get(aopProxy)).getTargetSource().getTarget(); return target; }
Example #24
Source File: DtsTransactionScaner.java From dts with Apache License 2.0 | 5 votes |
private Class<?> findTargetClass(Object proxy) throws Exception { if (AopUtils.isAopProxy(proxy)) { AdvisedSupport advised = getAdvisedSupport(proxy); Object target = advised.getTargetSource().getTarget(); return findTargetClass(target); } else { return proxy.getClass(); } }
Example #25
Source File: DtsTransactionScaner.java From dts with Apache License 2.0 | 5 votes |
private AdvisedSupport getAdvisedSupport(Object proxy) throws Exception { Field h; if (AopUtils.isJdkDynamicProxy(proxy)) { h = proxy.getClass().getSuperclass().getDeclaredField("h"); } else { h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); } h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); return (AdvisedSupport)advised.get(dynamicAdvisedInterceptor); }
Example #26
Source File: DtsTransactionScaner.java From dts with Apache License 2.0 | 5 votes |
@Override protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { try { synchronized (proxyedSet) { if (proxyedSet.contains(beanName)) { return bean; } proxyedSet.add(beanName); Class<?> serviceInterface = findTargetClass(bean); Method[] methods = serviceInterface.getMethods(); LinkedList<MethodDesc> methodDescList = new LinkedList<MethodDesc>(); for (Method method : methods) { DtsTransaction anno = method.getAnnotation(DtsTransaction.class); if (anno != null) { methodDescList.add(makeMethodDesc(anno, method)); } } if (methodDescList.size() != 0) { interceptor = new TransactionDtsInterceptor(methodDescList); } else { return bean; } if (!AopUtils.isAopProxy(bean)) { bean = super.wrapIfNecessary(bean, beanName, cacheKey); } else { AdvisedSupport advised = getAdvisedSupport(bean); Advisor[] advisor = buildAdvisors(beanName, getAdvicesAndAdvisorsForBean(null, null, null)); for (Advisor avr : advisor) { advised.addAdvisor(0, avr); } } return bean; } } catch (Exception e) { throw new DtsException(e); } }
Example #27
Source File: Jaxb2RootElementHttpMessageConverterTests.java From java-technology-stack with MIT License | 5 votes |
@Before public void setup() { converter = new Jaxb2RootElementHttpMessageConverter(); rootElement = new RootElement(); DefaultAopProxyFactory proxyFactory = new DefaultAopProxyFactory(); AdvisedSupport advisedSupport = new AdvisedSupport(); advisedSupport.setTarget(rootElement); advisedSupport.setProxyTargetClass(true); AopProxy proxy = proxyFactory.createAopProxy(advisedSupport); rootElementCglib = (RootElement) proxy.getProxy(); }
Example #28
Source File: DelayQueueScaner.java From summerframework with Apache License 2.0 | 5 votes |
private Class<?> findTargetClass(Object proxy) throws Exception { if (AopUtils.isAopProxy(proxy)) { AdvisedSupport advised = this.getAdvisedSupport(proxy); Object target = advised.getTargetSource().getTarget(); return findTargetClass(target); } else { return proxy.getClass(); } }
Example #29
Source File: DelayQueueScaner.java From summerframework with Apache License 2.0 | 5 votes |
@Override protected Object wrapIfNecessary(Object bean, String beanName, Object cacheKey) { try { Object beanCopy = bean; synchronized (proxyedSet) { if (proxyedSet.contains(beanName)) { return beanCopy; } proxyedSet.add(beanName); Class<?> serviceInterface = this.findTargetClass(beanCopy); Method[] methods = serviceInterface.getMethods(); List<Method> annotationMethods = Lists.newArrayList(); for (Method method : methods) { Delay anno = method.getAnnotation(Delay.class); if (anno != null) { annotationMethods.add(method); } } if (!annotationMethods.isEmpty()) { interceptor = new DelayQueueInterceptor(rabbitTemplate); } else { return beanCopy; } if (!AopUtils.isAopProxy(beanCopy)) { beanCopy = super.wrapIfNecessary(beanCopy, beanName, cacheKey); } else { AdvisedSupport advised = this.getAdvisedSupport(beanCopy); Advisor[] advisor = buildAdvisors(beanName, this.getAdvicesAndAdvisorsForBean(null, null, null)); for (Advisor avr : advisor) { advised.addAdvisor(0, avr); } } return beanCopy; } } catch (Exception e) { throw new RuntimeException(e); } }
Example #30
Source File: AopTargetUtils.java From timer with Apache License 2.0 | 5 votes |
private static Object getCglibProxyTargetObject(Object proxy) throws Exception { Field h = proxy.getClass().getDeclaredField("CGLIB$CALLBACK_0"); h.setAccessible(true); Object dynamicAdvisedInterceptor = h.get(proxy); Field advised = dynamicAdvisedInterceptor.getClass().getDeclaredField("advised"); advised.setAccessible(true); Object target = ((AdvisedSupport) advised.get(dynamicAdvisedInterceptor)).getTargetSource().getTarget(); return target; }