Tabnine Logo
org.springframework.aop.framework
Code IndexAdd Tabnine to your IDE (free)

How to use org.springframework.aop.framework

Best Java code snippets using org.springframework.aop.framework (Showing top 20 results out of 1,467)

origin: spring-projects/spring-framework

/**
 * Create a new proxy according to the settings in this factory.
 * <p>Can be called repeatedly. Effect will vary if we've added
 * or removed interfaces. Can add and remove interceptors.
 * <p>Uses a default class loader: Usually, the thread context class loader
 * (if necessary for proxy creation).
 * @return the proxy object
 */
public Object getProxy() {
  return createAopProxy().getProxy();
}
origin: spring-projects/spring-framework

/**
 * Subclasses should call this to get a new AOP proxy. They should <b>not</b>
 * create an AOP proxy with {@code this} as an argument.
 */
protected final synchronized AopProxy createAopProxy() {
  if (!this.active) {
    activate();
  }
  return getAopProxyFactory().createAopProxy(this);
}
origin: spring-projects/spring-framework

/**
 * Create a new ProxyFactory for the given interface and interceptor.
 * <p>Convenience method for creating a proxy for a single interceptor,
 * assuming that the interceptor handles all calls itself rather than
 * delegating to a target, like in the case of remoting proxies.
 * @param proxyInterface the interface that the proxy should implement
 * @param interceptor the interceptor that the proxy should invoke
 */
public ProxyFactory(Class<?> proxyInterface, Interceptor interceptor) {
  addInterface(proxyInterface);
  addAdvice(interceptor);
}
origin: spring-projects/spring-framework

/**
 * Create a proxy for the specified {@code TargetSource},
 * implementing the specified interface.
 * @param proxyInterface the interface that the proxy should implement
 * @param targetSource the TargetSource that the proxy should invoke
 * @return the proxy object
 * @see #ProxyFactory(Class, org.springframework.aop.TargetSource)
 */
@SuppressWarnings("unchecked")
public static <T> T getProxy(Class<T> proxyInterface, TargetSource targetSource) {
  return (T) new ProxyFactory(proxyInterface, targetSource).getProxy();
}
origin: spring-projects/spring-framework

@Test(expected = IllegalStateException.class)
// Should fail to get proxy as exposeProxy wasn't set to true
public void testTargetCantGetProxyByDefault() {
  NeedsToSeeProxy et = new NeedsToSeeProxy();
  ProxyFactory pf1 = new ProxyFactory(et);
  assertFalse(pf1.isExposeProxy());
  INeedsToSeeProxy proxied = (INeedsToSeeProxy) createProxy(pf1);
  proxied.incrementViaProxy();
}
origin: spring-projects/spring-framework

/**
 * As of 4.2, this method adds {@link TransactionalProxy} to the set of
 * proxy interfaces in order to avoid re-processing of transaction metadata.
 */
@Override
protected void postProcessProxyFactory(ProxyFactory proxyFactory) {
  proxyFactory.addInterface(TransactionalProxy.class);
}
origin: spring-projects/spring-framework

/**
 * Create a new ProxyFactory.
 * <p>No target, only interfaces. Must add interceptors.
 * @param proxyInterfaces the interfaces that the proxy should implement
 */
public ProxyFactory(Class<?>... proxyInterfaces) {
  setInterfaces(proxyInterfaces);
}
origin: spring-projects/spring-framework

@Test
public void testWithNoArgConstructor() {
  NoArgCtorTestBean target = new NoArgCtorTestBean("b", 1);
  target.reset();
  mockTargetSource.setTarget(target);
  AdvisedSupport pc = new AdvisedSupport();
  pc.setTargetSource(mockTargetSource);
  CglibAopProxy aop = new CglibAopProxy(pc);
  aop.setConstructorArguments(new Object[] {"Rob Harrop", 22}, new Class<?>[] {String.class, int.class});
  NoArgCtorTestBean proxy = (NoArgCtorTestBean) aop.getProxy();
  assertNotNull(proxy);
}
origin: spring-projects/spring-framework

@Test
public void testEqualsAndHashCodeDefined() {
  AdvisedSupport as = new AdvisedSupport(Named.class);
  as.setTarget(new Person());
  JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
  Named proxy = (Named) aopProxy.getProxy();
  Named named = new Person();
  assertEquals("equals()", proxy, named);
  assertEquals("hashCode()", proxy.hashCode(), named.hashCode());
}
origin: spring-projects/spring-framework

@Test(expected = AopConfigException.class)
public void testNoInterceptorsAndNoTarget() {
  AdvisedSupport pc = new AdvisedSupport(ITestBean.class);
  // Add no interceptors
  AopProxy aop = createAopProxy(pc);
  aop.getProxy();
}
origin: spring-projects/spring-framework

