org.jboss.forge.addon.ui.context.UIExecutionContext Java Examples
The following examples show how to use
org.jboss.forge.addon.ui.context.UIExecutionContext.
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: AddFractionCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); ThorntailFacet facet = project.getFacet(ThorntailFacet.class); if (fractionElements.hasValue()) { List<FractionDescriptor> fractions = Lists.toList(fractionElements.getValue()); facet.installFractions(fractions); List<String> artifactIds = fractions.stream().map(FractionDescriptor::getArtifactId) .collect(Collectors.toList()); return Results.success("Thorntail Fractions '" + artifactIds + "' were successfully added to the project descriptor"); } return Results.success(); }
Example #2
Source File: ConfigureEipPropertiesStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); // only execute if we are last if (last) { String kind = mandatoryAttributeValue(attributeMap, "kind"); if ("xml".equals(kind)) { return executeXml(context, attributeMap); } else { throw new UnsupportedOperationException("Java not yet supported"); } } else { return null; } }
Example #3
Source File: EndpointListCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(decode.getValue()); boolean val2 = "true".equals(verbose.getValue()); boolean val3 = "true".equals(explain.getValue()); org.apache.camel.commands.EndpointListCommand command = new org.apache.camel.commands.EndpointListCommand(name.getValue(), val, val2, val3); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #4
Source File: ConnectedCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext uiExecutionContext) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } String username = configuration.getString("CamelJolokiaUsername"); JolokiaCamelController controller = getController(); // ping to see if the connection works boolean ok = controller.ping(); if (ok) { return Results.success("Connected to " + url + (username != null ? " using " + username : "")); } else { return Results.fail("Error connecting to " + url); } }
Example #5
Source File: WindupUpdateDistributionCommand.java From windup with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { if (!context.getPrompt().promptBoolean( "Are you sure you want to continue? This command will delete current directories: addons, bin, lib, rules/migration-core")) { return Results.fail("Updating distribution was aborted."); } // Find the latest version. Coordinate latestDist = this.updater.getLatestReleaseOf("org.jboss.windup", "windup-distribution"); Version latestVersion = SingleVersion.valueOf(latestDist.getVersion()); Version installedVersion = currentAddon.getId().getVersion(); if (latestVersion.compareTo(installedVersion) <= 0) { return Results.fail(Util.WINDUP_BRAND_NAME_ACRONYM+" CLI is already in the most updated version."); } distUpdater.replaceWindupDirectoryWithDistribution(latestDist); return Results.success("Sucessfully updated "+Util.WINDUP_BRAND_NAME_ACRONYM+" CLI to version " + latestDist.getVersion() + ". Please restart MTA CLI."); }
Example #6
Source File: ConfigureEndpointPropertiesStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); // only execute if we are last if (last) { String kind = mandatoryAttributeValue(attributeMap, "kind"); if ("xml".equals(kind)) { return executeXml(context, attributeMap); } else if ("java".equals(kind)) { return executeJava(context, attributeMap); } else { return executeOther(context, attributeMap); } } else { return null; } }
Example #7
Source File: EndpointStatsCommand.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(decode.getValue()); String[] val2 = null; if (filter.getValue() != null) { String s = filter.getValue().toString(); val2 = s.split(","); } org.apache.camel.commands.EndpointStatisticCommand command = new org.apache.camel.commands.EndpointStatisticCommand(name.getValue(), val, val2); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #8
Source File: CreateTestClassCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); final DependencyFacet dependencyFacet = project.getFacet(DependencyFacet.class); if (!isArquillianWildflySwarmDependencyInstalled(dependencyFacet)) { installArquillianWildflySwarmDependency(dependencyFacet); } JavaClassSource test = Roaster.create(JavaClassSource.class) .setPackage(targetPackage.getValue()) .setName(named.getValue()); addArquillianRunner(test); addDefaultDeploymentAnnotation(test, project); addArquillianResourceEnricher(test); addTestMethod(test); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); facet.saveTestJavaSource(test); return Results.success(String.format("Test Class %s.%s was created", targetPackage.getValue(), named.getValue())); }
Example #9
Source File: Fabric8SetupStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { StopWatch watch = new StopWatch(); log.debug("Starting to setup fabric8 project"); Project project = getSelectedProject(context.getUIContext()); if (project == null) { return Results.fail("No pom.xml available so cannot edit the project!"); } // setup fabric8-maven-plugin setupFabricMavenPlugin(project); log.debug("fabric8-maven-plugin now setup"); // make sure we have resources as we need it later facetFactory.install(project, ResourcesFacet.class); log.info("execute took " + watch.taken()); return Results.success(); }
Example #10
Source File: RunCommand.java From thorntail-addon with Eclipse Public License 1.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context); UIOutput output = context.getUIContext().getProvider().getOutput(); PackagingFacet packagingFacet = project.getFacet(PackagingFacet.class); try { packagingFacet.createBuilder().addArguments("thorntail:run").runTests(false).build(output.out(), output.err()); } catch (BuildException ie) { if (!(ie.getCause() instanceof InterruptedException)) { return Results.fail("Error while running the build", ie.getCause()); } } return Results.success(); }
Example #11
Source File: ConfigureComponentPropertiesStep.java From fabric8-forge with Apache License 2.0 | 6 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { // only execute if we are last if (last) { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); String kind = mandatoryAttributeValue(attributeMap, "kind"); if ("springboot".equals(kind)) { return doExecuteSpringBoot(context); } else { return doExecuteJava(context); } } else { return null; } }
Example #12
Source File: ContextStartCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextStartCommand command = new org.apache.camel.commands.ContextStartCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Started " + name.getValue()); }
Example #13
Source File: ContextSuspendCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextSuspendCommand command = new org.apache.camel.commands.ContextSuspendCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Suspended " + name.getValue()); }
Example #14
Source File: ComponentListCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } boolean val = "true".equals(verbose.getValue()); org.apache.camel.commands.ComponentListCommand command = new org.apache.camel.commands.ComponentListCommand(name.getValue(), val); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #15
Source File: ContextInflightCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } Boolean value = sortByLongestDuration.getValue(); boolean flag = value != null && value.booleanValue(); org.apache.camel.commands.ContextInflightCommand command = new org.apache.camel.commands.ContextInflightCommand(name.getValue(), route.getValue(), limit.getValue(), flag); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #16
Source File: RouteProfileCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteProfileCommand command = new org.apache.camel.commands.RouteProfileCommand(route.getValue(), name.getValue()); command.setStringEscape(new NoopStringEscape()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #17
Source File: CamelGetOverviewCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { Project project = getSelectedProject(context); // does the project already have camel? Dependency core = findCamelCoreDependency(project); if (core == null) { return Results.fail("The project does not include camel-core"); } ProjectDto camelProject = new ProjectDto(); ResourcesFacet resourcesFacet = project.getFacet(ResourcesFacet.class); WebResourcesFacet webResourcesFacet = null; if (project.hasFacet(WebResourcesFacet.class)) { webResourcesFacet = project.getFacet(WebResourcesFacet.class); } // use value choices instead of completer as that works better in web console XmlEndpointsCompleter xmlEndpointCompleter = new XmlEndpointsCompleter(resourcesFacet, webResourcesFacet, null); JavaSourceFacet javaSourceFacet = project.getFacet(JavaSourceFacet.class); // use value choices instead of completer as that works better in web console RouteBuilderEndpointsCompleter javaEndpointsCompleter = new RouteBuilderEndpointsCompleter(javaSourceFacet, null); camelProject.addEndpoints(javaEndpointsCompleter.getEndpoints()); camelProject.addEndpoints(xmlEndpointCompleter.getEndpoints()); CamelCurrentComponentsFinder componentsFinder = new CamelCurrentComponentsFinder(getCamelCatalog(), project); List<ComponentDto> currentComponents = componentsFinder.findCurrentComponents(); camelProject.setComponents(currentComponents); String result = formatResult(camelProject); return Results.success(result); }
Example #18
Source File: RouteSuspendCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteSuspendCommand command = new org.apache.camel.commands.RouteSuspendCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Suspended " + route.getValue()); }
Example #19
Source File: AbstractDevOpsCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
protected void updateConfiguration(UIExecutionContext context, ProjectConfig config) { Map<Object, Object> attributeMap = context.getUIContext().getAttributeMap(); ProjectConfigs.configureProperties(config, attributeMap); Object pipelineValue = attributeMap.get("selectedPipeline"); if (pipelineValue instanceof PipelineDTO) { PipelineDTO pipeline = (PipelineDTO) pipelineValue; if (pipeline != null) { config.setPipeline(pipeline.getValue()); } } }
Example #20
Source File: SetupCommandTest.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Test public void testThorntailSetup() throws Exception { try (CommandController controller = uiTestHarness.createCommandController(SetupCommand.class, project.getRoot())) { controller.initialize(); Assert.assertTrue(controller.isValid()); final AtomicBoolean flag = new AtomicBoolean(); controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener() { @Override public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result) { if (result.getMessage().equals("Thorntail is now set up! Enjoy!")) { flag.set(true); } } }); controller.execute(); Assert.assertTrue(flag.get()); ThorntailFacet facet = project.getFacet(ThorntailFacet.class); Assert.assertTrue(facet.isInstalled()); MavenPluginAdapter thorntailPlugin = (MavenPluginAdapter) project.getFacet(MavenPluginFacet.class) .getEffectivePlugin(ThorntailFacet.PLUGIN_COORDINATE); Assert.assertEquals("thorntail-maven-plugin", thorntailPlugin.getCoordinate().getArtifactId()); Assert.assertEquals(1, thorntailPlugin.getExecutions().size()); Assert.assertEquals(0, thorntailPlugin.getConfig().listConfigurationElements().size()); } }
Example #21
Source File: FunktionArchetypeSelectionWizardStep.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { UIContext uiContext = context.getUIContext(); Project project = (Project) uiContext.getAttributeMap().get(Project.class); Archetype chosenArchetype = archetype.getValue(); String coordinate = chosenArchetype.getGroupId() + ":" + chosenArchetype.getArtifactId() + ":" + chosenArchetype.getVersion(); DependencyQueryBuilder depQuery = DependencyQueryBuilder.create(coordinate); String repository = chosenArchetype.getRepository(); if (!Strings.isNullOrEmpty(repository)) { if (repository.endsWith(".xml")) { int lastRepositoryPath = repository.lastIndexOf('/'); if (lastRepositoryPath > -1) repository = repository.substring(0, lastRepositoryPath); } if (!repository.isEmpty()) { depQuery.setRepositories(new DependencyRepository("archetype", repository)); } } Dependency resolvedArtifact = dependencyResolver.resolveArtifact(depQuery); FileResource<?> artifact = resolvedArtifact.getArtifact(); MetadataFacet metadataFacet = project.getFacet(MetadataFacet.class); File fileRoot = project.getRoot().reify(DirectoryResource.class).getUnderlyingResourceObject(); ArchetypeHelper archetypeHelper = new ArchetypeHelper(artifact.getResourceInputStream(), fileRoot, metadataFacet.getProjectGroupName(), metadataFacet.getProjectName(), metadataFacet.getProjectVersion()); JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); archetypeHelper.setPackageName(facet.getBasePackage()); archetypeHelper.execute(); return Results.success(); }
Example #22
Source File: RouteInfoCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteInfoCommand command = new org.apache.camel.commands.RouteInfoCommand(route.getValue(), name.getValue()); command.setStringEscape(new NoopStringEscape()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #23
Source File: WindupUpdateRulesetCommand.java From windup with Eclipse Public License 1.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { return Results.fail("Update was disabled!"); /* temporary disabled update of rules due possible breakage on compatibility and proper * function String updatedTo = updater.replaceRulesetsDirectoryWithLatestReleaseIfAny(); if (updatedTo == null) return Results.fail("The ruleset is already in the most updated version."); else return Results.success("Sucessfully updated the rulesets to version " + updatedTo + " ."); */ }
Example #24
Source File: SetupFractionsStep.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) { Project project = getSelectedProject(context); ThorntailFacet thorntail = project.getFacet(ThorntailFacet.class); List<FractionDescriptor> installedFractions = thorntail.getInstalledFractions(); if (enableJAXRS(installedFractions)) { JavaSourceFacet facet = project.getFacet(JavaSourceFacet.class); JavaClassSource restEndpoint = Roaster.create(JavaClassSource.class) .setPackage(facet.getBasePackage() + ".rest") .setName("HelloWorldEndpoint"); if (hasCDI(installedFractions)) { restEndpoint.addAnnotation(ApplicationScoped.class); } restEndpoint.addAnnotation(Path.class).setStringValue("/hello"); MethodSource<JavaClassSource> method = restEndpoint.addMethod().setPublic().setReturnType(Response.class) .setName("doGet") .setBody("return Response.ok(\"Hello from Thorntail!\").build();"); method.addAnnotation(GET.class); method.addAnnotation(javax.ws.rs.Produces.class).setStringArrayValue(new String[] { MediaType.TEXT_PLAIN }); facet.saveJavaSource(restEndpoint); } if (hasTopologyJgroups(installedFractions)) { ThorntailConfiguration config = thorntail.getConfiguration(); Map<String, String> props = new TreeMap<>(config.getProperties()); props.put("swarm.bind.address", "127.0.0.1"); props.put("java.net.preferIPv4Stack", "true"); props.put("jboss.node.name", "${project.artifactId}"); thorntail.setConfiguration(ThorntailConfigurationBuilder.create(config).properties(props)); } return Results.success(); }
Example #25
Source File: SetupCommandTest.java From thorntail-addon with Eclipse Public License 1.0 | 5 votes |
@Test public void testThorntailSetupWithNullParameters() throws Exception { try (CommandController controller = uiTestHarness.createCommandController(SetupCommand.class, project.getRoot())) { controller.initialize(); controller.setValueFor("httpPort", null); controller.setValueFor("contextPath", null); controller.setValueFor("portOffset", null); Assert.assertTrue(controller.isValid()); final AtomicBoolean flag = new AtomicBoolean(); controller.getContext().addCommandExecutionListener(new AbstractCommandExecutionListener() { @Override public void postCommandExecuted(UICommand command, UIExecutionContext context, Result result) { if (result.getMessage().equals("Thorntail is now set up! Enjoy!")) { flag.set(true); } } }); controller.execute(); Assert.assertTrue(flag.get()); ThorntailFacet facet = project.getFacet(ThorntailFacet.class); Assert.assertTrue(facet.isInstalled()); MavenPluginAdapter thorntailPlugin = (MavenPluginAdapter) project.getFacet(MavenPluginFacet.class) .getEffectivePlugin(ThorntailFacet.PLUGIN_COORDINATE); Assert.assertEquals("thorntail-maven-plugin", thorntailPlugin.getCoordinate().getArtifactId()); Assert.assertEquals(1, thorntailPlugin.getExecutions().size()); Assert.assertEquals(0, thorntailPlugin.getConfig().listConfigurationElements().size()); } }
Example #26
Source File: RouteResetStatsCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteResetStatsCommand command = new org.apache.camel.commands.RouteResetStatsCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Reset route statistics on " + name.getValue()); }
Example #27
Source File: RouteStartCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RouteStartCommand command = new org.apache.camel.commands.RouteStartCommand(route.getValue(), name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Started " + route.getValue()); }
Example #28
Source File: ContextListCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextListCommand command = new org.apache.camel.commands.ContextListCommand(); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }
Example #29
Source File: ContextResumeCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.ContextResumeCommand command = new org.apache.camel.commands.ContextResumeCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success("Resumed " + name.getValue()); }
Example #30
Source File: RestApiDocCommand.java From fabric8-forge with Apache License 2.0 | 5 votes |
@Override public Result execute(UIExecutionContext context) throws Exception { String url = getJolokiaUrl(); if (url == null) { return Results.fail("Not connected to remote jolokia agent. Use camel-connect command first"); } org.apache.camel.commands.RestApiDocCommand command = new org.apache.camel.commands.RestApiDocCommand(name.getValue()); command.execute(getController(), getOutput(context), getError(context)); return Results.success(); }