Search in sources :

Example 1 with ProviderType

use of org.guvnor.ala.runtime.providers.ProviderType in project kie-wb-common by kiegroup.

the class ProvisioningPipelinesProducer method getWildflyPipeline.

/**
 * Produces a pipeline for provisioning building an provisioning war applications into an Wildlfy server.
 */
@Produces
public SystemPipelineDescriptor getWildflyPipeline() {
    return new SystemPipelineDescriptor() {

        @Override
        public Optional<ProviderType> getProviderType() {
            return Optional.of(WildflyProviderType.instance());
        }

        @Override
        public Pipeline getPipeline() {
            // Create Wildfly Pipeline Configuration
            final GitConfig gitConfig = new GitConfig() {
            };
            final MavenProjectConfig projectConfig = new MavenProjectConfig() {
            };
            final MavenBuildConfig mavenBuildConfig = new MavenBuildConfig() {

                @Override
                public List<String> getGoals() {
                    final List<String> result = new ArrayList<>();
                    result.add("clean");
                    result.add("package");
                    return result;
                }

                @Override
                public Properties getProperties() {
                    final Properties result = new Properties();
                    result.setProperty("failIfNoTests", "false");
                    return result;
                }
            };
            final MavenBuildExecConfig mavenBuildExecConfig = new MavenBuildExecConfig() {
            };
            final WildflyProviderConfig wildflyProviderConfig = new WildflyProviderConfig() {
            };
            final ContextAwareWildflyRuntimeExecConfig wildflyRuntimeExecConfig = new ContextAwareWildflyRuntimeExecConfig() {
            };
            final Pipeline pipeline = PipelineFactory.newBuilder().addConfigStage("Git Source", gitConfig).addConfigStage("Maven Project", projectConfig).addConfigStage("Maven Build Config", mavenBuildConfig).addConfigStage("Maven Build", mavenBuildExecConfig).addConfigStage("Wildfly Provider Config", wildflyProviderConfig).addConfigStage("Wildfly Runtime Exec", wildflyRuntimeExecConfig).buildAs("source-to-wildlfy-provisioning");
            return pipeline;
        }
    };
}
Also used : WildflyProviderConfig(org.guvnor.ala.wildfly.config.WildflyProviderConfig) ArrayList(java.util.ArrayList) MavenBuildConfig(org.guvnor.ala.build.maven.config.MavenBuildConfig) Properties(java.util.Properties) Pipeline(org.guvnor.ala.pipeline.Pipeline) MavenBuildExecConfig(org.guvnor.ala.build.maven.config.MavenBuildExecConfig) SystemPipelineDescriptor(org.guvnor.ala.pipeline.SystemPipelineDescriptor) MavenProjectConfig(org.guvnor.ala.build.maven.config.MavenProjectConfig) ContextAwareWildflyRuntimeExecConfig(org.guvnor.ala.wildfly.config.impl.ContextAwareWildflyRuntimeExecConfig) GitConfig(org.guvnor.ala.source.git.config.GitConfig) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) WildflyProviderType(org.guvnor.ala.wildfly.model.WildflyProviderType) Produces(javax.enterprise.inject.Produces)

Example 2 with ProviderType

use of org.guvnor.ala.runtime.providers.ProviderType in project kie-wb-common by kiegroup.

the class RuntimeProvisioningServiceBackendImplTest method testGetProviderTypes.

@Test
public void testGetProviderTypes() {
    List<ProviderType> values = mockList(ProviderType.class, ELEMENTS_COUNT);
    ProviderTypeList list = new ProviderTypeList(values);
    when(runtimeProvisioningService.getProviderTypes(PAGE, PAGE_SIZE, SORT, SORT_ORDER)).thenReturn(list);
    List<ProviderType> result = runtimeProvisioningServiceBackend.getProviderTypes(PAGE, PAGE_SIZE, SORT, SORT_ORDER);
    verify(runtimeProvisioningService, times(1)).getProviderTypes(PAGE, PAGE_SIZE, SORT, SORT_ORDER);
    assertEquals(values, result);
}
Also used : ProviderType(org.guvnor.ala.runtime.providers.ProviderType) ProviderTypeList(org.guvnor.ala.services.api.itemlist.ProviderTypeList) Test(org.junit.Test)

Example 3 with ProviderType

use of org.guvnor.ala.runtime.providers.ProviderType in project kie-wb-common by kiegroup.

the class RestPipelineServiceImpl method runPipeline.

