use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class CaseRestApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
CaseManagementServiceBase caseManagementServiceBase = null;
CaseManagementRuntimeDataServiceBase caseManagementRuntimeDataServiceBase = null;
CaseAdminServiceBase caseAdminServiceBase = null;
KieServerRegistry context = null;
for (Object object : services) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (CaseManagementServiceBase.class.isAssignableFrom(object.getClass())) {
caseManagementServiceBase = (CaseManagementServiceBase) object;
continue;
} else if (CaseManagementRuntimeDataServiceBase.class.isAssignableFrom(object.getClass())) {
caseManagementRuntimeDataServiceBase = (CaseManagementRuntimeDataServiceBase) object;
continue;
} else if (CaseAdminServiceBase.class.isAssignableFrom(object.getClass())) {
caseAdminServiceBase = (CaseAdminServiceBase) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>();
components.add(new CaseResource(caseManagementServiceBase, caseManagementRuntimeDataServiceBase, context));
components.add(new CaseQueryResource(caseManagementRuntimeDataServiceBase, context));
components.add(new CaseAdminResource(caseManagementRuntimeDataServiceBase, caseAdminServiceBase, context));
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class JbpmUIRestApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
FormServiceBase formServiceBase = null;
ImageServiceBase imageServiceBase = null;
FormRendererBase formRendererBase = null;
KieServerRegistry context = null;
for (Object object : services) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (FormServiceBase.class.isAssignableFrom(object.getClass())) {
formServiceBase = (FormServiceBase) object;
continue;
} else if (ImageServiceBase.class.isAssignableFrom(object.getClass())) {
imageServiceBase = (ImageServiceBase) object;
continue;
} else if (FormRendererBase.class.isAssignableFrom(object.getClass())) {
formRendererBase = (FormRendererBase) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(2);
components.add(new FormResource(formServiceBase, formRendererBase, context));
components.add(new ImageResource(imageServiceBase, context));
components.add(new StaticFilesResource(formRendererBase));
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class DMNRestApplicationComponentsService method getAppComponents.
@Override
public Collection<Object> getAppComponents(String extension, SupportedTransports type, Object... services) {
// skip calls from other than owning extension
if (!OWNER_EXTENSION.equals(extension)) {
return Collections.emptyList();
}
ModelEvaluatorServiceBase modelEvaluatorService = null;
KieServerRegistry context = null;
for (Object object : services) {
// in case given service is null (meaning was not configured) continue with next one
if (object == null) {
continue;
}
if (ModelEvaluatorServiceBase.class.isAssignableFrom(object.getClass())) {
modelEvaluatorService = (ModelEvaluatorServiceBase) object;
continue;
} else if (KieServerRegistry.class.isAssignableFrom(object.getClass())) {
context = (KieServerRegistry) object;
continue;
}
}
List<Object> components = new ArrayList<Object>(1);
components.add(new ModelEvaluatorResource(modelEvaluatorService));
return components;
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class KieControllerCrashIntegrationTest method testCrashAfterRegistered.
@Test
public void testCrashAfterRegistered() throws Exception {
final String SERVER_TEMPLATE_ID = "template-id";
final String SERVER_NAME = "server-name";
KieServerEnvironment.setServerId(SERVER_TEMPLATE_ID);
ServerTemplate serverTemplate = new ServerTemplate(SERVER_TEMPLATE_ID, SERVER_NAME);
controllerClient.saveServerTemplate(serverTemplate);
ServerTemplateList instanceList = controllerClient.listServerTemplates();
assertEquals(1, instanceList.getServerTemplates().length);
// Register kie server in controller.
KieServerInfo kieServerInfo = new KieServerInfo(SERVER_TEMPLATE_ID, "1.0.0");
kieServerInfo.setLocation("http://127.0.0.1:20000");
kieServerInfo.setMode(KieServerMode.PRODUCTION);
kieServerInfo.setName(SERVER_NAME);
KieServerRegistry registry = new KieServerRegistryImpl();
KieServerStateRepository dummyKieServerStateRepository = new KieServerStateRepository() {
@Override
public void store(String serverId, KieServerState kieServerState) {
}
@Override
public KieServerState load(String serverId) {
KieServerState kieServerState = new KieServerState();
kieServerState.setControllers(Collections.singleton(TestConfig.getControllerHttpUrl()));
kieServerState.setConfiguration(new KieServerConfig());
if (TestConfig.isLocalServer()) {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, "", null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, "", null));
} else {
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_USER, TestConfig.getUsername(), null));
kieServerState.getConfiguration().addConfigItem(new KieServerConfigItem(KieServerConstants.CFG_KIE_CONTROLLER_PASSWORD, TestConfig.getPassword(), null));
}
return kieServerState;
}
};
registry.registerStateRepository(dummyKieServerStateRepository);
KieServerController controller = new DefaultRestControllerImpl(registry);
controller.connect(kieServerInfo);
// Check that kie server is registered.
serverUp.await(5, TimeUnit.SECONDS);
ServerInstanceKeyList list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
if (list.getServerInstanceKeys().length == 0) {
// Race condition when health check deleted server instance sooner than we were able to check. Resubmitting server instance again.
serverUp = new CountDownLatch(1);
serverDown = new CountDownLatch(1);
controller.connect(kieServerInfo);
serverUp.await(5, TimeUnit.SECONDS);
list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
}
assertNotNull(list.getServerInstanceKeys());
assertEquals(1, list.getServerInstanceKeys().length);
// Check that kie server is deregistered automatically.
serverDown.await(5, TimeUnit.SECONDS);
list = controllerClient.getServerInstances(instanceList.getServerTemplates()[0].getId());
assertNotNull(list.getServerInstanceKeys());
assertEquals(0, list.getServerInstanceKeys().length);
}
use of org.kie.server.services.api.KieServerRegistry in project droolsjbpm-integration by kiegroup.
the class AbstractKieServerImplTest method testHealthCheckFailedExtension.
@Test
public void testHealthCheckFailedExtension() {
extensions.add(new KieServerExtension() {
@Override
public List<Message> healthCheck(boolean report) {
List<Message> messages = KieServerExtension.super.healthCheck(report);
messages.add(new Message(Severity.ERROR, "TEST extension is unhealthy"));
return messages;
}
@Override
public void updateContainer(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) {
}
@Override
public boolean isUpdateContainerAllowed(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) {
return false;
}
@Override
public boolean isInitialized() {
return true;
}
@Override
public boolean isActive() {
return true;
}
@Override
public void init(KieServerImpl kieServer, KieServerRegistry registry) {
}
@Override
public Integer getStartOrder() {
return 10;
}
@Override
public List<Object> getServices() {
return null;
}
@Override
public String getImplementedCapability() {
return "TEST";
}
@Override
public String getExtensionName() {
return "TEST";
}
@Override
public <T> T getAppComponents(Class<T> serviceType) {
return null;
}
@Override
public List<Object> getAppComponents(SupportedTransports type) {
return null;
}
@Override
public void disposeContainer(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) {
}
@Override
public void destroy(KieServerImpl kieServer, KieServerRegistry registry) {
}
@Override
public void createContainer(String id, KieContainerInstance kieContainerInstance, Map<String, Object> parameters) {
}
});
kieServer.init();
List<Message> healthMessages = kieServer.healthCheck(false);
assertEquals(healthMessages.size(), 1);
Message failedContainer = healthMessages.get(0);
assertEquals(Severity.ERROR, failedContainer.getSeverity());
assertEquals(1, failedContainer.getMessages().size());
assertEquals("TEST extension is unhealthy", failedContainer.getMessages().iterator().next());
}
Aggregations