@Test
public void testProxyNotWrappedIfIncompatible() {
  FooBar bean = new FooBar();
  ProxyCreatorSupport as = new ProxyCreatorSupport();
  as.setInterfaces(Foo.class);
  as.setTarget(bean);
  Foo proxy = (Foo) createProxy(as);
  assertSame("Target should be returned when return types are incompatible", bean, proxy.getBarThis());
  assertSame("Proxy should be returned when return types are compatible", proxy, proxy.getFooThis());
}
origin: spring-projects/spring-framework

/**
 * Set the names of the interfaces we're proxying. If no interface
 * is given, a CGLIB for the actual class will be created.
 * <p>This is essentially equivalent to the "setInterfaces" method,
 * but mirrors TransactionProxyFactoryBean's "setProxyInterfaces".
 * @see #setInterfaces
 * @see AbstractSingletonProxyFactoryBean#setProxyInterfaces
 */
public void setProxyInterfaces(Class<?>[] proxyInterfaces) throws ClassNotFoundException {
  setInterfaces(proxyInterfaces);
}
origin: spring-projects/spring-framework

@Override
public void incrementViaProxy() {
  INeedsToSeeProxy thisViaProxy = (INeedsToSeeProxy) AopContext.currentProxy();
  thisViaProxy.increment();
  Advised advised = (Advised) thisViaProxy;
  checkAdvised(advised);
}
origin: spring-projects/spring-framework

@Override
public boolean removeAdvice(Advice advice) throws AopConfigException {
  int index = indexOf(advice);
  if (index == -1) {
    return false;
  }
  else {
    removeAdvisor(index);
    return true;
  }
}
origin: spring-projects/spring-framework

@Override
public void addAdvisor(int pos, Advisor advisor) throws AopConfigException {
  if (advisor instanceof IntroductionAdvisor) {
    validateIntroductionAdvisor((IntroductionAdvisor) advisor);
  }
  addAdvisorInternal(pos, advisor);
}
origin: spring-projects/spring-framework

/**
 * Create a AdvisedSupport instance with the given parameters.
 * @param interfaces the proxied interfaces
 */
public AdvisedSupport(Class<?>... interfaces) {
  this();
  setInterfaces(interfaces);
}
origin: spring-projects/spring-framework

/**
 * Activate this proxy configuration.
 * @see AdvisedSupportListener#activated
 */
private void activate() {
  this.active = true;
  for (AdvisedSupportListener listener : this.listeners) {
    listener.activated(this);
  }
}
origin: spring-projects/spring-framework

@Override
protected AopProxy createAopProxy(AdvisedSupport as) {
  as.setProxyTargetClass(true);
  return new CglibAopProxy(as);
}
origin: spring-projects/spring-framework

@Override
public void setBeanFactory(BeanFactory beanFactory) {
  this.beanFactory = beanFactory;
  checkInterceptorNames();
}
origin: spring-projects/spring-framework

  public TestDynamicPointcutAdvice(MethodInterceptor mi, final String pattern) {
    super(mi);
    setPointcut(new DynamicMethodMatcherPointcut() {
      @Override
      public boolean matches(Method m, @Nullable Class<?> targetClass, Object... args) {
        boolean run = m.getName().contains(pattern);
        if (run) ++count;
        return run;
      }
    });
  }
}
org.springframework.aop.framework

Most used classes

  • ProxyFactory
    Factory for AOP proxies for programmatic use, rather than via a bean factory. This class provides a
  • Advised
    Interface to be implemented by classes that hold the configuration of a factory of AOP proxies. This
  • DefaultAdvisorAutoProxyCreator
    BeanPostProcessor implementation that creates AOP proxies based on all candidate Advisors in the cu
  • AopProxyUtils
    Utility methods for AOP proxy factories. Mainly for internal use within the AOP framework.See org.sp
  • AdvisedSupport
    Superclass for AOP proxy configuration managers. These are not themselves AOP proxies, but subclasse
  • BeanNameAutoProxyCreator,
  • ReflectiveMethodInvocation,
  • AdvisorAdapterRegistry,
  • AopConfigException,
  • AopContext,
  • GlobalAdvisorAdapterRegistry,
  • AbstractAutoProxyCreator,
  • AbstractBeanFactoryAwareAdvisingPostProcessor,
  • AopProxy,
  • ProxyConfig,
  • DefaultAopProxyFactory,
  • AutoProxyUtils,
  • JdkDynamicAopProxy,
  • MethodBeforeAdviceInterceptor
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now