當前位置: 首頁>>代碼示例>>Java>>正文


Java ClassLoaders.executeIn方法代碼示例

本文整理匯總了Java中org.jboss.forge.furnace.util.ClassLoaders.executeIn方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassLoaders.executeIn方法的具體用法?Java ClassLoaders.executeIn怎麽用?Java ClassLoaders.executeIn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.jboss.forge.furnace.util.ClassLoaders的用法示例。


在下文中一共展示了ClassLoaders.executeIn方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: lookup

import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
public <T> T lookup(final Class<T> type)
{
   try
   {
      return ClassLoaders.executeIn(Thread.currentThread().getContextClassLoader(), new Callable<T>()
      {
         @Override
         public T call() throws Exception
         {
            return getPlexusContainer().lookup(type);
         }
      });
   }
   catch (Exception e)
   {
      throw new RuntimeException("Could not look up component of type [" + type.getName() + "]", e);
   }
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:19,代碼來源:PlexusContainer.java

示例2: run

import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public void run()
{
   try
   {
      ClassLoaders.executeIn(loader, new Callable<Object>()
      {
         @Override
         public Object call() throws Exception
         {
            System.setProperty(FurnaceImpl.TEST_MODE_PROPERTY, "true");

            furnace.setServerMode(true);
            furnace.start(loader);

            SecurityActions.cleanupThreadLocals(thread);
            return null;
         }
      });
   }
   catch (Exception e)
   {
      throw new RuntimeException("Failed to start Furnace container.", e);
   }
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:26,代碼來源:FurnaceDeployableContainer.java

示例3: run

import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public void run()
{
   try
   {
      ClassLoaders.executeIn(loader, new Callable<Object>()
      {
         @Override
         public Object call() throws Exception
         {
            furnace.setServerMode(true);
            furnace.start(loader);

            SecurityActions.cleanupThreadLocals(thread);
            return null;
         }
      });
   }
   catch (Exception e)
   {
      throw new RuntimeException("Failed to start Furnace container.", e);
   }
}
 
開發者ID:koentsje,項目名稱:forge-furnace,代碼行數:24,代碼來源:ForgeDeployableContainer.java

示例4: run

import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public void run()
{
   Thread currentThread = Thread.currentThread();
   String name = currentThread.getName();
   currentThread.setName(addon.getId().toCoordinates());
   try
   {
      logger.fine("> Starting container [" + addon.getId() + "] [" + addon.getRepository().getRootDirectory() + "]");
      long start = System.currentTimeMillis();

      lifecycleProviderEntry = detectLifecycleProvider();
      if (lifecycleProviderEntry != null)
      {
         final AddonLifecycleProvider lifecycleProvider = lifecycleProviderEntry.getProvider();
         ClassLoaders.executeIn(addon.getClassLoader(), new Callable<Void>()
         {
            @Override
            public Void call() throws Exception
            {
               lifecycleProvider.initialize(furnace, furnace.getAddonRegistry(getRepositories()),
                        lifecycleProviderEntry.getAddon());
               lifecycleProvider.start(addon);
               stateManager.setServiceRegistry(addon, lifecycleProvider.getServiceRegistry(addon));
               stateManager.setEventManager(addon, lifecycleProvider.getEventManager(addon));

               firePostStartup(lifecycleProvider);
               return null;
            }

         });
      }

      logger.fine(">> Started container [" + addon.getId() + "] - " + (System.currentTimeMillis() - start) + "ms");

   }
   catch (Throwable e)
   {
      addon.getFuture().cancel(false);
      stateManager.setHandles(addon, new ExceptionFuture<Void>(e), this);

      Level level = Level.FINEST;
      if (!shutdownRequested)
         level = Level.SEVERE;
      logger.log(level, "Failed to start addon [" + addon.getId() + "] with classloader ["
               + stateManager.getClassLoaderOf(addon)
               + "]", e);
   }
   finally
   {
      lifecycleManager.finishedStarting(addon);
      SecurityActions.cleanupThreadLocals(Thread.currentThread());
      currentThread.setName(name);
      currentThread.setContextClassLoader(null);
   }
}
 
開發者ID:forge,項目名稱:furnace,代碼行數:57,代碼來源:AddonRunnable.java

示例5: run

import org.jboss.forge.furnace.util.ClassLoaders; //導入方法依賴的package包/類
@Override
public void run()
{
   Thread currentThread = Thread.currentThread();
   String name = currentThread.getName();
   currentThread.setName(addon.getId().toCoordinates());
   try
   {
      logger.info("> Starting container [" + addon.getId() + "] [" + addon.getRepository().getRootDirectory() + "]");
      long start = System.currentTimeMillis();

      lifecycleProviderEntry = detectLifecycleProvider();
      if (lifecycleProviderEntry != null)
      {
         final AddonLifecycleProvider lifecycleProvider = lifecycleProviderEntry.getProvider();
         ClassLoaders.executeIn(addon.getClassLoader(), new Callable<Void>()
         {
            @Override
            public Void call() throws Exception
            {
               lifecycleProvider.initialize(furnace, furnace.getAddonRegistry(getRepositories()),
                        lifecycleProviderEntry.getAddon());
               lifecycleProvider.start(addon);
               stateManager.setServiceRegistry(addon, lifecycleProvider.getServiceRegistry(addon));
               stateManager.setEventManager(addon, lifecycleProvider.getEventManager(addon));

               for (AddonDependency dependency : addon.getDependencies())
               {
                  if (dependency.getDependency().getStatus().isLoaded())
                     Addons.waitUntilStarted(dependency.getDependency());
               }

               lifecycleProvider.postStartup(addon);
               for (AddonView view : stateManager.getViewsOf(addon))
               {
                  for (Addon a : view.getAddons(notThisAddonFilter))
                  {
                     a.getEventManager().fireEvent(new PostStartup(addon));
                  }
               }
               return null;
            }
         });
      }

      logger.info(">> Started container [" + addon.getId() + "] - " + (System.currentTimeMillis() - start) + "ms");

   }
   catch (Throwable e)
   {
      addon.getFuture().cancel(false);

      Level level = Level.FINEST;
      if (!shutdownRequested)
         level = Level.SEVERE;

      logger.log(level, "Failed to start addon [" + addon.getId() + "] with classloader ["
               + stateManager.getClassLoaderOf(addon)
               + "]", e);
   }
   finally
   {
      lifecycleManager.finishedStarting(addon);
      SecurityActions.cleanupThreadLocals(Thread.currentThread());
      currentThread.setName(name);
      currentThread.setContextClassLoader(null);
   }
}
 
開發者ID:koentsje,項目名稱:forge-furnace,代碼行數:69,代碼來源:AddonRunnable.java


注:本文中的org.jboss.forge.furnace.util.ClassLoaders.executeIn方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。