Package org.exoplatform.container

Examples of org.exoplatform.container.ExoContainer


   }

   public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception)
   {
      String containerName = extractContainerName(context);
      ExoContainer container = null;
      if (containerName != null)
      {
         if (containerName.equals(JobSchedulerServiceImpl.STANDALONE_CONTAINER_NAME))
         {
            container = ExoContainerContext.getTopContainer();           
         }
         else
         {
            RootContainer rootContainer = RootContainer.getInstance();
            container = (ExoContainer)rootContainer.getComponentInstance(containerName);           
         }
      }
      if (container != null)
      {
         List<ComponentRequestLifecycle> components =
            container.getComponentInstancesOfType(ComponentRequestLifecycle.class);
         for (ComponentRequestLifecycle component : components)
         {
            component.endRequest(container);
         }
         ExoContainerContext.setCurrentContainer(null);           
View Full Code Here


   static final String NAME = "JobContextConfigListener";

   public void jobToBeExecuted(JobExecutionContext context)
   {
      String containerName = extractContainerName(context);
      ExoContainer container = null;
      if (containerName != null)
      {
         if (containerName.equals(JobSchedulerServiceImpl.STANDALONE_CONTAINER_NAME))
         {
            container = ExoContainerContext.getTopContainer();           
         }
         else
         {
            RootContainer rootContainer = RootContainer.getInstance();
            container = (ExoContainer)rootContainer.getComponentInstance(containerName);           
         }
      }
      if (container != null)
      {
         ExoContainerContext.setCurrentContainer(container);           
         List<ComponentRequestLifecycle> components = container.getComponentInstancesOfType(ComponentRequestLifecycle.class);
         for (ComponentRequestLifecycle component : components)
         {
            try {
               component.startRequest(container);
            } catch(Throwable e) {
View Full Code Here

   }

   public void jobWasExecuted(JobExecutionContext context, JobExecutionException exception)
   {
      String containerName = extractContainerName(context);
      ExoContainer container = null;
      if (containerName != null)
      {
         if (containerName.equals(JobSchedulerServiceImpl.STANDALONE_CONTAINER_NAME))
         {
            container = ExoContainerContext.getTopContainer();           
         }
         else
         {
            RootContainer rootContainer = RootContainer.getInstance();
            container = (ExoContainer)rootContainer.getComponentInstance(containerName);           
         }
      }
      if (container != null)
      {
         List<ComponentRequestLifecycle> components = container.getComponentInstancesOfType(ComponentRequestLifecycle.class);
         for (ComponentRequestLifecycle component : components)
         {
            try {
               component.endRequest(container);
            } catch(Throwable e) {
View Full Code Here

        if (!producerPortletInvokerSet || !PropertyManager.isDevelopping()) {
           // The current instance did not register the producerPortletInvoker so we have nothing to do or we are not in
           // developing mode
           return;
        }
        final ExoContainer topContainer = ExoContainerContext.getTopContainer();
        FederatingPortletInvoker federatingPortletInvoker = (FederatingPortletInvoker) topContainer
                .getComponentInstanceOfType(FederatingPortletInvoker.class);
        if (federatingPortletInvoker != null && federatingPortletInvoker.isResolved(PortletInvoker.LOCAL_PORTLET_INVOKER_ID)) {
           // The current instance registered the producerPortletInvoker so we have to unregister it
           federatingPortletInvoker.unregisterInvoker(PortletInvoker.LOCAL_PORTLET_INVOKER_ID);
        }
View Full Code Here

      }
   }

   public void beforeInvoke(Object managedResource)
   {
      final ExoContainer container = findContainer();
      if (container != null)
      {
         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
         {
            public Void run()
            {
               ExoContainer oldContainer = ExoContainerContext.getCurrentContainerIfPresent();
               if (!(oldContainer instanceof RootContainer))
               {
                  previousContainer.set(oldContainer);
               }
               ExoContainerContext.setCurrentContainer(container);
View Full Code Here

      {
         SecurityHelper.doPrivilegedAction(new PrivilegedAction<Void>()
         {
            public Void run()
            {
               ExoContainer oldContainer = previousContainer.get();
               if (oldContainer != null)
               {
                  previousContainer.set(null);
               }
               ExoContainerContext.setCurrentContainer(oldContainer);
View Full Code Here

   {
      if (instance_ != null)
         return instance_;

      //
      ExoContainer exocontainer = (ExoContainer)container;
      Component component = null;
      ConfigurationManager manager;
      String componentKey;
      try
      {
         InitParams params = null;
         boolean debug = false;
         synchronized (this)
         {
            // Avoid to create duplicate instances if it is called at the same time by several threads
            if (instance_ != null)
               return instance_;
            // Get the component
            Object key = getComponentKey();
            if (key instanceof String)
               componentKey = (String)key;
            else
               componentKey = ((Class<?>)key).getName();
            manager = (ConfigurationManager)exocontainer.getComponentInstanceOfType(ConfigurationManager.class);
            component = manager.getComponent(componentKey);
            if (component != null)
            {
               params = component.getInitParams();
               debug = component.getShowDeployInfo();
            }
            // Please note that we cannot fully initialize the Object "instance_" before releasing other
            // threads because it could cause StackOverflowError due to recursive calls
            Object instance = exocontainer.createComponent(getComponentImplementation(), params);
            if (instance_ != null)
            {
               // Avoid instantiating twice the same component in case of a cyclic reference due
               // to component plugins
               return instance_;
            }
            exocontainer.addComponentToCtx(getComponentKey(), instance);
            if (debug)
               LOG.debug("==> create  component : " + instance_);
            if (component != null && component.getComponentPlugins() != null)
            {
               addComponentPlugin(debug, instance, component.getComponentPlugins(), exocontainer);
            }
            ExternalComponentPlugins ecplugins = manager.getConfiguration().getExternalComponentPlugins(componentKey);
            if (ecplugins != null)
            {
               addComponentPlugin(debug, instance, ecplugins.getComponentPlugins(), exocontainer);
            }
            // check if component implement the ComponentLifecycle
            if (instance instanceof ComponentLifecycle)
            {
               ComponentLifecycle lc = (ComponentLifecycle)instance;
               lc.initComponent(exocontainer);
            }
            instance_ = instance;
         }

      }
      catch (Exception ex)
      {
         String msg = "Cannot instantiate component " + getComponentImplementation();
         if (component != null)
         {
            msg =
               "Cannot instantiate component key=" + component.getKey() + " type=" + component.getType() + " found at "
                  + component.getDocumentURL();
         }
         throw new RuntimeException(msg, ex);
      }
      finally
      {
         exocontainer.removeComponentFromCtx(getComponentKey());
      }
      return instance_;
   }
View Full Code Here

   /**
    * @see javax.servlet.http.HttpServlet#service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    */
   public final void service(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
   {
      final ExoContainer oldContainer = ExoContainerContext.getCurrentContainer();
      // Keep the old ClassLoader
      final ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
      ExoContainer container = null;
      boolean hasBeenSet = false;
      try
      {
         container = getContainer();
         if (!container.equals(oldContainer))
         {
            if (container instanceof PortalContainer)
            {
               PortalContainer.setInstance((PortalContainer)container);
            }
View Full Code Here

   /**
    * @return Gives the {@link ExoContainer} that fits best with the current context
    */
   protected final ExoContainer getContainer()
   {
      ExoContainer container = ExoContainerContext.getCurrentContainer();
      if (container instanceof RootContainer)
      {
         // The top container is a RootContainer, thus we assume that we are in a portal mode
         container = PortalContainer.getCurrentInstance(config.getServletContext());
         if (container == null)
View Full Code Here

   @Override
   public ServletContext getServletContext()
   {
      if (requirePortalEnvironment())
      {
         ExoContainer container = getContainer();
         if (container instanceof PortalContainer)
         {
            return ((PortalContainer)container).getPortalContext();
         }
      }
View Full Code Here

TOP

Related Classes of org.exoplatform.container.ExoContainer

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.