org.jboss.forge.furnace.repositories.AddonRepositoryMode Java Examples
The following examples show how to use
org.jboss.forge.furnace.repositories.AddonRepositoryMode.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FurnaceProducer.java From fabric8-forge with Apache License 2.0 | 6 votes |
public void setup(File repoDir) { furnace = FurnaceFactory.getInstance(Thread.currentThread() .getContextClassLoader(), Thread.currentThread() .getContextClassLoader()); furnace.addRepository(AddonRepositoryMode.IMMUTABLE, repoDir); Future<Furnace> future = furnace.startAsync(); try { future.get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException("Furnace failed to start.", e); } AddonRegistry addonRegistry = furnace.getAddonRegistry(); commandFactory = addonRegistry.getServices(CommandFactory.class).get(); controllerFactory = (CommandControllerFactory) addonRegistry .getServices(CommandControllerFactory.class.getName()).get(); dependencyResolver = (DependencyResolver) addonRegistry .getServices(DependencyResolver.class.getName()).get(); }
Example #2
Source File: AddonManagerHotswapTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Before public void setUp() throws IOException, InterruptedException { furnace = ServiceLoader.load(Furnace.class).iterator().next(); resolver = new MavenAddonDependencyResolver(); repository = File.createTempFile("furnace-repo", ".tmp"); repository.delete(); repository.mkdir(); furnace.addRepository(AddonRepositoryMode.MUTABLE, repository); furnace.startAsync(); while (!furnace.getStatus().isStarted()) { Thread.sleep(100); } addonManager = new AddonManagerImpl(furnace, resolver); }
Example #3
Source File: AddonManagerHotswapTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Test(timeout = 20000) public void testFurnaceLoadsInstalledAddonFromSeparateInstance() throws IOException, TimeoutException { Assert.assertEquals(1, furnace.getRepositories().size()); Assert.assertEquals(0, furnace.getAddonRegistry().getAddons().size()); Assert.assertEquals(0, furnace.getRepositories().get(0).listEnabled().size()); Furnace furnace2 = ServiceLoader.load(Furnace.class).iterator().next(); AddonDependencyResolver resolver = new MavenAddonDependencyResolver(); furnace2.addRepository(AddonRepositoryMode.MUTABLE, repository); AddonManager addonManager = new AddonManagerImpl(furnace2, resolver); AddonId addon = AddonId.from("test:no_dep", "1.1.2-SNAPSHOT"); InstallRequest install = addonManager.install(addon); List<? extends AddonActionRequest> actions = install.getActions(); Assert.assertEquals(1, actions.size()); Assert.assertThat(actions.get(0), instanceOf(DeployRequest.class)); install.perform(); Addons.waitUntilStarted(furnace.getAddonRegistry().getAddon(addon)); Assert.assertEquals(1, furnace2.getRepositories().get(0).listEnabled().size()); Assert.assertEquals(1, furnace.getRepositories().get(0).listEnabled().size()); Assert.assertEquals(1, furnace.getAddonRegistry().getAddons().size()); }
Example #4
Source File: ContainerLifecycleListenerTest.java From furnace with Eclipse Public License 1.0 | 6 votes |
@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(); }
Example #5
Source File: AddonRemoveMojo.java From furnace with Eclipse Public License 1.0 | 6 votes |
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Execution skipped."); return; } if (!addonRepository.exists()) { throw new MojoExecutionException("Addon Repository " + addonRepository.getAbsolutePath() + " does not exist."); } Furnace forge = new FurnaceImpl(); AddonRepository repository = forge.addRepository(AddonRepositoryMode.MUTABLE, addonRepository); MavenAddonDependencyResolver addonResolver = new MavenAddonDependencyResolver(this.classifier); addonResolver.setSettings(settings); AddonManager addonManager = new AddonManagerImpl(forge, addonResolver); for (String addonId : addonIds) { AddonId id = AddonId.fromCoordinates(addonId); RemoveRequest request = addonManager.remove(id, repository); getLog().info("" + request); request.perform(); } }
Example #6
Source File: FurnaceDeployableContainer.java From furnace with Eclipse Public License 1.0 | 6 votes |
private MutableAddonRepository selectTargetRepository(RepositoryLocationAware<?> archive) { MutableAddonRepository target = repository; if (archive instanceof RepositoryLocationAware<?> && ((RepositoryLocationAware<?>) archive).getAddonRepository() != null) { final String repositoryName = ((RepositoryLocationAware<?>) archive).getAddonRepository(); if (deploymentRepositories.get(repositoryName) == null) { target = waitForConfigurationRescan(new Callable<MutableAddonRepository>() { @Override public MutableAddonRepository call() throws Exception { return (MutableAddonRepository) runnable.furnace.addRepository(AddonRepositoryMode.MUTABLE, new File(addonDir, OperatingSystemUtils.getSafeFilename(repositoryName))); } }); deploymentRepositories.put(repositoryName, target); } else target = deploymentRepositories.get(repositoryName); } return target; }
Example #7
Source File: BootstrapClassLoaderTestCase.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void shouldBeAbleToPassClassesIntoDelegate() throws Exception { Furnace instance = FurnaceFactory.getInstance(); File tempDir = File.createTempFile("test", "repository"); tempDir.delete(); tempDir.mkdir(); tempDir.deleteOnExit(); instance.addRepository(AddonRepositoryMode.IMMUTABLE, tempDir); instance.getRepositories().get(0).getAddonResources(AddonId.from("a", "1")); }
Example #8
Source File: FurnaceImplTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void shouldAllowToAddDiskRepository() throws Exception { try (Furnace f = new FurnaceImpl()) { f.addRepository(AddonRepositoryMode.IMMUTABLE, new File("target")); Assert.assertEquals(1, f.getRepositories().size()); } }
Example #9
Source File: FurnaceImplTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void shouldNotAllowMultipleRepositoriesWithSameRootDirectory() throws Exception { try (Furnace f = new FurnaceImpl()) { AddonRepository repo1 = f.addRepository(AddonRepositoryMode.IMMUTABLE, new File("target")); AddonRepository repo2 = f.addRepository(new TestAddonRepository(new File("target"))); Assert.assertEquals(repo1, repo2); } }
Example #10
Source File: FurnaceImplTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testAddMultipleDiskRepositoriesWithSameRootDirectoryIsIdempotent() throws Exception { try (Furnace f = new FurnaceImpl()) { AddonRepository repo1 = f.addRepository(AddonRepositoryMode.IMMUTABLE, new File("target")); AddonRepository repo2 = f.addRepository(AddonRepositoryMode.IMMUTABLE, new File("target")); Assert.assertEquals(repo1, repo2); } }
Example #11
Source File: FurnaceImplTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test(expected = IllegalArgumentException.class) public void shouldValidateAddRepositoryArgumentDirectory() throws Exception { try (Furnace f = new FurnaceImpl()) { f.addRepository(AddonRepositoryMode.IMMUTABLE, null); } }
Example #12
Source File: FurnaceImpl.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Override public AddonRepository addRepository(AddonRepositoryMode mode, File directory) { Assert.notNull(mode, "Addon repository mode must not be null."); Assert.notNull(directory, "Addon repository directory must not be null."); AddonRepository repository = AddonRepositoryImpl.forDirectory(this, directory); if (mode.isImmutable()) repository = new ImmutableAddonRepository(repository); return addRepository(repository); }
Example #13
Source File: ForgeSetArgsTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testAddonsCanReferenceDependenciesInOtherRepositories() throws IOException { String[] args = new String[] { "arg1", "arg2" }; Furnace forge = FurnaceFactory.getInstance(); forge.setArgs(args); forge.addRepository(AddonRepositoryMode.MUTABLE, repodir1); forge.startAsync(); String[] forgeArgs = forge.getArgs(); Assert.assertArrayEquals(args, forgeArgs); forge.stop(); }
Example #14
Source File: MultipleRepositoryTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Test public void testAddTwoRepositoriesToSameLocationIsIdempotent() throws IOException { Furnace forge = FurnaceFactory.getInstance(); AddonRepository repo1 = forge.addRepository(AddonRepositoryMode.MUTABLE, repodir1); AddonRepository repo2 = forge.addRepository(AddonRepositoryMode.MUTABLE, repodir1); Assert.assertEquals(repo1, repo2); }
Example #15
Source File: Furnaces.java From fabric8-forge with Apache License 2.0 | 5 votes |
static Furnace startFurnace() throws Exception { // Create a Furnace instance. NOTE: This must be called only once Furnace furnace = FurnaceFactory.getInstance(); // Add repository containing addons specified in pom.xml furnace.addRepository(AddonRepositoryMode.IMMUTABLE, new File("target/addon-repository")); // Start Furnace in another thread Future<Furnace> future = furnace.startAsync(); // Wait until Furnace is started and return return future.get(); }
Example #16
Source File: FurnaceDeployableContainer.java From furnace with Eclipse Public License 1.0 | 5 votes |
private void initContainer() { runnable = new ForgeRunnable(ClassLoader.getSystemClassLoader()); furnaceHolder.setFurnace(runnable.furnace); thread = new Thread(runnable, "Arquillian Furnace Runtime"); repository = (MutableAddonRepository) runnable.furnace.addRepository(AddonRepositoryMode.MUTABLE, addonDir); }
Example #17
Source File: AddonManagerRepositoryTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
/** * Hack to deploy addon in an immutable repository */ private static void deployAddonInImmutableRepository(AddonId addonId, AddonRepository repository) { Furnace furnace = new FurnaceImpl(); furnace.addRepository(AddonRepositoryMode.MUTABLE, repository.getRootDirectory()); AddonManagerImpl addonManager = new AddonManagerImpl(furnace, new MavenAddonDependencyResolver()); addonManager.deploy(addonId).perform(); }
Example #18
Source File: AddonManagerRepositoryTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
private static AddonRepository registerTempRepository(Furnace furnace, AddonRepositoryMode mode) throws IOException { File repository = File.createTempFile("furnace-repo", ".tmp"); repository.delete(); repository.mkdir(); return furnace.addRepository(mode, repository); }
Example #19
Source File: AddonManagerRepositoryTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws IOException { furnace = new FurnaceImpl(); mutable = registerTempRepository(furnace, AddonRepositoryMode.MUTABLE); immutable = registerTempRepository(furnace, AddonRepositoryMode.IMMUTABLE); addonManager = new AddonManagerImpl(furnace, new MavenAddonDependencyResolver()); }
Example #20
Source File: AddonManagerInstallTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws IOException { furnace = ServiceLoader.load(Furnace.class).iterator().next(); resolver = new MavenAddonDependencyResolver(); repository = OperatingSystemUtils.createTempDir(); furnace.addRepository(AddonRepositoryMode.MUTABLE, repository); addonManager = new AddonManagerImpl(furnace, resolver); }
Example #21
Source File: AddonManagerRealTest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@Before public void setUp() throws IOException { furnace = ServiceLoader.load(Furnace.class).iterator().next(); resolver = new MavenAddonDependencyResolver(); repository = OperatingSystemUtils.createTempDir(); furnace.addRepository(AddonRepositoryMode.MUTABLE, repository); addonManager = new AddonManagerImpl(furnace, resolver); }
Example #22
Source File: FurnaceSETest.java From furnace with Eclipse Public License 1.0 | 5 votes |
@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(); }
Example #23
Source File: AddonInstallMojo.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { getLog().info("Execution skipped."); return; } Furnace forge = new FurnaceImpl(); if (!addonRepository.exists()) { addonRepository.mkdirs(); } else if (overwrite) { try { deleteDirectory(addonRepository); addonRepository.mkdirs(); } catch (IOException e) { forge.close(); throw new MojoExecutionException("Could not delete " + addonRepository, e); } } AddonRepository repository = forge.addRepository(AddonRepositoryMode.MUTABLE, addonRepository); MavenAddonDependencyResolver addonResolver = new MavenAddonDependencyResolver(this.classifier); addonResolver.setSettings(settings); addonResolver.setResolveAddonAPIVersions(!skipAddonAPIVersionResolution); AddonManager addonManager = new AddonManagerImpl(forge, addonResolver); for (String addonId : addonIds) { AddonId id = AddonId.fromCoordinates(addonId); InstallRequest install = addonManager.install(id, repository); if (!install.getActions().isEmpty()) { getLog().info("" + install); install.perform(); } } }
Example #24
Source File: MultipleRepositoryViewTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@Test public void testAddonsSharedIfSubgraphEquivalent() 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 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(left.isDeployed(no_dep2)); Assert.assertTrue(left.isDeployed(no_dep)); Assert.assertTrue(left.isDeployed(one_dep)); Assert.assertFalse(right.isDeployed(one_dep)); Assert.assertFalse(right.isDeployed(no_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); AddonRegistry rightRegistry = furnace.getAddonRegistry(right); Addon leftNoDep = leftRegistry.getAddon(no_dep); Addon rightNoDep = rightRegistry.getAddon(no_dep); Addon rootNoDep = registry.getAddon(no_dep); Assert.assertTrue(leftNoDep.getStatus().isStarted()); Assert.assertFalse(rightNoDep.getStatus().isStarted()); // not deployed to this repository Assert.assertFalse(rootNoDep.getStatus().isStarted()); // there is a newer version Addon leftNoDep2 = leftRegistry.getAddon(no_dep2); Addon rightNoDep2 = rightRegistry.getAddon(no_dep2); Addon rootNoDep2 = registry.getAddon(no_dep2); Assert.assertFalse(leftNoDep2.getStatus().isStarted()); // not deployed to this repository Assert.assertTrue(rightNoDep2.getStatus().isStarted()); Assert.assertTrue(rootNoDep2.getStatus().isStarted()); Addon leftOneDep = leftRegistry.getAddon(one_dep); Addon rightOneDep = rightRegistry.getAddon(one_dep); Addon rootOneDep = registry.getAddon(one_dep); Assert.assertTrue(leftOneDep.getStatus().isStarted()); Assert.assertFalse(rightOneDep.getStatus().isStarted()); // not deployed to this repository Assert.assertTrue(rootOneDep.getStatus().isStarted()); Addon leftOneDepA = leftRegistry.getAddon(one_dep_a); Addon rightOneDepA = rightRegistry.getAddon(one_dep_a); Addon rootOneDepA = registry.getAddon(one_dep_a); Assert.assertFalse(leftOneDepA.getStatus().isStarted()); // not deployed to this repository Assert.assertTrue(rightOneDepA.getStatus().isStarted()); Assert.assertTrue(rootOneDepA.getStatus().isStarted()); registration.removeListener(); furnace.stop(); }
Example #25
Source File: MultipleRepositoryViewTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@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(); }
Example #26
Source File: MultipleRepositoryTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@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(); }
Example #27
Source File: MultipleRepositoryTest.java From furnace with Eclipse Public License 1.0 | 4 votes |
@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(); }
Example #28
Source File: AddAddonDirectoryCommand.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public CommandResult execute() { furnace.addRepository(AddonRepositoryMode.MUTABLE, new File(directory)); return CommandResult.CONTINUE; }
Example #29
Source File: AddImmutableAddonDirectoryCommand.java From windup with Eclipse Public License 1.0 | 4 votes |
@Override public CommandResult execute() { furnace.addRepository(AddonRepositoryMode.IMMUTABLE, new File(directory)); return CommandResult.CONTINUE; }
Example #30
Source File: Bootstrap.java From windup with Eclipse Public License 1.0 | 4 votes |
private void run(List<String> args) { try { furnace = FurnaceFactory.getInstance(); furnace.setServerMode(true); CopyOnWriteArrayList<Command> commands = new CopyOnWriteArrayList<>(processArguments(args)); if (!executePhase(CommandPhase.PRE_CONFIGURATION, commands)) return; if (!executePhase(CommandPhase.CONFIGURATION, commands)) return; if (commands.isEmpty()) { // no commands are available, just print the help and exit new DisplayHelpCommand().execute(); return; } if (!containsMutableRepository(furnace.getRepositories())) { furnace.addRepository(AddonRepositoryMode.MUTABLE, getUserAddonsDir()); } if (!executePhase(CommandPhase.POST_CONFIGURATION, commands) || commands.isEmpty()) return; furnace.addContainerLifecycleListener(containerStatusListener); try { startFurnace(); } catch (Exception e) { System.out.println("Failed to start "+ Util.WINDUP_BRAND_NAME_ACRONYM+"!"); if (e.getMessage() != null) System.out.println("Failure reason: " + e.getMessage()); e.printStackTrace(); } if (!executePhase(CommandPhase.PRE_EXECUTION, commands) || commands.isEmpty()) return; furnace.addContainerLifecycleListener(new GreetingListener()); // Now see if there are any server SPIs that need to run Imported<WindupServerProvider> serverProviders = furnace.getAddonRegistry().getServices(WindupServerProvider.class); for (WindupServerProvider serverProvider : serverProviders) { String expectedArgName = serverProvider.getName(); boolean matches = args.stream().anyMatch(arg -> arg.equals(expectedArgName) || arg.equals("--" + expectedArgName) ); if (matches) { serverProvider.runServer(args.toArray(new String[args.size()])); return; } } if (!executePhase(CommandPhase.EXECUTION, commands) || commands.isEmpty()) return; if (!executePhase(CommandPhase.POST_EXECUTION, commands) || commands.isEmpty()) return; } catch (Throwable t) { System.err.println(Util.WINDUP_BRAND_NAME_ACRONYM +" execution failed due to: " + t.getMessage()); t.printStackTrace(); } }