Package org.exoplatform.container

Examples of org.exoplatform.container.ComponentTaskContext


      }
   }

   private T create(Callable<T> mainCreateTask)
   {
      ComponentTaskContext ctx = container.getComponentTaskContext();
      try
      {
         loadTasks();
         loadDependencies(ctx);
         return mainCreateTask.call();
View Full Code Here


      }
   }

   private void loadDependencies(ComponentTaskContext ctx) throws Exception
   {
      ComponentTaskContext createCtx = ctx;
      if (createCtx == null)
      {
         createCtx = new ComponentTaskContext(getComponentKey(), ComponentTaskType.CREATE);
         container.setComponentTaskContext(createCtx);
      }
      else if (!createCtx.isLast(getComponentKey()))
      {
         createCtx = createCtx.addToContext(getComponentKey());
         container.setComponentTaskContext(createCtx);
      }
      container.loadDependencies(getComponentKey(), createCtx, getCreateDependencies(), ComponentTaskType.CREATE);
   }
View Full Code Here

      // Avoid to create duplicate instances if it is called at the same time by several threads
      if (instance_ != null)
         return instance_;
      else if (ctx.get() != null)
         return ctx.get();
      ComponentTaskContext taskCtx = container.getComponentTaskContext();
      boolean isRoot = taskCtx.isRoot();
      if (!isRoot)
      {
         container.setComponentTaskContext(taskCtx = taskCtx.setLastTaskType(ComponentTaskType.CREATE));
      }
      try
      {
         ComponentTask<T> task = createTask.get();
         T result = task.call(ctx);
         if (instance_ != null)
         {
            // Avoid instantiating twice the same component in case of a cyclic reference due
            // to component plugins
            return instance_;
         }
         else if (ctx.get() != null)
            return ctx.get();

         ctx.push(result);
      }
      catch (CyclicDependencyException e)
      {
         throw e;
      }
      catch (Exception e)
      {
         throw new RuntimeException("Cannot create component " + getComponentImplementation(), e);
      }
      if (isRoot)
      {
         container.setComponentTaskContext(taskCtx =
            taskCtx.resetDependencies(getComponentKey(), ComponentTaskType.INIT));
      }
      else
      {
         container.setComponentTaskContext(taskCtx = taskCtx.setLastTaskType(ComponentTaskType.INIT));
      }

      Collection<ComponentTask<Void>> tasks = initTasks.get();
      ComponentTask<Void> task = null;
      try
View Full Code Here

TOP

Related Classes of org.exoplatform.container.ComponentTaskContext

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.