assertNotSame(cache1.getClassAdvisor(), cache3.getClassAdvisor());
}
public void testContainerProxy() throws Exception
{
InstanceDomain domain = new InstanceDomain(AspectManager.instance(), "blah", false);
InterfaceIntroduction intro = new InterfaceIntroduction("intro", "*", null);
String[] intfs = {MixinInterface.class.getName()};
InterfaceIntroduction.Mixin mixin = new InterfaceIntroduction.Mixin(Mixin.class.getName(), intfs, null, false);
intro.getMixins().add(mixin);
domain.addInterfaceIntroduction(intro);
AspectDefinition def = new AspectDefinition("aspect", Scope.PER_VM, new GenericAspectFactory(EchoInterceptor.class.getName(), null));
domain.addAspectDefinition(def);
AdviceFactory advice = new AdviceFactory(def, "invoke");
domain.addInterceptorFactory(advice.getName(), advice);
//PointcutExpression pointcut = new PointcutExpression("pointcut", "execution(java.lang.String $instanceof{" + POJO.class.getName() + "}->helloWorld(..))");
{
PointcutExpression pointcut = new PointcutExpression("pointcut", "execution(java.lang.String " + POJO.class.getName() + "->helloWorld(..))");
domain.addPointcut(pointcut);
InterceptorFactory[] interceptors = {advice};
AdviceBinding binding = new AdviceBinding("pojo-binding", pointcut, null, null, interceptors);
domain.addBinding(binding);
}
{
PointcutExpression pointcut = new PointcutExpression("mixin-pointcut", "execution(java.lang.String $instanceof{" + MixinInterface.class.getName() + "}->intercepted(..))");
domain.addPointcut(pointcut);
InterceptorFactory[] interceptors = {advice};
AdviceBinding binding = new AdviceBinding("mixin-binding", pointcut, null, null, interceptors);
domain.addBinding(binding);
}
Class<?> proxyClass = ContainerProxyFactory.getProxyClass(POJO.class, domain);
ClassProxyContainer container = new ClassProxyContainer("test", domain);
domain.setAdvisor(container);
container.setClass(proxyClass);
container.initializeClassContainer();
POJO proxy = (POJO) proxyClass.newInstance();
AspectManaged cp = (AspectManaged)proxy;
cp.setAdvisor(container);