@Override
public String runPipeline(final String pipelineId, final Input input, final boolean async) throws BusinessException {
    final Pipeline pipeline = pipelineRegistry.getPipelineByName(pipelineId);
    if (pipeline == null) {
        throw new BusinessException("Pipeline: " + pipelineId + " was not found.");
    }
    String providerName = input.get(ProviderConfig.PROVIDER_NAME);
    Provider provider = null;
    ProviderType providerType = null;
    PipelineExecutorTaskDef taskDef;
    if (providerName != null && !providerName.isEmpty()) {
        provider = runtimeRegistry.getProvider(providerName);
    }
    if (provider == null) {
        providerType = pipelineRegistry.getProviderType(pipelineId);
    }
    if (provider != null) {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input, provider);
    } else if (providerType != null) {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input, providerType);
    } else {
        taskDef = new PipelineExecutorTaskDefImpl(pipeline, input);
    }
    return executorTaskManager.execute(taskDef, async ? PipelineExecutorTaskManager.ExecutionMode.ASYNCHRONOUS : PipelineExecutorTaskManager.ExecutionMode.SYNCHRONOUS);
}
Also used : PipelineExecutorTaskDefImpl(org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskDefImpl) BusinessException(org.guvnor.ala.services.exceptions.BusinessException) ProviderType(org.guvnor.ala.runtime.providers.ProviderType) ConfigBasedPipeline(org.guvnor.ala.pipeline.ConfigBasedPipeline) Pipeline(org.guvnor.ala.pipeline.Pipeline) Provider(org.guvnor.ala.runtime.providers.Provider) PipelineExecutorTaskDef(org.guvnor.ala.pipeline.execution.PipelineExecutorTaskDef)

Example 4 with ProviderType

use of org.guvnor.ala.runtime.providers.ProviderType in project kie-wb-common by kiegroup.

the class InMemoryPipelineRegistryTest method testGetProviderType.

@Test
public void testGetProviderType() {
    ProviderType result = pipelineRegistry.getProviderType(PIPELINE_ID);
    assertNull(result);
    pipelineRegistry.registerPipeline(pipeline, providerType);
    result = pipelineRegistry.getProviderType(PIPELINE_ID);
    assertEquals(providerType, result);
}
Also used : ProviderType(org.guvnor.ala.runtime.providers.ProviderType) Test(org.junit.Test)

Example 5 with ProviderType

use of org.guvnor.ala.runtime.providers.ProviderType in project kie-wb-common by kiegroup.

the class RestRuntimeProvisioningServiceImpl method cacheBeans.

@PostConstruct
public void cacheBeans() {
    LOG.info("> Initializing ProviderTypes. ");
    final Set<Bean<?>> beans = beanManager.getBeans(ProviderType.class, new AnnotationLiteral<Any>() {
    });
    for (final Bean b : beans) {
        try {
            // I don't want to register the CDI proxy, I need a fresh instance :(
            ProviderType pt = (ProviderType) b.getBeanClass().newInstance();
            LOG.info("> Registering ProviderType: " + pt.getProviderTypeName());
            runtimeRegistry.registerProviderType(pt);
        } catch (InstantiationException | IllegalAccessException ex) {
            LOG.error("Something went wrong with registering Provider Types!", ex);
        }
    }
}
Also used : ProviderType(org.guvnor.ala.runtime.providers.ProviderType) Any(javax.enterprise.inject.Any) Bean(javax.enterprise.inject.spi.Bean) PostConstruct(javax.annotation.PostConstruct)

Aggregations

ProviderType (org.guvnor.ala.runtime.providers.ProviderType)8 Test (org.junit.Test)5 Pipeline (org.guvnor.ala.pipeline.Pipeline)3 ArrayList (java.util.ArrayList)2 Provider (org.guvnor.ala.runtime.providers.Provider)2 Properties (java.util.Properties)1 PostConstruct (javax.annotation.PostConstruct)1 Any (javax.enterprise.inject.Any)1 Produces (javax.enterprise.inject.Produces)1 Bean (javax.enterprise.inject.spi.Bean)1 MavenBuildConfig (org.guvnor.ala.build.maven.config.MavenBuildConfig)1 MavenBuildExecConfig (org.guvnor.ala.build.maven.config.MavenBuildExecConfig)1 MavenProjectConfig (org.guvnor.ala.build.maven.config.MavenProjectConfig)1 ConfigBasedPipeline (org.guvnor.ala.pipeline.ConfigBasedPipeline)1 SystemPipelineDescriptor (org.guvnor.ala.pipeline.SystemPipelineDescriptor)1 PipelineExecutorTaskDef (org.guvnor.ala.pipeline.execution.PipelineExecutorTaskDef)1 PipelineExecutorTaskDefImpl (org.guvnor.ala.pipeline.execution.impl.PipelineExecutorTaskDefImpl)1 ProviderTypeList (org.guvnor.ala.services.api.itemlist.ProviderTypeList)1 BusinessException (org.guvnor.ala.services.exceptions.BusinessException)1 GitConfig (org.guvnor.ala.source.git.config.GitConfig)1