private void buildInterceptorChain(InterceptorInfo interceptorInfo) throws Exception { Set<Class> listOfClasses = new HashSet<Class>(); for(String name : interceptorInfo.getInterceptorClassNames()) { listOfClasses.add( loader.loadClass(name)); } // Add framework interceptors to list, but check for existence of // class before attempting to load it via application class loader for(InterceptorDescriptor frameworkInterceptor : frameworkInterceptors) { Class clazz = frameworkInterceptor.getInterceptorClass(); if( clazz == null ) { clazz = loader.loadClass(frameworkInterceptor.getInterceptorClassName()); } listOfClasses.add(clazz); } initInterceptorClasses(listOfClasses); interceptorsExists = (listOfClasses.size() > 0) || interceptorInfo.getHasTargetClassAroundInvoke(); int size = CallbackType.values().length; callbackChain = new CallbackChainImpl[size]; initCallbackIndices(interceptorInfo.getAroundConstructInterceptors(), CallbackType.AROUND_CONSTRUCT); initCallbackIndices(interceptorInfo.getPostConstructInterceptors(), CallbackType.POST_CONSTRUCT); initCallbackIndices(interceptorInfo.getPreDestroyInterceptors(), CallbackType.PRE_DESTROY); }
public InterceptorManager(Logger _logger, ClassLoader classLoader, String className, InterceptorInfo interceptorInfo) throws Exception { this._logger = _logger; loader = classLoader; beanClassName = className; this.beanClass = loader.loadClass(beanClassName); this.interceptorInfo = interceptorInfo; if( interceptorInfo.getSupportRuntimeDelegate() ) { frameworkInterceptors.add(SystemInterceptorProxy.createInterceptorDesc()); } buildInterceptorChain(interceptorInfo); }
InterceptorInfo interceptorInfo = new InterceptorInfo(); interceptorInfo.setTargetClass(targetClass); interceptorInfo.setInterceptorClassNames(interceptorClasses); interceptorInfo.setPostConstructInterceptors (next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT)); interceptorInfo.setPreDestroyInterceptors (next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY)); if( next.hasAroundInvokeMethod() ) { interceptorInfo.setHasTargetClassAroundInvoke(true); interceptorInfo.setAroundInvokeInterceptorChains(interceptorChains); interceptorInfo.setSupportRuntimeDelegate(true);
public JavaEEInterceptorBuilder createBuilder(InterceptorInfo info) throws Exception { Class targetObjectClass = info.getTargetClass(); // Create an interface with all public methods of the target class // in order to create a dynamic proxy String subClassIntfName = EJBUtils.getGeneratedOptionalInterfaceName(targetObjectClass.getName()); EjbOptionalIntfGenerator gen = new EjbOptionalIntfGenerator(targetObjectClass.getClassLoader()); gen.generateOptionalLocalInterface(targetObjectClass, subClassIntfName); Class subClassIntf = gen.loadClass(subClassIntfName); String beanSubClassName = subClassIntfName + "__Bean__"; // Generate a sub-class of the application's class. Use an instance of this subclass // as the actual object passed back to the application. The sub-class instance // delegates all public methods to the dyanamic proxy, which calls the // InvocationHandler. gen.generateOptionalLocalInterfaceSubClass( targetObjectClass, beanSubClassName, subClassIntf); Class subClass = gen.loadClass(beanSubClassName); // TODO do interceptor builder once per managed bean InterceptorManager interceptorManager = new InterceptorManager(_logger, targetObjectClass.getClassLoader(), targetObjectClass.getName(), info); JavaEEInterceptorBuilderImpl builderImpl = new JavaEEInterceptorBuilderImpl(info, interceptorManager, gen, subClassIntf, subClass); return builderImpl; }
interceptorInfo.getAroundInvokeInterceptors(beanMethod);
InterceptorInfo interceptorInfo = new InterceptorInfo(); interceptorInfo.setTargetClass(targetClass); interceptorInfo.setInterceptorClassNames(interceptorClasses); interceptorInfo.setAroundConstructInterceptors (next.getAroundConstructCallbackInterceptors(targetClass, getConstructor(targetClass, isCDIBundle))); interceptorInfo.setPostConstructInterceptors (next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.POST_CONSTRUCT)); interceptorInfo.setPreDestroyInterceptors (next.getCallbackInterceptors(LifecycleCallbackDescriptor.CallbackType.PRE_DESTROY)); if( next.hasAroundInvokeMethod() ) { interceptorInfo.setHasTargetClassAroundInvoke(true); interceptorInfo.setAroundInvokeInterceptorChains(interceptorChains); interceptorInfo.setSupportRuntimeDelegate(true);
public JavaEEInterceptorBuilder createBuilder(InterceptorInfo info) throws Exception { Class targetObjectClass = info.getTargetClass(); // Create an interface with all public methods of the target class // in order to create a dynamic proxy String subClassIntfName = EJBUtils.getGeneratedOptionalInterfaceName(targetObjectClass.getName()); EjbOptionalIntfGenerator gen = new EjbOptionalIntfGenerator(targetObjectClass.getClassLoader()); gen.generateOptionalLocalInterface(targetObjectClass, subClassIntfName); Class subClassIntf = gen.loadClass(subClassIntfName); String beanSubClassName = subClassIntfName + "__Bean__"; // Generate a sub-class of the application's class. Use an instance of this subclass // as the actual object passed back to the application. The sub-class instance // delegates all public methods to the dyanamic proxy, which calls the // InvocationHandler. gen.generateOptionalLocalInterfaceSubClass( targetObjectClass, beanSubClassName, subClassIntf); Class subClass = gen.loadClass(beanSubClassName); // TODO do interceptor builder once per managed bean InterceptorManager interceptorManager = new InterceptorManager(_logger, targetObjectClass.getClassLoader(), targetObjectClass.getName(), info); JavaEEInterceptorBuilderImpl builderImpl = new JavaEEInterceptorBuilderImpl(info, interceptorManager, gen, subClassIntf, subClass); return builderImpl; }
interceptorInfo.getAroundInvokeInterceptors(beanMethod);
private void buildInterceptorChain(InterceptorInfo interceptorInfo) throws Exception { Set<Class> listOfClasses = new HashSet<Class>(); for(String name : interceptorInfo.getInterceptorClassNames()) { listOfClasses.add( loader.loadClass(name)); } // Add framework interceptors to list, but check for existence of // class before attempting to load it via application class loader for(InterceptorDescriptor frameworkInterceptor : frameworkInterceptors) { Class clazz = frameworkInterceptor.getInterceptorClass(); if( clazz == null ) { clazz = loader.loadClass(frameworkInterceptor.getInterceptorClassName()); } listOfClasses.add(clazz); } initInterceptorClasses(listOfClasses); interceptorsExists = (listOfClasses.size() > 0) || interceptorInfo.getHasTargetClassAroundInvoke(); int size = CallbackType.values().length; callbackChain = new CallbackChainImpl[size]; initCallbackIndices(interceptorInfo.getPostConstructInterceptors(), CallbackType.POST_CONSTRUCT); initCallbackIndices(interceptorInfo.getPreDestroyInterceptors(), CallbackType.PRE_DESTROY); }
public InterceptorManager(Logger _logger, ClassLoader classLoader, String className, InterceptorInfo interceptorInfo) throws Exception { this._logger = _logger; loader = classLoader; beanClassName = className; this.beanClass = loader.loadClass(beanClassName); this.interceptorInfo = interceptorInfo; if( interceptorInfo.getSupportRuntimeDelegate() ) { frameworkInterceptors.add(SystemInterceptorProxy.createInterceptorDesc()); } buildInterceptorChain(interceptorInfo); }