本文整理匯總了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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}