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);
}
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);
}
}
}
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;
}
Aggregations