You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Gerhard Petracek (JIRA)" <de...@myfaces.apache.org> on 2011/01/14 21:17:45 UTC

[jira] Created: (EXTCDI-120) StartupEventBroadcaster

StartupEventBroadcaster
-----------------------

                 Key: EXTCDI-120
                 URL: https://issues.apache.org/jira/browse/EXTCDI-120
             Project: MyFaces CODI
          Issue Type: New Feature
          Components: Core
            Reporter: Gerhard Petracek


before codi configures anything it should be possible to process initialization tasks.

public interface StartupEventBroadcaster
{
    void broadcastStartup();
}

example for an use-case:

it can be used for an improved app-server support in combination with mojarra
the basic problem is the early config approach of mojarra.
if mojarra gets invoked before the bootstrapping process of a cdi container, it starts to configure everything immediately and codi gets invoked (outside a cdi context).

in such a case it's possible to use a custom ServletContextListener for bootsrapping the container.
in case of owb it's possible to extend WebBeansConfigurationListener

example:

public class MojarraAwareWebBeansConfigurationListener extends WebBeansConfigurationListener implements StartupEventBroadcaster
{
    private static Boolean initialized = false;

    private static ContainerLifecycle storedContainerLifecycle;

    public void contextInitialized(ServletContextEvent event)
    {
        if (!initialized)
        {
            //in this case CDI is bootstrapped already
            super.contextInitialized(event);
            initialized = true;
            storedContainerLifecycle = this.lifeCycle;
        }
    }

    public void broadcastStartup()
    {
        if (initialized)
        {
            return;
        }

        //in this case Mojarra was invoked too soon

        FacesContext facesContext = FacesContext.getCurrentInstance();

        if (facesContext != null && facesContext.getExternalContext() != null)
        {
            //force bootstrapping of OWB
            contextInitialized(new ServletContextEvent((ServletContext) facesContext.getExternalContext().getContext()));
            initialized = true;
        }
    }

    public void requestInitialized(ServletRequestEvent event)
    {
        if (this.lifeCycle == null)
        {
            //here we have a different instance
            this.lifeCycle = storedContainerLifecycle;
        }
        super.requestInitialized(event);
    }
}

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (EXTCDI-120) StartupEventBroadcaster

Posted by "Gerhard Petracek (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/EXTCDI-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981950#action_12981950 ] 

Gerhard Petracek commented on EXTCDI-120:
-----------------------------------------

it's a hook for codi btw. support-modules or add-ons e.g. for integrating existing frameworks like mojarra and gets triggered >before< bootstrapping codi. (that's the only contract.)
what you are referring to is a different story. for jsf based apps codi provides such an event (see StartupEvent)
however, it would be nice to get an event which gets fired after the bootstrapping process of cdi.

