本文整理匯總了Java中org.jboss.forge.furnace.spi.ExportedInstance類的典型用法代碼示例。如果您正苦於以下問題:Java ExportedInstance類的具體用法?Java ExportedInstance怎麽用?Java ExportedInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ExportedInstance類屬於org.jboss.forge.furnace.spi包,在下文中一共展示了ExportedInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getExportedInstance
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public <T> ExportedInstance<T> getExportedInstance(final Class<T> requestedType)
{
Assert.notNull(requestedType, "Requested Class type may not be null");
if (!ClassLoaders.ownsClass(addon.getClassLoader(), requestedType))
{
log.fine("Class " + requestedType.getName() + " is not present in this addon [" + addon + "]");
}
for (Class<?> type : serviceTypes)
{
if (requestedType.isAssignableFrom(type))
{
return new ReflectionExportedInstance<T>(addon, (Class<T>) type);
}
}
return null;
}
示例2: testExportedInstanceExposesServiceTypeAndSourceAddon
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Test
public void testExportedInstanceExposesServiceTypeAndSourceAddon() throws Exception
{
Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
Assert.assertNotNull(furnace);
AddonRegistry registry = furnace.getAddonRegistry();
boolean found = false;
for (Addon addon : registry.getAddons())
{
ExportedInstance<ExportedInstanceApiTest> instance = addon.getServiceRegistry()
.getExportedInstance(ExportedInstanceApiTest.class);
if (instance != null)
{
found = true;
Assert.assertEquals(ExportedInstanceApiTest.class, instance.getActualType());
Assert.assertEquals(addon, instance.getSourceAddon());
break;
}
}
Assert.assertTrue("Could not locate service in any addon.", found);
}
示例3: get
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的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.");
}
示例4: selectExact
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的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.");
}
示例5: toString
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public String toString()
{
StringBuilder result = new StringBuilder();
result.append("[");
Iterator<ExportedInstance<T>> iterator = this.getExportedInstances().iterator();
while (iterator.hasNext())
{
ExportedInstance<T> instance = iterator.next();
result.append(instance.getActualType().getName()).append(" from addon ");
result.append(instance.getSourceAddon().getId());
if (iterator.hasNext())
result.append(",\n");
}
result.append("]");
return result.toString();
}
示例6: getExportedInstances
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
@SuppressWarnings("rawtypes")
public <T> Set<ExportedInstance<T>> getExportedInstances(Class<T> clazz)
{
Set<ExportedInstance<T>> result = (Set) instancesCache.get(clazz.getName());
if (result == null)
{
result = delegate.getExportedInstances(clazz);
instancesCache.put(clazz.getName(), (Set) result);
}
return result;
}
示例7: getExportedInstance
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public <T> ExportedInstance<T> getExportedInstance(Class<T> type)
{
ExportedInstance<?> exportedInstance = instanceCache.get(type.getName());
if (exportedInstance == null)
{
exportedInstance = delegate.getExportedInstance(type);
instanceCache.put(type.getName(), exportedInstance);
}
return (ExportedInstance<T>) exportedInstance;
}
示例8: fireEvent
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public void fireEvent(Object event, Annotation... qualifiers) throws EventException
{
ServiceRegistry registry = addon.getServiceRegistry();
ExportedInstance<EventManager> instance = registry.getExportedInstance(EventManager.class);
if (instance != null)
{
EventManager manager = instance.get();
manager.fireEvent(event, qualifiers);
instance.release(manager);
}
}
示例9: getExportedInstances
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public <T> Set<ExportedInstance<T>> getExportedInstances(Class<T> requestedType)
{
Set<ExportedInstance<T>> result = new HashSet<ExportedInstance<T>>();
for (Class<?> type : serviceTypes)
{
if (requestedType.isAssignableFrom(type))
{
result.add(new ReflectionExportedInstance<T>(addon, (Class<T>) type));
}
}
return result;
}
示例10: release
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public void release(T instance)
{
ExportedInstance<T> exported = instanceMap.get(instance);
if (exported != null)
{
instanceMap.remove(instance);
exported.release(instance);
}
}
示例11: getExportedInstance
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
private ExportedInstance<T> getExportedInstance()
{
return lock.performLocked(LockMode.READ, new Callable<ExportedInstance<T>>()
{
@Override
public ExportedInstance<T> call() throws Exception
{
Iterator<ExportedInstance<T>> iterator = getExportedInstances().iterator();
if (iterator.hasNext())
return iterator.next();
return null;
}
});
}
示例12: getExportedInstances
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
private Set<ExportedInstance<T>> getExportedInstances()
{
return lock.performLocked(LockMode.READ, new Callable<Set<ExportedInstance<T>>>()
{
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public Set<ExportedInstance<T>> call() throws Exception
{
if (addonRegistry.getVersion() != version)
{
version = addonRegistry.getVersion();
instanceCache.clear();
for (Addon addon : addonRegistry.getAddons())
{
if (addon.getStatus().isStarted())
{
ServiceRegistry serviceRegistry = addon.getServiceRegistry();
if (type != null)
{
instanceCache.addAll(serviceRegistry.getExportedInstances(type));
}
else
{
instanceCache.addAll((Collection) serviceRegistry.getExportedInstances(typeName));
}
}
}
}
return instanceCache;
}
});
}
示例13: next
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public T next()
{
ExportedInstance<T> exported = iterator.next();
T instance = exported.get();
imported.instanceMap.put(instance, exported);
return instance;
}
示例14: getExportedInstances
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
@Override
public <T> Set<ExportedInstance<T>> getExportedInstances(Class<T> requestedType)
{
Set<ExportedInstance<T>> result = new HashSet<ExportedInstance<T>>();
for (Class<?> type : serviceTypes)
{
if (requestedType.isAssignableFrom(type))
{
result.add(new ReflectionExportedInstance<T>(addon, requestedType));
}
}
return result;
}
示例15: getExportedInstance
import org.jboss.forge.furnace.spi.ExportedInstance; //導入依賴的package包/類
private ExportedInstance<T> getExportedInstance()
{
return lock.performLocked(LockMode.READ, new Callable<ExportedInstance<T>>()
{
@Override
public ExportedInstance<T> call() throws Exception
{
ExportedInstance<T> result = null;
for (Addon addon : addonRegistry.getAddons())
{
if (AddonStatus.STARTED.equals(addon.getStatus()))
{
ServiceRegistry serviceRegistry = addon.getServiceRegistry();
if (type != null)
{
result = serviceRegistry.getExportedInstance(type);
}
else
{
result = serviceRegistry.getExportedInstance(typeName);
}
}
if (result != null)
break;
}
return result;
}
});
}