Uploaded image for project: 'MyFaces CODI'
  1. MyFaces CODI
  2. EXTCDI-120

StartupEventBroadcaster

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 0.9.3
    • Core
    • None

    Description

      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);
      }
      }

      Attachments

        Activity

          People

            gpetracek Gerhard Petracek
            gpetracek Gerhard Petracek
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: