Java源码示例:org.jboss.forge.furnace.Furnace

示例1
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();
}
 
示例2
@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);
}
 
示例3
@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());
}
 
示例4
/**
 * Initialize tag handlers based upon the provided furnace instance.
 */
public ParserContext(Furnace furnace, RuleLoaderContext ruleLoaderContext)
{
    this.ruleLoaderContext = ruleLoaderContext;

    @SuppressWarnings("rawtypes")
    Imported<ElementHandler> loadedHandlers = furnace.getAddonRegistry().getServices(ElementHandler.class);
    for (ElementHandler<?> handler : loadedHandlers)
    {
        NamespaceElementHandler annotation = Annotations.getAnnotation(handler.getClass(),
                    NamespaceElementHandler.class);
        if (annotation != null)
        {
            HandlerId handlerID = new HandlerId(annotation.namespace(), annotation.elementName());
            if (handlers.containsKey(handlerID))
            {
                String className1 = Proxies.unwrapProxyClassName(handlers.get(handlerID).getClass());
                String className2 = Proxies.unwrapProxyClassName(handler.getClass());
                throw new WindupException("Multiple handlers registered with id: " + handlerID + " Classes are: "
                            + className1 + " and " + className2);
            }
            handlers.put(handlerID, handler);
        }
    }
}
 
示例5
@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();
   }
}
 
示例6
@Test
public void testDependenciesAreCorrectlyDeployedAndAssigned()
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   Assert.assertSame(AddonCompatibilityStrategies.LENIENT, furnace.getAddonCompatibilityStrategy());

   Addon self = LocalServices.getAddon(getClass().getClassLoader());

   Set<org.jboss.forge.furnace.addons.AddonDependency> dependencies = self.getDependencies();
   Assert.assertEquals(2, dependencies.size());

   Iterator<org.jboss.forge.furnace.addons.AddonDependency> iterator = dependencies.iterator();

   org.jboss.forge.furnace.addons.AddonDependency incompatibleAddon = iterator.next();
   Assert.assertEquals(AddonId.from(INCOMPATIBLE, INCOMPATIBLE_VERSION), incompatibleAddon.getDependency().getId());
   Assert.assertEquals(AddonStatus.STARTED, incompatibleAddon.getDependency().getStatus());

   org.jboss.forge.furnace.addons.AddonDependency compatibleAddon = iterator.next();
   Assert.assertEquals(AddonId.from(COMPATIBLE, COMPATIBLE_VERSION), compatibleAddon.getDependency().getId());
   Assert.assertEquals(AddonStatus.STARTED, compatibleAddon.getDependency().getStatus());
}
 
示例7
@Override
public ContainerMethodExecutor getExecutor(FurnaceProtocolConfiguration protocolConfiguration,
         ProtocolMetaData metaData, CommandCallback callback)
{
   if (metaData == null)
   {
      return new ContainerMethodExecutor()
      {
         @Override
         public TestResult invoke(TestMethodExecutor arg0)
         {
            return TestResult.skipped();
         }
      };
   }

   Collection<FurnaceHolder> contexts = metaData.getContexts(FurnaceHolder.class);
   if (contexts.size() == 0)
   {
      throw new IllegalArgumentException(
               "No " + Furnace.class.getName() + " found in " + ProtocolMetaData.class.getName() + ". " +
                        "Furnace protocol can not be used");
   }
   return new FurnaceTestMethodExecutor(protocolConfiguration, contexts.iterator().next());
}
 
示例8
@Test
public void testCreateNewSpringBootProjectAndRunFabric8Setup() throws Exception {
    // lets point to a local maven repo
    localMavenRepo.mkdirs();
    System.setProperty("maven.repo.local", localMavenRepo.getAbsolutePath());

    Furnaces.withFurnace(new FurnaceCallback<String>() {

        @Override
        public String invoke(Furnace furnace) throws Exception {
            createNewProject(furnace);
            return null;
        }
    });
}
 
示例9
public static <T> T withFurnace(FurnaceCallback<T> callback) throws Exception {
    Furnace furnace = startFurnace();
    try {
        return callback.invoke(furnace);
    } finally {
        furnace.stop();
    }
}
 
示例10
public AddonRunnable(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager,
         Addon addon)
{
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.furnace = furnace;
   this.addon = addon;
}
 
示例11
@Test
public void testPopulateMavenRepo() throws Exception {
    // lets point to a local maven repo
    localMavenRepo.mkdirs();
    System.setProperty("maven.repo.local", localMavenRepo.getAbsolutePath());

    Furnaces.withFurnace(new FurnaceCallback<String>() {

        @Override
        public String invoke(Furnace furnace) throws Exception {
            createProjects(furnace);
            return null;
        }
    });
}
 
示例12
protected void createProjects(Furnace furnace) throws Exception {
    File projectsOutputFolder = new File(baseDir, "target/createdProjects");
    Files.recursiveDelete(projectsOutputFolder);

    ProjectGenerator generator = new ProjectGenerator(furnace, projectsOutputFolder, localMavenRepo);
    File archetypeJar = generator.getArtifactJar("io.fabric8.archetypes", "archetypes-catalog", ProjectGenerator.FABRIC8_ARCHETYPE_VERSION);

    List<String> archetypes = getArchetypesFromJar(archetypeJar);
    assertThat(archetypes).describedAs("Archetypes to create").isNotEmpty();

    String testArchetype = System.getProperty(TEST_ARCHETYPE_SYSTEM_PROPERTY, "");
    if (Strings.isNotBlank(testArchetype)) {
        LOG.info("Due to system property: '" + TEST_ARCHETYPE_SYSTEM_PROPERTY + "' we will just run the test on archetype: " + testArchetype);
        generator.createProjectFromArchetype(testArchetype);
    } else {
        for (String archetype : archetypes) {
            // TODO fix failing archetypes...
            if (!archetype.startsWith("jboss-fuse-") && !archetype.startsWith("swarm")) {
                generator.createProjectFromArchetype(archetype);
            }
        }
    }

    removeSnapshotFabric8Artifacts();


    List<File> failedFolders = generator.getFailedFolders();
    if (failedFolders.size() > 0) {
        LOG.error("Failed to build all the projects!!!");
        for (File failedFolder : failedFolders) {
            LOG.error("Failed to build project: " + failedFolder.getName());
        }
    }
}
 
示例13
public AddonModuleLoader(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager)
{
   this.furnace = furnace;
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.moduleCache = new AddonModuleIdentifierCache();
   this.moduleJarFileCache = new AddonModuleJarFileCache();
   installModuleMBeanServer();
}
 
示例14
public GraphContextImpl(Furnace furnace, GraphTypeManager typeManager,
            GraphApiCompositeClassLoaderProvider classLoaderProvider, Path graphDir)
{
    this.furnace = furnace;
    this.graphTypeManager = typeManager;
    this.classLoaderProvider = classLoaderProvider;
    this.graphDir = graphDir;
}
 
示例15
@Test
public void testAddonRepositoryIsCorrectInMultiViewEnvironment() throws Exception
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   Assert.assertNotNull(furnace);
   AddonRegistry registry = furnace.getAddonRegistry();
   AddonRepository rep1 = registry.getAddon(AddonId.from("dep1", "1")).getRepository();
   AddonRepository rep2 = registry.getAddon(AddonId.from("dep2", "2")).getRepository();
   AddonRepository rep3 = registry.getAddon(AddonId.from("dep3", "3")).getRepository();
   AddonRepository rep4 = registry.getAddon(AddonId.from("dep4", "4")).getRepository();
   AddonRepository rep5 = registry.getAddon(AddonId.from("dep5", "5")).getRepository();
   Assert.assertEquals(rep1, rep2);
   Assert.assertEquals(rep3, rep4);
   Assert.assertEquals(rep4, rep5);
}
 
示例16
@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);
}
 
示例17
@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);
}
 
示例18
@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();
}
 
示例19
/**
 * 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();
}
 
示例20
private void waitForOldWindupUIAddon(Furnace furnace) throws InterruptedException
{
    Addon addon = furnace.getAddonRegistry().getAddon(AddonId.from(WINDUP_UI_ADDON_NAME, WINDUP_OLD_VERSION));
    Addons.waitUntilStarted(addon);
    do
    {
        // We need to wait till furnace will process all the information changed in the directories.
        Thread.sleep(500);
    }
    while (furnace.getAddonRegistry().getServices(WindupUpdateDistributionCommand.class).isUnsatisfied());
}
 
示例21
@Override
public Furnace setServerMode(boolean server)
{
   assertNotAlive();
   this.serverMode = server;
   return this;
}
 
示例22
public AddonLoader(Furnace furnace, AddonLifecycleManager lifecycleManager, AddonStateManager stateManager,
         AddonModuleLoader loader)
{
   this.lock = furnace.getLockManager();
   this.lifecycleManager = lifecycleManager;
   this.stateManager = stateManager;
   this.loader = loader;
}
 
示例23
@Test
public void testIsAmbiguous() throws Exception
{
   Furnace furnace = LocalServices.getFurnace(getClass().getClassLoader());
   AddonRegistry registry = furnace.getAddonRegistry();
   Imported<MockInterface> services = registry.getServices(MockInterface.class);
   Assert.assertFalse(services.isUnsatisfied());
   Assert.assertTrue(services.isAmbiguous());
}
 
示例24
public static UpdateRequest createUpdateRequest(AddonInfo addonToRemove, AddonInfo addonToInstall,
         MutableAddonRepository repository, Furnace furnace)
{
   RemoveRequest removeRequest = createRemoveRequest(addonToRemove, repository, furnace);
   DeployRequest installRequest = createDeployRequest(addonToInstall, repository, furnace);
   return new UpdateRequestImpl(removeRequest, installRequest);
}
 
示例25
protected FreeMarkerOperation(Furnace furnace, String templatePath, String outputFilename, String... varNames)
{
    this.furnace = furnace;
    this.templatePath = templatePath.replace('\\', '/');
    this.outputFilename = outputFilename;
    this.variableNames = Arrays.asList(varNames);
}
 
示例26
private void waitUntilStable(Furnace furnace) throws InterruptedException
{
   while (furnace.getStatus().isStarting())
   {
      Thread.sleep(10);
   }
}
 
示例27
@Test
public void shouldBeAbleToPassPrimitivesIntoDelegate() throws Exception
{
   Furnace instance = FurnaceFactory.getInstance();
   Assert.assertNotNull(instance);
   instance.setServerMode(false);
}
 
示例28
private void waitUntilStarted(Furnace furnace) throws InterruptedException
{
   while (!furnace.getStatus().isStarted())
   {
      Thread.sleep(150);
   }
}
 
示例29
@Override
public void preDeploy(Furnace furnace, Archive<?> archive) throws Exception
{
   previousUserSettings = System.setProperty(MavenContainer.ALT_USER_SETTINGS_XML_LOCATION,
            getAbsolutePath("profiles/settings.xml"));
   previousLocalRepository = System.setProperty(MavenContainer.ALT_LOCAL_REPOSITORY_LOCATION,
            "target/the-other-repository");
}
 
示例30
@Override
public void afterStop(Furnace forge) throws ContainerException
{
   afterStopTimesCalled++;
}