Package org.springframework.aop.framework

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


    ctx.refresh();

    EventPublicationInterceptor interceptor =
        (EventPublicationInterceptor) ctx.getBean("publisher");
    ProxyFactory factory = new ProxyFactory(target);
    factory.addAdvice(0, interceptor);

    ITestBean testBean = (ITestBean) factory.getProxy();

    // invoke any method on the advised proxy to see if the interceptor has been invoked
    testBean.getAge();
View Full Code Here


    // Build a proxy that also exposes the JAX-WS BindingProvider interface.
    ProxyFactory pf = new ProxyFactory();
    pf.addInterface(getServiceInterface());
    pf.addInterface(BindingProvider.class);
    pf.addAdvice(this);
    this.serviceProxy = pf.getProxy(this.beanClassLoader);
  }


  public Object getObject() {
View Full Code Here

    JmxTestBean bean = new JmxTestBean();
    bean.setName("Rob Harrop");

    ProxyFactory factory = new ProxyFactory();
    factory.setTarget(bean);
    factory.addAdvice(new NopInterceptor());
    factory.setInterfaces(new Class[]{IJmxTestBean.class});

    IJmxTestBean proxy = (IJmxTestBean) factory.getProxy();
    String name = "bean:mmm=whatever";
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

    MockControl contextControl = contextControl(jndiName, ejb);
 
    LocalSlsbInvokerInterceptor si = configuredInterceptor(contextControl, jndiName);
 
    ProxyFactory pf = new ProxyFactory(new Class[] { BusinessMethods.class } );
    pf.addAdvice(si);
    BusinessMethods target = (BusinessMethods) pf.getProxy();
 
    assertTrue(target.targetMethod() == retVal);
 
    contextControl.verify();
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

    MockControl contextControl = contextControl(jndiName, ejb);

    LocalSlsbInvokerInterceptor si = configuredInterceptor(contextControl, jndiName);

    ProxyFactory pf = new ProxyFactory(new Class[] { BusinessMethods.class } );
    pf.addAdvice(si);
    BusinessMethods target = (BusinessMethods) pf.getProxy();

    assertTrue(target.targetMethod() == retVal);

    contextControl.verify();
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

    MockControl contextControl = contextControl(jndiName, ejb);

    LocalSlsbInvokerInterceptor si = configuredInterceptor(contextControl, jndiName);

    ProxyFactory pf = new ProxyFactory(new Class[] { LocalInterfaceWithBusinessMethods.class } );
    pf.addAdvice(si);
    LocalInterfaceWithBusinessMethods target = (LocalInterfaceWithBusinessMethods) pf.getProxy();

    try {
      target.targetMethod();
      fail("Should have thrown exception");
View Full Code Here

  }

  protected Object configuredProxy(SimpleRemoteSlsbInvokerInterceptor si, Class ifc) throws NamingException {
    si.afterPropertiesSet();
    ProxyFactory pf = new ProxyFactory(new Class[] {ifc});
    pf.addAdvice(si);
    return pf.getProxy();
  }


  public void testPerformsLookup() throws Exception {
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.