Examples of RuntimeExceptionBindingTypeBean


Examples of org.apache.webbeans.newtests.interceptors.business.common.RuntimeExceptionBindingTypeBean

        beanClasses.add(RuntimeExceptionsInterceptor.class);
        beanClasses.add(RuntimeExceptionBindingTypeBean.class);

        startContainer(beanClasses, beanXmls);

        RuntimeExceptionBindingTypeBean instance = getInstance(RuntimeExceptionBindingTypeBean.class);

        Assert.assertNotNull(instance);

        int result = instance.business();
        Assert.assertEquals(42, result);
       
        shutDownContainer();
       
    }
View Full Code Here

Examples of org.apache.webbeans.newtests.interceptors.business.common.RuntimeExceptionBindingTypeBean

        Interceptor interceptorBean = beanManager.resolveInterceptors(InterceptionType.AROUND_INVOKE, new AnnotationLiteral<RuntimeExceptions>() {}).iterator().next();
        Bean bean = beanManager.resolve(beanManager.getBeans(RuntimeExceptionBindingTypeBean.class));
        CreationalContext creationalContext = beanManager.createCreationalContext(bean);
       
        // we cannot use the container to create the proxy as it already proxies the internal instance
        RuntimeExceptionBindingTypeBean target = new RuntimeExceptionBindingTypeBean();

        RuntimeExceptionsInterceptor interceptor = (RuntimeExceptionsInterceptor) interceptorBean.create(creationalContext);

        Method[] interceptedMethods = {RuntimeExceptionBindingTypeBean.class.getMethod("business")};
        Map<Method, List<Interceptor<?>>> interceptors = new HashMap<Method, List<Interceptor<?>>>();
        interceptors.put(interceptedMethods[0], Arrays.<Interceptor<?>> asList(interceptorBean));
        Map instances = new HashMap();
        instances.put(interceptorBean, interceptor);
        InterceptorHandler interceptorHandler
                = new DefaultInterceptorHandler<RuntimeExceptionBindingTypeBean>(target, target, interceptors, instances, null);
       
        InterceptorDecoratorProxyFactory factory = new InterceptorDecoratorProxyFactory(getWebBeansContext());
        Class<RuntimeExceptionBindingTypeBean> proxyClass
                = factory.createProxyClass(bean, Thread.currentThread().getContextClassLoader(), RuntimeExceptionBindingTypeBean.class, interceptedMethods, null);

        RuntimeExceptionBindingTypeBean instance = factory.createProxyInstance(proxyClass, target, interceptorHandler);
        int result = instance.business();
        Assert.assertEquals(42, result);

        Assert.assertEquals(1, interceptor.invoked);
       
        shutDownContainer();
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.