本文整理汇总了Java中org.jboss.forge.furnace.spi.ListenerRegistration类的典型用法代码示例。如果您正苦于以下问题:Java ListenerRegistration类的具体用法?Java ListenerRegistration怎么用?Java ListenerRegistration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ListenerRegistration类属于org.jboss.forge.furnace.spi包,在下文中一共展示了ListenerRegistration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: waitForConfigurationRescan
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
private <T> T waitForConfigurationRescan(Callable<T> action)
{
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = runnable.furnace
.addContainerLifecycleListener(listener);
T result = Callables.call(action);
while (runnable.furnace.getStatus().isStarting() || !listener.isConfigurationScanned())
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
throw new RuntimeException("Sleep interrupted while waiting for configuration rescan.", e);
}
}
registration.removeListener();
return result;
}
示例2: testContainerStartup
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testContainerStartup() throws Exception
{
Furnace furnace = FurnaceFactory.getInstance();
TestLifecycleListener listener = new TestLifecycleListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
File temp = OperatingSystemUtils.createTempDir();
temp.deleteOnExit();
furnace.addRepository(AddonRepositoryMode.IMMUTABLE, temp);
furnace.startAsync();
waitUntilStarted(furnace);
Assert.assertEquals(1, listener.beforeStartTimesCalled);
Assert.assertEquals(1, listener.afterStartTimesCalled);
registration.removeListener();
furnace.stop();
}
示例3: cleanup
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
private void cleanup()
{
for (ListenerRegistration<ContainerLifecycleListener> registation : loadedListenerRegistrations)
{
registation.removeListener();
}
registeredListeners.clear();
loader = null;
manager.dispose();
manager = null;
for (RepositoryEntry entry : repositories)
{
try
{
entry.getDirtyChecker().close();
}
catch (Exception e)
{
logger.log(Level.SEVERE, "Error occurred.", e);
}
}
repositories.clear();
executor.shutdownNow();
firedAfterStart = false;
}
示例4: testContainerStartup
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testContainerStartup() throws Exception
{
Furnace furnace = FurnaceFactory.getInstance();
TestLifecycleListener listener = new TestLifecycleListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
File temp = File.createTempFile("addonDir", "sdfsdf");
temp.deleteOnExit();
furnace.addRepository(AddonRepositoryMode.IMMUTABLE, temp);
furnace.startAsync();
waitUntilStarted(furnace);
Assert.assertEquals(1, listener.beforeStartTimesCalled);
registration.removeListener();
furnace.stop();
}
示例5: testAddonsLoadAPIClassesFromBootpathJAR
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsLoadAPIClassesFromBootpathJAR() throws IOException, Exception
{
Furnace furnace = FurnaceFactory.getInstance();
furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
manager.install(no_dep).perform();
manager.install(one_dep).perform();
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
registration.removeListener();
Addon projectsAddon = furnace.getAddonRegistry().getAddon(no_dep);
Addons.waitUntilStarted(projectsAddon, 10, TimeUnit.SECONDS);
ClassLoader addonClassLoader = projectsAddon.getClassLoader().loadClass(Addon.class.getName()).getClassLoader();
ClassLoader appClassLoader = Addon.class.getClassLoader();
Assert.assertNotEquals(appClassLoader, addonClassLoader);
Assert.assertTrue(projectsAddon.getStatus().isStarted());
furnace.stop();
}
示例6: perform
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Override
public final void perform()
{
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> reg = furnace.addContainerLifecycleListener(listener);
try
{
execute();
if (!furnace.getStatus().isStopped())
{
while (furnace.getStatus().isStarting() || !listener.isConfigurationScanned())
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
throw new RuntimeException(e);
}
}
}
}
finally
{
reg.removeListener();
}
}
示例7: addContainerLifecycleListener
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Override
public ListenerRegistration<ContainerLifecycleListener> addContainerLifecycleListener(
final ContainerLifecycleListener listener)
{
registeredListeners.add(listener);
return new ListenerRegistration<ContainerLifecycleListener>()
{
@Override
public ContainerLifecycleListener removeListener()
{
registeredListeners.remove(listener);
return listener;
}
};
}
示例8: cleanup
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
private void cleanup()
{
for (ListenerRegistration<ContainerLifecycleListener> registation : loadedListenerRegistrations)
{
registation.removeListener();
}
registeredListeners.clear();
lastRepoVersionSeen.clear();
loader = null;
manager.dispose();
manager = null;
repositories.clear();
}
示例9: addLifecycleListener
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
/**
* Add a {@link RuleLifecycleListener} to receive events when {@link Rule} instances are evaluated, executed, and their results.
*/
public ListenerRegistration<RuleLifecycleListener> addLifecycleListener(final RuleLifecycleListener listener)
{
this.listeners.add(listener);
return new ListenerRegistration<RuleLifecycleListener>()
{
@Override
public RuleLifecycleListener removeListener()
{
listeners.remove(listener);
return listener;
}
};
}
示例10: testAddonsDuplicatedIfSubgraphDiffers
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsDuplicatedIfSubgraphDiffers() throws IOException, InterruptedException, TimeoutException
{
Furnace furnace = FurnaceFactory.getInstance();
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, leftRepo);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, rightRepo);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
AddonId one_dep_lib = AddonId.from("test:one_dep_lib", "1.0.0.Final");
AddonId one_dep_2 = AddonId.from("test:one_dep", "2.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_lib));
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(left.isDeployed(one_dep_2));
Assert.assertFalse(right.isDeployed(one_dep_lib));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_2));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, left).perform();
manager.deploy(one_dep_lib, left).perform();
manager.deploy(one_dep_2, right).perform();
Assert.assertTrue(left.isDeployed(no_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(left.isDeployed(one_dep_a));
Assert.assertTrue(left.isDeployed(one_dep_lib));
Assert.assertFalse(left.isDeployed(one_dep_2));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(one_dep_lib));
Assert.assertTrue(right.isDeployed(one_dep_2));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
AddonRegistry registry = furnace.getAddonRegistry();
Addons.waitUntilStarted(registry.getAddon(one_dep_a), 10, TimeUnit.SECONDS);
AddonRegistry leftRegistry = furnace.getAddonRegistry(left);
Addon addon = leftRegistry.getAddon(one_dep);
Assert.assertNotNull(addon);
registration.removeListener();
furnace.stop();
}
示例11: testAddonsCanReferenceDependenciesInOtherRepositories
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsCanReferenceDependenciesInOtherRepositories() throws IOException, InterruptedException,
TimeoutException
{
Furnace furnace = FurnaceFactory.getInstance();
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, right).perform();
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(right.isDeployed(one_dep_a));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(one_dep_a), 10, TimeUnit.SECONDS);
registration.removeListener();
furnace.stop();
}
示例12: testAddonsDontFailIfDuplicatedInOtherRepositories
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsDontFailIfDuplicatedInOtherRepositories() throws IOException, Exception
{
Furnace furnace = FurnaceFactory.getInstance();
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, left).perform();
manager.deploy(one_dep_a, right).perform();
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertTrue(left.isDeployed(one_dep_a));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(left.isDeployed(one_dep_a));
Assert.assertTrue(right.isDeployed(one_dep_a));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
registration.removeListener();
Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(one_dep_a), 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(no_dep), 10, TimeUnit.SECONDS);
Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(one_dep), 10, TimeUnit.SECONDS);
System.out.println("Getting instances.");
//FIXME Mocked addons should contain these classes. Use reflection to avoid compile-time dependency ?
// ExportedInstance<ConverterFactory> instance = furnace.getAddonRegistry()
// .getExportedInstance(ConverterFactory.class);
// ConverterFactory factory = instance.get();
//
// factory.getConverter(File.class,
// furnace.getAddonRegistry().getAddon(one_dep_a).getClassLoader()
// .loadClass("org.jboss.forge.addon.resource.DirectoryResource"));
furnace.stop();
}
示例13: start
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Override
public void start(ClassLoader loader)
{
logger.log(Level.INFO, "Furnace [" + getVersion() + "] starting.");
assertNotAlive();
alive = true;
this.loader = loader;
for (ContainerLifecycleListener listener : ServiceLoader.load(ContainerLifecycleListener.class, loader))
{
ListenerRegistration<ContainerLifecycleListener> registration = addContainerLifecycleListener(listener);
loadedListenerRegistrations.add(registration);
}
fireBeforeContainerStartedEvent();
try
{
getAddonRegistry();
do
{
lock.performLocked(LockMode.WRITE, new Callable<Void>()
{
@Override
public Void call() throws Exception
{
boolean dirty = false;
if (!getLifecycleManager().isStartingAddons())
{
for (RepositoryEntry entry : repositories)
{
DirtyChecker dirtyChecker = entry.getDirtyChecker();
if (dirtyChecker.isDirty())
{
logger.log(Level.FINE, "Detected changes in repository [" + entry.getRepository() + "].");
dirty = true;
}
dirtyChecker.resetDirtyStatus();
}
if (dirty)
{
reloadConfiguration();
}
}
status = ContainerStatus.STARTED;
if (!firedAfterStart)
{
fireAfterContainerStartedEvent();
firedAfterStart = true;
}
return null;
}
});
Thread.sleep(100);
}
while (isAlive() && serverMode);
while (isAlive() && getLifecycleManager().isStartingAddons())
{
Thread.sleep(100);
}
}
catch (Exception e)
{
logger.log(Level.SEVERE, "Error occurred.", e);
}
finally
{
fireBeforeContainerStoppedEvent();
status = ContainerStatus.STOPPED;
getLifecycleManager().stopAll();
}
fireAfterContainerStoppedEvent();
cleanup();
}
示例14: testAddonsSharedIfSubgraphEquivalent
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsSharedIfSubgraphEquivalent() throws IOException, InterruptedException, TimeoutException
{
Furnace furnace = FurnaceFactory.getInstance(Furnace.class.getClassLoader());
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
AddonId no_dep2 = AddonId.from("test:no_dep", "2.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(no_dep2));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(no_dep2));
Assert.assertFalse(right.isDeployed(one_dep));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, right).perform();
manager.deploy(no_dep2, right).perform();
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(no_dep2));
Assert.assertTrue(left.isDeployed(no_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(right.isDeployed(one_dep_a));
Assert.assertTrue(right.isDeployed(no_dep2));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
AddonRegistry registry = furnace.getAddonRegistry();
Addons.waitUntilStarted(registry.getAddon(one_dep_a), 10, TimeUnit.SECONDS);
AddonRegistry leftRegistry = furnace.getAddonRegistry(left);
Assert.assertNotNull(leftRegistry.getAddon(no_dep));
Assert.assertTrue(registry.getAddon(no_dep).getStatus().isMissing());
Assert.assertNotNull(registry.getAddon(no_dep2));
Assert.assertTrue(leftRegistry.getAddon(no_dep2).getStatus().isMissing());
registration.removeListener();
furnace.stop();
}
示例15: testAddonsDuplicatedIfSubgraphDiffers
import org.jboss.forge.furnace.spi.ListenerRegistration; //导入依赖的package包/类
@Test
public void testAddonsDuplicatedIfSubgraphDiffers() throws IOException, InterruptedException, TimeoutException
{
Furnace furnace = FurnaceFactory.getInstance(Furnace.class.getClassLoader());
AddonRepository left = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir1);
AddonRepository right = furnace.addRepository(AddonRepositoryMode.MUTABLE, repodir2);
AddonDependencyResolver resolver = new MavenAddonDependencyResolver();
AddonManager manager = new AddonManagerImpl(furnace, resolver);
AddonId no_dep = AddonId.from("test:no_dep", "1.0.0.Final");
AddonId one_dep = AddonId.from("test:one_dep", "1.0.0.Final");
AddonId one_dep_a = AddonId.from("test:one_dep_a", "1.0.0.Final");
AddonId one_dep_lib = AddonId.from("test:one_dep_lib", "1.0.0.Final");
AddonId one_dep_2 = AddonId.from("test:one_dep", "2.0.0.Final");
Assert.assertFalse(left.isDeployed(one_dep_lib));
Assert.assertFalse(left.isDeployed(one_dep_a));
Assert.assertFalse(left.isDeployed(no_dep));
Assert.assertFalse(left.isDeployed(one_dep));
Assert.assertFalse(left.isDeployed(one_dep_2));
Assert.assertFalse(right.isDeployed(one_dep_lib));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_2));
manager.install(no_dep, left).perform();
manager.deploy(one_dep, left).perform();
manager.deploy(one_dep_a, left).perform();
manager.deploy(one_dep_lib, left).perform();
manager.deploy(one_dep_2, right).perform();
Assert.assertTrue(left.isDeployed(no_dep));
Assert.assertTrue(left.isDeployed(one_dep));
Assert.assertTrue(left.isDeployed(one_dep_a));
Assert.assertTrue(left.isDeployed(one_dep_lib));
Assert.assertFalse(left.isDeployed(one_dep_2));
Assert.assertFalse(right.isDeployed(no_dep));
Assert.assertFalse(right.isDeployed(one_dep));
Assert.assertFalse(right.isDeployed(one_dep_a));
Assert.assertFalse(right.isDeployed(one_dep_lib));
Assert.assertTrue(right.isDeployed(one_dep_2));
ConfigurationScanListener listener = new ConfigurationScanListener();
ListenerRegistration<ContainerLifecycleListener> registration = furnace.addContainerLifecycleListener(listener);
furnace.startAsync();
while (!listener.isConfigurationScanned())
Thread.sleep(100);
AddonRegistry registry = furnace.getAddonRegistry();
Addons.waitUntilStarted(registry.getAddon(one_dep_a), 10, TimeUnit.SECONDS);
AddonRegistry leftRegistry = furnace.getAddonRegistry(left);
Addon addon = leftRegistry.getAddon(one_dep);
Assert.assertNotNull(addon);
registration.removeListener();
furnace.stop();
}