Package org.apache.myfaces.spi

Examples of org.apache.myfaces.spi.InjectionProvider


    }

    @Override
    public InjectionProvider getInjectionProvider(ExternalContext externalContext)
    {
        InjectionProvider lifecycleProvider = null;
        if (externalContext == null)
        {
            // Really in jsf 2.0, this will not happen, because a Startup/Shutdown
            // FacesContext and ExternalContext are provided on initialization and shutdown,
            // and in other scenarios the real FacesContext/ExternalContext is provided.
            log.info("No ExternalContext using fallback InjectionProvider.");
            lifecycleProvider = resolveFallbackInjectionProvider();
        }
        else
        {
            lifecycleProvider = (InjectionProvider)
                    externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
        }
        if (lifecycleProvider == null)
        {
            if (!resolveInjectionProviderFromExternalContext(externalContext))
            {
                if (!resolveInjectionProviderFromService(externalContext))
                {
                    lifecycleProvider = resolveFallbackInjectionProvider();
                    externalContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY, lifecycleProvider);
                }
                else
                {
                    //Retrieve it because it was resolved
                    lifecycleProvider = (InjectionProvider)
                            externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
                }
            }
            else
            {
                //Retrieve it because it was resolved
                lifecycleProvider = (InjectionProvider)
                        externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
            }
            log.info("Using InjectionProvider "+ lifecycleProvider.getClass().getName());
        }
        return lifecycleProvider;
    }