> StartupEventBroadcaster
> -----------------------
>
>                 Key: EXTCDI-120
>                 URL: https://issues.apache.org/jira/browse/EXTCDI-120
>             Project: MyFaces CODI
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Gerhard Petracek
>             Fix For: 0.9.3
>
>
> before codi configures anything it should be possible to process initialization tasks.
> public interface StartupEventBroadcaster
> {
>     void broadcastStartup();
> }
> example for an use-case:
> it can be used for an improved app-server support in combination with mojarra
> the basic problem is the early config approach of mojarra.
> if mojarra gets invoked before the bootstrapping process of a cdi container, it starts to configure everything immediately and codi gets invoked (outside a cdi context).
> in such a case it's possible to use a custom ServletContextListener for bootsrapping the container.
> in case of owb it's possible to extend WebBeansConfigurationListener
> example:
> public class MojarraAwareWebBeansConfigurationListener extends WebBeansConfigurationListener implements StartupEventBroadcaster
> {
>     private static Boolean initialized = false;
>     private static ContainerLifecycle storedContainerLifecycle;
>     public void contextInitialized(ServletContextEvent event)
>     {
>         if (!initialized)
>         {
>             //in this case CDI is bootstrapped already
>             super.contextInitialized(event);
>             initialized = true;
>             storedContainerLifecycle = this.lifeCycle;
>         }
>     }
>     public void broadcastStartup()
>     {
>         if (initialized)
>         {
>             return;
>         }
>         //in this case Mojarra was invoked too soon
>         FacesContext facesContext = FacesContext.getCurrentInstance();
>         if (facesContext != null && facesContext.getExternalContext() != null)
>         {
>             //force bootstrapping of OWB
>             contextInitialized(new ServletContextEvent((ServletContext) facesContext.getExternalContext().getContext()));
>             initialized = true;
>         }
>     }
>     public void requestInitialized(ServletRequestEvent event)
>     {
>         if (this.lifeCycle == null)
>         {
>             //here we have a different instance
>             this.lifeCycle = storedContainerLifecycle;
>         }
>         super.requestInitialized(event);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (EXTCDI-120) StartupEventBroadcaster

Posted by "Gerhard Petracek (JIRA)" <de...@myfaces.apache.org>.
     [ https://issues.apache.org/jira/browse/EXTCDI-120?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gerhard Petracek resolved EXTCDI-120.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 0.9.3

> StartupEventBroadcaster
> -----------------------
>
>                 Key: EXTCDI-120
>                 URL: https://issues.apache.org/jira/browse/EXTCDI-120
>             Project: MyFaces CODI
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Gerhard Petracek
>             Fix For: 0.9.3
>
>
> before codi configures anything it should be possible to process initialization tasks.
> public interface StartupEventBroadcaster
> {
>     void broadcastStartup();
> }
> example for an use-case:
> it can be used for an improved app-server support in combination with mojarra
> the basic problem is the early config approach of mojarra.
> if mojarra gets invoked before the bootstrapping process of a cdi container, it starts to configure everything immediately and codi gets invoked (outside a cdi context).
> in such a case it's possible to use a custom ServletContextListener for bootsrapping the container.
> in case of owb it's possible to extend WebBeansConfigurationListener
> example:
> public class MojarraAwareWebBeansConfigurationListener extends WebBeansConfigurationListener implements StartupEventBroadcaster
> {
>     private static Boolean initialized = false;
>     private static ContainerLifecycle storedContainerLifecycle;
>     public void contextInitialized(ServletContextEvent event)
>     {
>         if (!initialized)
>         {
>             //in this case CDI is bootstrapped already
>             super.contextInitialized(event);
>             initialized = true;
>             storedContainerLifecycle = this.lifeCycle;
>         }
>     }
>     public void broadcastStartup()
>     {
>         if (initialized)
>         {
>             return;
>         }
>         //in this case Mojarra was invoked too soon
>         FacesContext facesContext = FacesContext.getCurrentInstance();
>         if (facesContext != null && facesContext.getExternalContext() != null)
>         {
>             //force bootstrapping of OWB
>             contextInitialized(new ServletContextEvent((ServletContext) facesContext.getExternalContext().getContext()));
>             initialized = true;
>         }
>     }
>     public void requestInitialized(ServletRequestEvent event)
>     {
>         if (this.lifeCycle == null)
>         {
>             //here we have a different instance
>             this.lifeCycle = storedContainerLifecycle;
>         }
>         super.requestInitialized(event);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (EXTCDI-120) StartupEventBroadcaster

Posted by "Mark Struberg (JIRA)" <de...@myfaces.apache.org>.
    [ https://issues.apache.org/jira/browse/EXTCDI-120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12981922#action_12981922 ] 

Mark Struberg commented on EXTCDI-120:
--------------------------------------

might it be interesting to propose the introduction of a new ContainerStarted system Event (JSR-299 spec section 11).
Will ask for clarification about it on the weld-dev list.

> StartupEventBroadcaster
> -----------------------
>
>                 Key: EXTCDI-120
>                 URL: https://issues.apache.org/jira/browse/EXTCDI-120
>             Project: MyFaces CODI
>          Issue Type: New Feature
>          Components: Core
>            Reporter: Gerhard Petracek
>             Fix For: 0.9.3
>
>
> before codi configures anything it should be possible to process initialization tasks.
> public interface StartupEventBroadcaster
> {
>     void broadcastStartup();
> }
> example for an use-case:
> it can be used for an improved app-server support in combination with mojarra
> the basic problem is the early config approach of mojarra.
> if mojarra gets invoked before the bootstrapping process of a cdi container, it starts to configure everything immediately and codi gets invoked (outside a cdi context).
> in such a case it's possible to use a custom ServletContextListener for bootsrapping the container.
> in case of owb it's possible to extend WebBeansConfigurationListener
> example:
> public class MojarraAwareWebBeansConfigurationListener extends WebBeansConfigurationListener implements StartupEventBroadcaster
> {
>     private static Boolean initialized = false;
>     private static ContainerLifecycle storedContainerLifecycle;
>     public void contextInitialized(ServletContextEvent event)
>     {
>         if (!initialized)
>         {
>             //in this case CDI is bootstrapped already
>             super.contextInitialized(event);
>             initialized = true;
>             storedContainerLifecycle = this.lifeCycle;
>         }
>     }
>     public void broadcastStartup()
>     {
>         if (initialized)
>         {
>             return;
>         }
>         //in this case Mojarra was invoked too soon
>         FacesContext facesContext = FacesContext.getCurrentInstance();
>         if (facesContext != null && facesContext.getExternalContext() != null)
>         {
>             //force bootstrapping of OWB
>             contextInitialized(new ServletContextEvent((ServletContext) facesContext.getExternalContext().getContext()));
>             initialized = true;
>         }
>     }
>     public void requestInitialized(ServletRequestEvent event)
>     {
>         if (this.lifeCycle == null)
>         {
>             //here we have a different instance
>             this.lifeCycle = storedContainerLifecycle;
>         }
>         super.requestInitialized(event);
>     }
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.