Search in sources :

Example 41 with KieServerExtension

use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.

the class AbstractKieServerImplTest method testUpdateContainerWithNullReleaseID.

@Test
public void testUpdateContainerWithNullReleaseID() {
    KieServerExtension extension = mock(KieServerExtension.class);
    extensions.add(extension);
    String containerId = "container-to-update";
    startContainerToUpdate(containerId, getVersion(mode));
    ServiceResponse<ReleaseId> updateResponse = kieServer.updateContainerReleaseId(containerId, null, true);
    Assertions.assertThat(updateResponse.getType()).isEqualTo(ServiceResponse.ResponseType.FAILURE);
    verify(extension, never()).isUpdateContainerAllowed(anyString(), any(), any());
    verify(extension, never()).updateContainer(any(), any(), any());
    kieServer.disposeContainer(containerId);
}
Also used : KieServerExtension(org.kie.server.services.api.KieServerExtension) Matchers.anyString(org.mockito.Matchers.anyString) ReleaseId(org.kie.server.api.model.ReleaseId) Test(org.junit.Test)

Example 42 with KieServerExtension

use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.

the class KieServerScannerEventListener method onKieScannerUpdateResultsEvent.

@Override
public void onKieScannerUpdateResultsEvent(KieScannerUpdateResultsEvent updateResults) {
    if (!updateResults.getResults().hasMessages(Level.ERROR)) {
        List<KieServerExtension> extensions = kieServer.getServerExtensions();
        String containerId = kieContainerInstance.getContainerId();
        ReleaseId releaseId = kieContainerInstance.getKieContainer().getContainerReleaseId();
        Map<String, Object> parameters = kieServer.getContainerParameters(kieContainerInstance.getKieContainer(), kieServer.getMessagesForContainer(containerId));
        for (KieServerExtension extension : extensions) {
            boolean allowed = extension.isUpdateContainerAllowed(containerId, kieContainerInstance, parameters);
            if (!allowed) {
                logger.error("Unable to update container {} due to it is not allowed by extension {}", containerId, extension);
                return;
            }
        }
        kieContainerInstance.clearExtraClasses();
        boolean disposedMarshallers = kieContainerInstance.updateReleaseId();
        // on scanner successful update dispose marshallers
        if (!disposedMarshallers) {
            kieContainerInstance.disposeMarshallers();
        }
        // once the upgrade was successful, notify all extensions so they can be upgraded (if needed)
        for (KieServerExtension extension : extensions) {
            extension.updateContainer(containerId, kieContainerInstance, parameters);
            logger.debug("Container {} (for release id {}) on {} updated successfully", containerId, releaseId, extension);
        }
    }
}
Also used : KieServerExtension(org.kie.server.services.api.KieServerExtension) ReleaseId(org.kie.api.builder.ReleaseId)

Example 43 with KieServerExtension

use of org.kie.server.services.api.KieServerExtension in project droolsjbpm-integration by kiegroup.

the class KieServerAutoConfiguration method kieServer.

@Bean(destroyMethod = "destroy")
@ConditionalOnMissingBean(name = "kieServer")
public KieServer kieServer(List<KieServerExtension> extensions, List<KieContainerResource> containers) {
    System.setProperty(KieServerConstants.CFG_SB_CXF_PATH, cxfPath);
    System.setProperty(KieServerConstants.KIE_SERVER_CONTROLLER, properties.getControllers());
    System.setProperty(KieServerConstants.KIE_SERVER_LOCATION, properties.getLocation());
    if (KieServerEnvironment.getServerId() == null) {
        String serverName = properties.getServerName();
        String serverId = properties.getServerId();
        KieServerEnvironment.setServerId(serverId.toString());
        KieServerEnvironment.setServerName(serverName);
    }
    logger.info("KieServer (id {} (name {})) started initialization process", KieServerEnvironment.getServerId(), KieServerEnvironment.getServerName());
    if (properties.isClassPathContainer()) {
        kieServer = new ImmutableSpringBootKieServerImpl(extensions, identityProvider, containers);
    } else {
        kieServer = new SpringBootKieServerImpl(extensions, identityProvider);
    }
    kieServer.init();
    KieServerRestImpl kieServerResource = new KieServerRestImpl(kieServer);
    this.endpoints = new ArrayList<>();
    endpoints.add(kieServerResource);
    // next add any resources from server extensions
    List<KieServerExtension> activeExtensions = kieServer.getServerExtensions();
    for (KieServerExtension extension : activeExtensions) {
        LinkedHashSet<Object> resources = new LinkedHashSet<>(extension.getAppComponents(SupportedTransports.REST));
        endpoints.addAll(resources);
    }
    logger.info("KieServer (id {}) started successfully", KieServerEnvironment.getServerId());
    return kieServer;
}
Also used : SpringBootKieServerImpl(org.kie.server.springboot.SpringBootKieServerImpl) ImmutableSpringBootKieServerImpl(org.kie.server.springboot.ImmutableSpringBootKieServerImpl) LinkedHashSet(java.util.LinkedHashSet) KieServerExtension(org.kie.server.services.api.KieServerExtension) ImmutableSpringBootKieServerImpl(org.kie.server.springboot.ImmutableSpringBootKieServerImpl) KieServerRestImpl(org.kie.server.remote.rest.common.resource.KieServerRestImpl) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

KieServerExtension (org.kie.server.services.api.KieServerExtension)43 Message (org.kie.server.api.model.Message)10 ArrayList (java.util.ArrayList)9 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)9 ReleaseId (org.kie.server.api.model.ReleaseId)8 Test (org.junit.Test)6 KieModuleMetaData (org.kie.scanner.KieModuleMetaData)6 KieContainerResource (org.kie.server.api.model.KieContainerResource)6 ServiceResponse (org.kie.server.api.model.ServiceResponse)6 Matchers.anyString (org.mockito.Matchers.anyString)6 JbpmKieServerExtension (org.kie.server.services.jbpm.JbpmKieServerExtension)5 DeploymentService (org.jbpm.services.api.DeploymentService)4 ProcessService (org.jbpm.services.api.ProcessService)4 KieContainerInstance (org.kie.server.services.api.KieContainerInstance)4 KieServerRegistry (org.kie.server.services.api.KieServerRegistry)4 HashMap (java.util.HashMap)3 Map (java.util.Map)3 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)3 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)3 RuntimeDataService (org.jbpm.services.api.RuntimeDataService)3