View Full Code Here


                                {
                                    String className = iter.next();
                                    Object obj = createClass(className,extContext);
                                    if (InjectionProvider.class.isAssignableFrom(obj.getClass()))
                                    {
                                        InjectionProvider discoverableInjectionProvider =
                                                (InjectionProvider) obj;
                                        if (discoverableInjectionProvider.isAvailable())
                                        {
                                            extContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY,
                                                                               discoverableInjectionProvider);
                                            return true;
                                        }
                                    }
                                }
                                return false;
                            }
                        });
            }
            else
            {
                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).
                        getServiceProviderList(INJECTION_PROVIDER);
                Iterator<String> iter = classList.iterator();
                while (iter.hasNext())
                {
                    String className = iter.next();
                    Object obj = createClass(className,extContext);
                    if (InjectionProvider.class.isAssignableFrom(obj.getClass()))
                    {
                        InjectionProvider discoverableInjectionProvider
                                = (InjectionProvider) obj;
                        if (discoverableInjectionProvider.isAvailable())
                        {
                            extContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY,
                                                               discoverableInjectionProvider);
                            return (Boolean) true;
                        }
View Full Code Here

            }
           
            currentTestContext.setUp(this.originalTarget);
           
            FacesContext facesContext = null;
            InjectionProvider injectionProvider = null;
            Object testCaseCreationMetadata = null;
            try
            {
                facesContext = currentTestContext.getFacesInitializer().
                    initStartupFacesContext(currentTestContext.servletContext);
               
                InjectionProviderFactory ipf = InjectionProviderFactory.
                    getInjectionProviderFactory(facesContext.getExternalContext());
                injectionProvider = ipf.getInjectionProvider(
                    facesContext.getExternalContext());
               
                if (injectionProvider != null)
                {
                    testCaseCreationMetadata = injectionProvider.inject(originalTarget);
                    injectionProvider.postConstruct(originalTarget, testCaseCreationMetadata);
                }
            }
            finally
            {
                currentTestContext.getFacesInitializer().destroyStartupFacesContext(facesContext);
            }
            try
            {
                defaultStatement.evaluate();
            }
            finally
            {
                facesContext = currentTestContext.getFacesInitializer().
                    initShutdownFacesContext(currentTestContext.servletContext);

                if (injectionProvider != null)
                {
                    injectionProvider.preDestroy(originalTarget, testCaseCreationMetadata);
                }
               
                currentTestContext.getFacesInitializer().destroyShutdownFacesContext(facesContext);
               
                currentTestContext.tearDown();
View Full Code Here

        }
    }
   
    public void _callPreDestroyOnInjectedJSFArtifacts(FacesContext facesContext)
    {
        InjectionProvider injectionProvider = InjectionProviderFactory.getInjectionProviderFactory(
            facesContext.getExternalContext()).getInjectionProvider(facesContext.getExternalContext());
        List<BeanEntry> injectedBeanStorage =
                (List<BeanEntry>)facesContext.getExternalContext().getApplicationMap().get(INJECTED_BEAN_STORAGE_KEY);

        if (injectedBeanStorage != null)
        {
            for (BeanEntry entry : injectedBeanStorage)
            {
                try
                {
                    injectionProvider.preDestroy(entry.getInstance(), entry.getCreationMetaData());
                }
                catch (InjectionProviderException ex)
                {
                    log.log(Level.INFO, "Exception on PreDestroy", ex);
                }
View Full Code Here

        }
    }
   
    public void _callPreDestroyOnInjectedJSFArtifacts(FacesContext facesContext)
    {
        InjectionProvider injectionProvider = InjectionProviderFactory.getInjectionProviderFactory(
            facesContext.getExternalContext()).getInjectionProvider(facesContext.getExternalContext());
        List<BeanEntry> injectedBeanStorage =
                (List<BeanEntry>)facesContext.getExternalContext().getApplicationMap().get(INJECTED_BEAN_STORAGE_KEY);

        if (injectedBeanStorage != null)
        {
            for (BeanEntry entry : injectedBeanStorage)
            {
                try
                {
                    injectionProvider.preDestroy(entry.getInstance(), entry.getCreationMetaData());
                }
                catch (InjectionProviderException ex)
                {
                    log.log(Level.INFO, "Exception on PreDestroy", ex);
                }
View Full Code Here

        // get RuntimeConfig and LifecycleProvider
        RuntimeConfig runtimeConfig = RuntimeConfig.getCurrentInstance(externalContext);
        LifecycleProvider lifecycleProvider = LifecycleProviderFactory
                .getLifecycleProviderFactory(externalContext).getLifecycleProvider(externalContext);
        InjectionProvider injectionProvider = InjectionProviderFactory
            .getInjectionProviderFactory(externalContext).getInjectionProvider(externalContext);

        // create ManagedBeanDestroyer
        ManagedBeanDestroyer mbDestroyer
                = new ManagedBeanDestroyer(lifecycleProvider, runtimeConfig);
View Full Code Here

                                {
                                    String className = iter.next();
                                    Object obj = createClass(className,extContext);
                                    if (InjectionProvider.class.isAssignableFrom(obj.getClass()))
                                    {
                                        InjectionProvider discoverableInjectionProvider =
                                                (InjectionProvider) obj;
                                        if (discoverableInjectionProvider.isAvailable())
                                        {
                                            extContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY,
                                                                               discoverableInjectionProvider);
                                            return true;
                                        }
                                    }
                                }
                                return false;
                            }
                        });
            }
            else
            {
                List<String> classList = ServiceProviderFinderFactory.getServiceProviderFinder(extContext).
                        getServiceProviderList(INJECTION_PROVIDER);
                Iterator<String> iter = classList.iterator();
                while (iter.hasNext())
                {
                    String className = iter.next();
                    Object obj = createClass(className,extContext);
                    if (InjectionProvider.class.isAssignableFrom(obj.getClass()))
                    {
                        InjectionProvider discoverableInjectionProvider
                                = (InjectionProvider) obj;
                        if (discoverableInjectionProvider.isAvailable())
                        {
                            extContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY,
                                                               discoverableInjectionProvider);
                            return (Boolean) true;
                        }
View Full Code Here

    }

    @Override
    public InjectionProvider getInjectionProvider(ExternalContext externalContext)
    {
        InjectionProvider lifecycleProvider = null;
        if (externalContext == null)
        {
            // Really in jsf 2.0, this will not happen, because a Startup/Shutdown
            // FacesContext and ExternalContext are provided on initialization and shutdown,
            // and in other scenarios the real FacesContext/ExternalContext is provided.
            log.info("No ExternalContext using fallback InjectionProvider.");
            lifecycleProvider = resolveFallbackInjectionProvider();
        }
        else
        {
            lifecycleProvider = (InjectionProvider)
                    externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
        }
        if (lifecycleProvider == null)
        {
            if (!resolveInjectionProviderFromExternalContext(externalContext))
            {
                if (!resolveInjectionProviderFromService(externalContext))
                {
                    lifecycleProvider = resolveFallbackInjectionProvider();
                    externalContext.getApplicationMap().put(INJECTION_PROVIDER_INSTANCE_KEY, lifecycleProvider);
                }
                else
                {
                    //Retrieve it because it was resolved
                    lifecycleProvider = (InjectionProvider)
                            externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
                }
            }
            else
            {
                //Retrieve it because it was resolved
                lifecycleProvider = (InjectionProvider)
                        externalContext.getApplicationMap().get(INJECTION_PROVIDER_INSTANCE_KEY);
            }
            log.info("Using InjectionProvider "+ lifecycleProvider.getClass().getName());
        }
        return lifecycleProvider;
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.spi.InjectionProvider

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.