Package org.springframework.aop

Examples of org.springframework.aop.MethodBeforeAdvice


  public boolean supportsAdvice(Advice advice) {
    return (advice instanceof MethodBeforeAdvice);
  }

  public MethodInterceptor getInterceptor(Advisor advisor) {
    MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
    return new MethodBeforeAdviceInterceptor(advice);
  }
View Full Code Here


   * The advice has no effect.
   */
  protected static class SyntheticInstantiationAdvisor extends DefaultPointcutAdvisor {

    public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
      super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
        public void before(Method method, Object[] args, Object target) {
          // Simply instantiate the aspect
          aif.getAspectInstance();
        }
      });
View Full Code Here

   */
  @SuppressWarnings("serial")
  protected static class SyntheticInstantiationAdvisor extends DefaultPointcutAdvisor {

    public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
      super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
        public void before(Method method, Object[] args, Object target) {
          // Simply instantiate the aspect
          aif.getAspectInstance();
        }
      });
View Full Code Here

   * The advice has no effect.
   */
  protected static class SyntheticInstantiationAdvisor extends DefaultPointcutAdvisor {

    public SyntheticInstantiationAdvisor(final MetadataAwareAspectInstanceFactory aif) {
      super(aif.getAspectMetadata().getPerClausePointcut(), new MethodBeforeAdvice() {
        public void before(Method method, Object[] args, Object target) {
          // Simply instantiate the aspect
          aif.getAspectInstance();
        }
      });
View Full Code Here

  public boolean supportsAdvice(Advice advice) {
    return (advice instanceof MethodBeforeAdvice);
  }

  public MethodInterceptor getInterceptor(Advisor advisor) {
    MethodBeforeAdvice advice = (MethodBeforeAdvice) advisor.getAdvice();
    return new MethodBeforeAdviceInterceptor(advice);
  }
View Full Code Here

    final int newAge = 23;
   
    ProxyFactory pf = new ProxyFactory(raw);
    pf.setExposeProxy(true);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      private int depth;
     
      public void before(Method method, Object[] args, Object target) throws Throwable {
        JoinPoint jp = AbstractAspectJAdvice.currentJoinPoint();
        assertTrue("Method named in toString", jp.toString().indexOf(method.getName()) != -1);
View Full Code Here

 
  public void testCanGetSourceLocationFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      public void before(Method method, Object[] args, Object target) throws Throwable {
        SourceLocation sloc = AbstractAspectJAdvice.currentJoinPoint().getSourceLocation();
        assertEquals("Same source location must be returned on subsequent requests",  sloc, AbstractAspectJAdvice.currentJoinPoint().getSourceLocation());
        assertEquals(TestBean.class, sloc.getWithinType());
        try {
View Full Code Here

 
  public void testCanGetStaticPartFromJoinPoint() {
    final Object raw = new TestBean();
    ProxyFactory pf = new ProxyFactory(raw);
    pf.addAdvisor(ExposeInvocationInterceptor.ADVISOR);
    pf.addAdvice(new MethodBeforeAdvice() {
      public void before(Method method, Object[] args, Object target) throws Throwable {
        StaticPart staticPart = AbstractAspectJAdvice.currentJoinPoint().getStaticPart();
        assertEquals("Same static part must be returned on subsequent requests",  staticPart, AbstractAspectJAdvice.currentJoinPoint().getStaticPart());
        assertEquals(ProceedingJoinPoint.METHOD_EXECUTION, staticPart.getKind());
        assertSame(AbstractAspectJAdvice.currentJoinPoint().getSignature(), staticPart.getSignature());
View Full Code Here

  public void testProxyConfigString() {
    TestBean target = new TestBean();
    ProxyFactory pc = new ProxyFactory(target);
    pc.setInterfaces(new Class[] {ITestBean.class});
    pc.addAdvice(new NopInterceptor());
    MethodBeforeAdvice mba = new CountingBeforeAdvice();
    Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut(), mba);
    pc.addAdvisor(advisor);
    ITestBean proxied = (ITestBean) createProxy(pc);

    String proxyConfigString = ((Advised) proxied).toProxyConfigString();
View Full Code Here

public class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor {
 
  public int count;
 
  public TestBeanAdvisor() {
    setAdvice(new MethodBeforeAdvice() {
      public void before(Method method, Object[] args, Object target) throws Throwable {
        ++count;
      }
    });
  }
View Full Code Here

TOP

Related Classes of org.springframework.aop.MethodBeforeAdvice

Copyright © 2018 www.massapicom. 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.