Package org.apache.webbeans.proxy

Examples of org.apache.webbeans.proxy.NormalScopeProxyFactory


                    } catch (final IllegalAccessException e) {
                        throw new OpenEJBRuntimeException(e);
                    }

                } else {
                    final NormalScopeProxyFactory normalScopeProxyFactory = webBeansContext.getNormalScopeProxyFactory();
                    final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass());
                    instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
                }

                cacheProxies.put(inBean, instance);
            } else {
                final Context context = webBeansContext.getBeanManagerImpl().getContext(scopeClass);
View Full Code Here


                    } catch (final IllegalAccessException e) {
                        throw new OpenEJBRuntimeException(e);
                    }

                } else {
                    final NormalScopeProxyFactory normalScopeProxyFactory = webBeansContext.getNormalScopeProxyFactory();
                    final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass());
                    instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
                }

                cacheProxies.put(inBean, instance);
            } else {
                final Context context = webBeansContext.getBeanManagerImpl().getContext(scopeClass);
View Full Code Here

    {
        if (proxyInstance == null)
        {
            if (proxy)
            {
                NormalScopeProxyFactory proxyFactory = webBeansContext.getNormalScopeProxyFactory();
                ClassLoader loader = returnType.getClassLoader();
                if (loader == null)
                {
                    loader = WebBeansUtil.getCurrentClassLoader();
                }
                Class<T> proxyClass = proxyFactory.createProxyClass(loader, returnType);
                proxyInstance = proxyFactory.createProxyInstance(proxyClass, provider);
            }
            else
            {
                proxyInstance = provider.get();
            }
View Full Code Here

{

    @Test
    public void textSimpleProxyCreation() throws Exception
    {
        NormalScopeProxyFactory pf = new NormalScopeProxyFactory(new WebBeansContext());

        // we take a fresh URLClassLoader to not blur the test classpath with synthetic classes.
        ClassLoader classLoader = new URLClassLoader(new URL[0]);

        Class<ClassInterceptedClass> proxyClass = pf.createProxyClass(classLoader, ClassInterceptedClass.class);
        Assert.assertNotNull(proxyClass);

        ClassInterceptedClass internalInstance = new ClassInterceptedClass();
        internalInstance.init();

        TestContextualInstanceProvider provider = new TestContextualInstanceProvider(internalInstance);

        ClassInterceptedClass proxy = pf.createProxyInstance(proxyClass, provider);

        Assert.assertEquals(42, proxy.getMeaningOfLife());
        Assert.assertTrue(provider.gotInvoked());

        Assert.assertEquals(internalInstance.getFloat(), proxy.getFloat(), 0f);
View Full Code Here

                    } catch (final IllegalAccessException e) {
                        throw new OpenEJBRuntimeException(e);
                    }

                } else {
                    final NormalScopeProxyFactory normalScopeProxyFactory = webBeansContext.getNormalScopeProxyFactory();
                    final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), beanContext.getBeanClass());
                    instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
                }

                cacheProxies.put(inBean, instance);
            } else {
                final Context context = webBeansContext.getBeanManagerImpl().getContext(scopeClass);
View Full Code Here

                } catch (final IllegalAccessException e) {
                    throw new OpenEJBRuntimeException(e);
                }

            } else {
                final NormalScopeProxyFactory normalScopeProxyFactory = webBeansContext.getNormalScopeProxyFactory();
                final Class<?> proxyClass = normalScopeProxyFactory.createProxyClass(beanContext.getClassLoader(), interfce);
                instance = normalScopeProxyFactory.createProxyInstance(proxyClass, provider);
            }

            cacheProxies.put(inBean, instance);
        } else {
            final Context context = webBeansContext.getBeanManagerImpl().getContext(scopeClass);
View Full Code Here

    {
        if (proxyInstance == null)
        {
            if (proxy)
            {
                NormalScopeProxyFactory proxyFactory = webBeansContext.getNormalScopeProxyFactory();
                ClassLoader loader = returnType.getClassLoader();
                if (loader == null)
                {
                    loader = WebBeansUtil.getCurrentClassLoader();
                }
                Class<T> proxyClass = proxyFactory.createProxyClass(loader, returnType);
                proxyInstance = proxyFactory.createProxyInstance(proxyClass, provider);
            }
            else
            {
                proxyInstance = provider.get();
            }
View Full Code Here

{
    @Test
    public void noBeanClassProxy()
    {
        final WebBeansContext webBeansContext = new WebBeansContext();
        final NormalScopeProxyFactory pf = new NormalScopeProxyFactory(webBeansContext);
        final Object proxy = pf.createNormalScopeProxy(new OwbBean<Provider>() {
            @Override
            public Set<Type> getTypes() {
                return null;
            }
View Full Code Here

    }

    @Test
    public void textSimpleProxyCreation() throws Exception
    {
        NormalScopeProxyFactory pf = new NormalScopeProxyFactory(new WebBeansContext());

        // we take a fresh URLClassLoader to not blur the test classpath with synthetic classes.
        ClassLoader classLoader = new URLClassLoader(new URL[0]);

        Class<ClassInterceptedClass> proxyClass = pf.createProxyClass(classLoader, ClassInterceptedClass.class);
        Assert.assertNotNull(proxyClass);

        ClassInterceptedClass internalInstance = new ClassInterceptedClass();
        internalInstance.init();

        TestContextualInstanceProvider provider = new TestContextualInstanceProvider(internalInstance);

        ClassInterceptedClass proxy = pf.createProxyInstance(proxyClass, provider);

        Assert.assertEquals(42, proxy.getMeaningOfLife());
        Assert.assertTrue(provider.gotInvoked());

        Assert.assertEquals(internalInstance.getFloat(), proxy.getFloat(), 0f);
View Full Code Here

        shutDownContainer();
    }

    private <T> T createNormalScopingProxy(ClassLoader classLoader, Class<T> clazz, T instance) throws ProxyGenerationException
    {
        NormalScopeProxyFactory pf = new NormalScopeProxyFactory(getWebBeansContext());

        Class<T> proxyClass = pf.createProxyClass(classLoader, clazz);
        Assert.assertNotNull(proxyClass);

        return pf.createProxyInstance(proxyClass, new TestRequestScopedInstanceProvider(instance));
    }
View Full Code Here

TOP

Related Classes of org.apache.webbeans.proxy.NormalScopeProxyFactory

Copyright © 2018 www.massapicom. 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.