Package org.springframework.aop.framework

Examples of org.springframework.aop.framework.ProxyFactory.addInterface()


  @SuppressWarnings("unchecked")
  private static <T> T initProxy(Class<?> type, ControllerMethodInvocationInterceptor interceptor) {
    if (type.isInterface()) {
      ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
      factory.addInterface(type);
      factory.addInterface(MethodInvocationInfo.class);
      factory.addAdvice(interceptor);
      return (T) factory.getProxy();
    }
    else {
View Full Code Here


  @SuppressWarnings("unchecked")
  private static <T> T initProxy(Class<?> type, ControllerMethodInvocationInterceptor interceptor) {
    if (type.isInterface()) {
      ProxyFactory factory = new ProxyFactory(EmptyTargetSource.INSTANCE);
      factory.addInterface(type);
      factory.addInterface(MethodInvocationInfo.class);
      factory.addAdvice(interceptor);
      return (T) factory.getProxy();
    }
    else {
      Enhancer enhancer = new Enhancer();
View Full Code Here

              "Cannot deactivate 'lookupOnStartup' without specifying a 'proxyInterface' or 'expectedType'");
        }
        Class<?>[] ifcs = ClassUtils.getAllInterfacesForClass(targetClass, jof.beanClassLoader);
        for (Class<?> ifc : ifcs) {
          if (Modifier.isPublic(ifc.getModifiers())) {
            proxyFactory.addInterface(ifc);
          }
        }
      }
      if (jof.exposeAccessContext) {
        proxyFactory.addAdvice(new JndiContextExposingInterceptor(jof.getJndiTemplate()));
View Full Code Here

    };
    ProxyFactory pf = new ProxyFactory();
    pf.setTargetSource(ts);
    Class<?> dependencyType = descriptor.getDependencyType();
    if (dependencyType.isInterface()) {
      pf.addInterface(dependencyType);
    }
    return pf.getProxy(beanFactory.getBeanClassLoader());
  }

}
View Full Code Here

  public void testAopJdkProxy() throws Exception {
    ModelMap map = new ModelMap();
    ProxyFactory factory = new ProxyFactory();
    Map<?, ?> target = new HashMap<Object, Object>();
    factory.setTarget(target);
    factory.addInterface(Map.class);
    Object proxy = factory.getProxy();
    map.addAttribute(proxy);
    assertSame(proxy, map.get("map"));
  }
View Full Code Here

  public void testAopJdkProxyWithMultipleInterfaces() throws Exception {
    ModelMap map = new ModelMap();
    Map<?, ?> target = new HashMap<Object, Object>();
    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(target);
    factory.addInterface(Serializable.class);
    factory.addInterface(Cloneable.class);
    factory.addInterface(Comparable.class);
    factory.addInterface(Map.class);
    Object proxy = factory.getProxy();
    map.addAttribute(proxy);
View Full Code Here

    ModelMap map = new ModelMap();
    Map<?, ?> target = new HashMap<Object, Object>();
    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(target);
    factory.addInterface(Serializable.class);
    factory.addInterface(Cloneable.class);
    factory.addInterface(Comparable.class);
    factory.addInterface(Map.class);
    Object proxy = factory.getProxy();
    map.addAttribute(proxy);
    assertSame(proxy, map.get("map"));
View Full Code Here

    Map<?, ?> target = new HashMap<Object, Object>();
    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(target);
    factory.addInterface(Serializable.class);
    factory.addInterface(Cloneable.class);
    factory.addInterface(Comparable.class);
    factory.addInterface(Map.class);
    Object proxy = factory.getProxy();
    map.addAttribute(proxy);
    assertSame(proxy, map.get("map"));
  }
View Full Code Here

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(target);
    factory.addInterface(Serializable.class);
    factory.addInterface(Cloneable.class);
    factory.addInterface(Comparable.class);
    factory.addInterface(Map.class);
    Object proxy = factory.getProxy();
    map.addAttribute(proxy);
    assertSame(proxy, map.get("map"));
  }
View Full Code Here

   */
  protected Object getProxyForService() {
    checkService();
    checkServiceInterface();
    ProxyFactory proxyFactory = new ProxyFactory();
    proxyFactory.addInterface(getServiceInterface());
    if (this.registerTraceInterceptor != null ?
        this.registerTraceInterceptor.booleanValue() : this.interceptors == null) {
      proxyFactory.addAdvice(new RemoteInvocationTraceInterceptor(getExporterName()));
    }
    if (this.interceptors != null) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.