当前位置: 首页>>代码示例>>Java>>正文


Java ContainerException类代码示例

本文整理汇总了Java中org.jboss.forge.furnace.exception.ContainerException的典型用法代码示例。如果您正苦于以下问题:Java ContainerException类的具体用法?Java ContainerException怎么用?Java ContainerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContainerException类属于org.jboss.forge.furnace.exception包,在下文中一共展示了ContainerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: waitUntilStopped

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
public static void waitUntilStopped(Addon addon)
{
   if (addon != null)
   {
      try
      {
         while (addon.getStatus().isStarted())
         {
            Thread.sleep(10);
         }
      }
      catch (Exception e)
      {
         throw new ContainerException("Addon [" + addon + "] was not stopped.", e);
      }
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:18,代码来源:Addons.java

示例2: waitUntilStarted

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
public static void waitUntilStarted(Addon addon, int quantity, TimeUnit unit) throws TimeoutException
{
   long start = System.currentTimeMillis();
   long threshold = start + TimeUnit.MILLISECONDS.convert(quantity, unit);
   while (!addon.getStatus().isStarted())
   {
      if (System.currentTimeMillis() > threshold)
      {
         throw new TimeoutException("Timeout expired waiting for [" + addon + "] to start.");
      }

      try
      {
         Thread.sleep(10);
      }
      catch (RuntimeException re)
      {
         throw re;
      }
      catch (Exception e)
      {
         throw new ContainerException("Addon [" + addon + "] was not started.", e);
      }
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:26,代码来源:Addons.java

示例3: loadClass

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
public static Class<?> loadClass(ClassLoader loader, String typeName)
{
   if (loader == null)
      throw new IllegalArgumentException("Class loader to inspect must not be null.");
   if (typeName == null)
      throw new IllegalArgumentException("Class name to find must not be null.");

   try
   {
      return loader.loadClass(typeName);
   }
   catch (ClassNotFoundException | LinkageError e)
   {
      throw new ContainerException("Could not locate class [" + typeName + "] in Loader [" + loader + "]", e);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:17,代码来源:ClassLoaders.java

示例4: addAddonDependency

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
private void addAddonDependency(Set<AddonView> views, AddonId found, Builder builder,
         AddonDependencyEntry dependency)
{
   AddonId addonId = stateManager.resolveAddonId(views, dependency.getName());
   ModuleIdentifier moduleId = null;
   if (addonId != null)
   {
      Addon addon = lifecycleManager.getAddon(views, addonId);
      moduleId = findCompatibleInstalledModule(addonId);
      if (moduleId != null)
      {
         builder.addDependency(DependencySpec.createModuleDependencySpec(
                  PathFilters.not(PathFilters.getMetaInfFilter()),
                  dependency.isExported() ? PathFilters.acceptAll() : PathFilters.rejectAll(),
                  this,
                  moduleCache.getModuleId(addon),
                  dependency.isOptional()));
      }
   }

   if (!dependency.isOptional() && (addonId == null || moduleId == null))
      throw new ContainerException("Dependency [" + dependency + "] could not be loaded for addon [" + found
               + "]");
}
 
开发者ID:forge,项目名称:furnace,代码行数:25,代码来源:AddonModuleLoader.java

示例5: get

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@Override
public T get()
{
   if (isAmbiguous())
      throw new IllegalStateException("Cannot resolve Ambiguous dependencies: " + toString());

   ExportedInstance<T> exported = getExportedInstance();
   if (exported != null)
   {
      T instance = exported.get();
      instanceMap.put(instance, exported);
      return instance;
   }
   else
      throw new ContainerException("No services of type [" + typeName + "] could be found in any started addons.");
}
 
开发者ID:forge,项目名称:furnace,代码行数:17,代码来源:ImportedImpl.java

示例6: selectExact

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@Override
public T selectExact(Class<T> type)
{
   Assert.notNull(type, "Type to select must not be null.");
   Set<ExportedInstance<T>> instances = getExportedInstances();
   for (ExportedInstance<T> instance : instances)
   {
      if (type.equals(instance.getActualType()))
      {
         T result = instance.get();
         instanceMap.put(result, instance);
         return result;
      }
   }
   throw new ContainerException("No services of type [" + type + "] could be found in any started addons.");
}
 
开发者ID:forge,项目名称:furnace,代码行数:17,代码来源:ImportedImpl.java

示例7: waitUntilStarted

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
public static void waitUntilStarted(Addon addon, int quantity, TimeUnit unit) throws TimeoutException
{
   long start = System.currentTimeMillis();
   while (!addon.getStatus().isStarted())
   {
      if (System.currentTimeMillis() > (start + TimeUnit.MILLISECONDS.convert(quantity, unit)))
      {
         throw new TimeoutException("Timeout expired waiting for [" + addon + "] to start.");
      }

      try
      {
         Thread.sleep(10);
      }
      catch (RuntimeException re)
      {
         throw re;
      }
      catch (Exception e)
      {
         throw new ContainerException("Addon [" + addon + "] was not started.", e);
      }
   }
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:25,代码来源:Addons.java

示例8: addAddonDependency

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
private void addAddonDependency(Set<AddonView> views, AddonId found, Builder builder, AddonDependencyEntry dependency)
{
   AddonId addonId = stateManager.resolveAddonId(views, dependency.getName());
   ModuleIdentifier moduleId = null;
   if (addonId != null)
   {
      Addon addon = lifecycleManager.getAddon(views, addonId);
      moduleId = findCompatibleInstalledModule(addonId);
      if (moduleId != null)
      {
         builder.addDependency(DependencySpec.createModuleDependencySpec(
                  PathFilters.not(PathFilters.getMetaInfFilter()),
                  dependency.isExported() ? PathFilters.acceptAll() : PathFilters.rejectAll(),
                  this,
                  moduleCache.getModuleId(addon),
                  dependency.isOptional()));
      }
   }

   if (!dependency.isOptional() && (addonId == null || moduleId == null))
      throw new ContainerException("Dependency [" + dependency + "] could not be loaded for addon [" + found
               + "]");
}
 
开发者ID:koentsje,项目名称:forge-furnace,代码行数:24,代码来源:AddonModuleLoader.java

示例9: testServiceProxiesCanBeInterrupted

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@Test
public void testServiceProxiesCanBeInterrupted() throws Exception
{
   AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
            .getAddonRegistry();

   final MockSimpleCountService service = registry.getServices(MockSimpleCountService.class).get();
   final AtomicReference<ContainerException> exception = new AtomicReference<>();
   Thread t = new Thread(new Runnable()
   {
      @Override
      public void run()
      {
         try
         {
            while (true)
            {
               service.execute();
            }
         }
         catch (ContainerException e)
         {
            exception.set(e);
         }

         if (!Thread.currentThread().isInterrupted())
            throw new RuntimeException("Should have been interrupted at this point.");
      }
   });

   Assert.assertNull(exception.get());

   t.start();
   Thread.sleep(250);
   t.interrupt();
   Thread.sleep(250);

   Assert.assertTrue(service.execute() > 0);
   Assert.assertNotNull(exception.get());
}
 
开发者ID:forge,项目名称:furnace,代码行数:41,代码来源:ThreadProxyInterruptTest.java

示例10: waitUntilStartedOrMissing

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
/**
 * Waits until the specified {@link Addon} starts or is missing
 */
public static void waitUntilStartedOrMissing(Addon addon, int quantity, TimeUnit unit) throws TimeoutException
{
   if (addon != null)
   {
      long start = System.currentTimeMillis();
      long threshold = start + TimeUnit.MILLISECONDS.convert(quantity, unit);
      while (!addon.getStatus().isStarted() && !addon.getStatus().isMissing())
      {
         if (System.currentTimeMillis() > threshold)
         {
            throw new TimeoutException("Timeout expired waiting for [" + addon + "] to load.");
         }

         try
         {
            Thread.sleep(10);
         }
         catch (RuntimeException re)
         {
            throw re;
         }
         catch (Exception e)
         {
            throw new ContainerException("Addon [" + addon + "] was not loaded.", e);
         }
      }
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:32,代码来源:Addons.java

示例11: get

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@Override
public T get()
{
   try
   {
      T delegate = type.newInstance();
      delegate = Proxies.enhance(addon.getClassLoader(), delegate, new ClassLoaderInterceptor(
               addon.getClassLoader(), delegate));
      return delegate;
   }
   catch (Exception e)
   {
      throw new ContainerException("Could not create instance of [" + type.getName() + "] through reflection.", e);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:16,代码来源:ReflectionExportedInstance.java

示例12: enhanceEnum

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Object enhanceEnum(ClassLoader loader, Object instance)
{
   try
   {
      final Class<Enum> callingType = (Class<Enum>) loader.loadClass(instance.getClass().getName());
      return Enum.valueOf(callingType, ((Enum) instance).name());
   }
   catch (final ClassNotFoundException e)
   {
      throw new ContainerException(
               "Could not enhance instance [" + instance + "] of type [" + instance.getClass() + "]", e);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:15,代码来源:ClassLoaderAdapterCallback.java

示例13: testDoesNotResolveNonService

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
@Test(expected = ContainerException.class)
public void testDoesNotResolveNonService() throws Exception
{
   AddonRegistry registry = LocalServices.getFurnace(getClass().getClassLoader())
            .getAddonRegistry();

   Imported<MockServiceConsumer> importedByName = registry.getServices(MockServiceConsumer.class.getName());
   Assert.assertTrue(importedByName.isUnsatisfied());
   importedByName.get();
}
 
开发者ID:forge,项目名称:furnace,代码行数:11,代码来源:ImportedLookupTest.java

示例14: addLocalResources

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
private void addLocalResources(AddonRepository repository, AddonId found, Builder builder, ModuleIdentifier id)
{
   List<File> resources = repository.getAddonResources(found);
   for (File file : resources)
   {
      try
      {
         if (file.isDirectory())
         {
            builder.addResourceRoot(
                     ResourceLoaderSpec.createResourceLoaderSpec(
                              ResourceLoaders.createFileResourceLoader(file.getName(), file),
                              PathFilters.acceptAll()));
         }
         else if (file.length() > 0)
         {
            JarFile jarFile = new JarFile(file);
            moduleJarFileCache.addJarFileReference(id, jarFile);
            builder.addResourceRoot(
                     ResourceLoaderSpec.createResourceLoaderSpec(
                              ResourceLoaders.createJarResourceLoader(file.getName(), jarFile),
                              PathFilters.acceptAll()));
         }
      }
      catch (IOException e)
      {
         throw new ContainerException("Could not load resources from [" + file.getAbsolutePath() + "]", e);
      }
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:31,代码来源:AddonModuleLoader.java

示例15: addContainerDependencies

import org.jboss.forge.furnace.exception.ContainerException; //导入依赖的package包/类
private void addContainerDependencies(Set<AddonView> views, AddonRepository repository, AddonId found,
         Builder builder)
                  throws ContainerException
{
   Set<AddonDependencyEntry> addons = repository.getAddonDependencies(found);
   for (AddonDependencyEntry dependency : addons)
   {
      /*
       * Containers should always take precedence at runtime.
       */
      if (dependency.getName().startsWith(CONTAINER_PREFIX))
         addAddonDependency(views, found, builder, dependency);
   }
}
 
开发者ID:forge,项目名称:furnace,代码行数:15,代码来源:AddonModuleLoader.java


注:本文中的org.jboss.forge.furnace.exception.ContainerException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。