use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.
the class TraceBeforeAdvice method testBeforeAdviceWithoutJoinPoint.
private long testBeforeAdviceWithoutJoinPoint(String file, int howmany, String technology) {
ClassPathXmlApplicationContext bf = new ClassPathXmlApplicationContext(file, CLASS);
StopWatch sw = new StopWatch();
sw.start(howmany + " repeated before advice invocations with " + technology);
ITestBean adrian = (ITestBean) bf.getBean("adrian");
assertTrue(AopUtils.isAopProxy(adrian));
Advised a = (Advised) adrian;
assertTrue(a.getAdvisors().length >= 3);
assertEquals("adrian", adrian.getName());
for (int i = 0; i < howmany; i++) {
adrian.getName();
}
sw.stop();
System.out.println(sw.prettyPrint());
return sw.getLastTaskTimeMillis();
}
use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.
the class CountingAspectJAdvice method testIsProxy.
@Test
public void testIsProxy() throws Exception {
ITestBean bean = getTestBean();
assertTrue("Bean is not a proxy", AopUtils.isAopProxy(bean));
// check the advice details
Advised advised = (Advised) bean;
Advisor[] advisors = advised.getAdvisors();
assertTrue("Advisors should not be empty", advisors.length > 0);
}
use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.
the class JoinPointMonitorAtAspectJAspect method checkAtAspectJAspect.
private void checkAtAspectJAspect(String appContextFile) {
ApplicationContext context = new ClassPathXmlApplicationContext(appContextFile, getClass());
ICounter counter = (ICounter) context.getBean("counter");
assertTrue("Proxy didn't get created", counter instanceof Advised);
counter.increment();
JoinPointMonitorAtAspectJAspect callCountingAspect = (JoinPointMonitorAtAspectJAspect) context.getBean("monitoringAspect");
assertEquals("Advise didn't get executed", 1, callCountingAspect.beforeExecutions);
assertEquals("Advise didn't get executed", 1, callCountingAspect.aroundExecutions);
}
use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.
the class InterfaceExtendingAspect method testProxyCreation.
@Test
public void testProxyCreation() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass());
ITestBean testBean = (ITestBean) ctx.getBean("testBean");
AnInterface interfaceExtendingAspect = (AnInterface) ctx.getBean("interfaceExtendingAspect");
assertTrue(testBean instanceof Advised);
assertFalse(interfaceExtendingAspect instanceof Advised);
}
use of org.springframework.aop.framework.Advised in project spring-framework by spring-projects.
the class TestNamespaceHandler method testProxyingDecorator.
@Test
public void testProxyingDecorator() throws Exception {
ITestBean bean = (ITestBean) this.beanFactory.getBean("debuggingTestBean");
assertTestBean(bean);
assertTrue(AopUtils.isAopProxy(bean));
Advisor[] advisors = ((Advised) bean).getAdvisors();
assertEquals("Incorrect number of advisors", 1, advisors.length);
assertEquals("Incorrect advice class", DebugInterceptor.class, advisors[0].getAdvice().getClass());
}
Aggregations