use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class DefaultRegisterableItemsFactory method getGlobalsFromDescriptor.
protected Map<String, Object> getGlobalsFromDescriptor(RuntimeEngine runtime) {
Map<String, Object> globals = new HashMap<String, Object>();
DeploymentDescriptor descriptor = getRuntimeManager().getDeploymentDescriptor();
if (descriptor != null) {
Map<String, Object> params = getParametersMap(runtime);
for (NamedObjectModel model : descriptor.getGlobals()) {
Object gInstance = getInstanceFromModel(model, getRuntimeManager().getEnvironment().getClassLoader(), params);
if (gInstance != null) {
globals.put(model.getName(), gInstance);
}
}
}
return globals;
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class HumanTaskServiceProducer method configureHumanTaskConfigurator.
protected void configureHumanTaskConfigurator(HumanTaskConfigurator configurator) {
configurator.environment(getEnvironment(identityProvider)).entityManagerFactory(emf).userGroupCallback(safeGet(userGroupCallback)).userInfo(safeGet(userInfo));
DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
// in case there is descriptor with enabled audit register then by default
if (!descriptor.getAuditMode().equals(AuditMode.NONE)) {
JPATaskLifeCycleEventListener listener = new JPATaskLifeCycleEventListener(false);
BAMTaskEventListener bamListener = new BAMTaskEventListener(false);
// if the audit persistence unit is different than default for the engine perform proper init
if (!"org.jbpm.domain".equals(descriptor.getAuditPersistenceUnit())) {
EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(descriptor.getAuditPersistenceUnit());
listener = new JPATaskLifeCycleEventListener(emf);
bamListener = new BAMTaskEventListener(emf);
}
configurator.listener(listener);
configurator.listener(bamListener);
}
// next proceed with registration of further listeners as cdi injections
try {
for (TaskLifeCycleEventListener listener : taskListeners) {
configurator.listener(listener);
logger.debug("Registering listener {}", listener);
}
} catch (Exception e) {
logger.debug("Cannot add listeners to task service due to {}", e.getMessage());
}
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class TransactionalCommandServiceProducer method produceAuditCommandService.
@Produces
@Audit
public TransactionalCommandService produceAuditCommandService() {
DeploymentDescriptorManager manager = new DeploymentDescriptorManager("org.jbpm.domain");
DeploymentDescriptor descriptor = manager.getDefaultDescriptor();
if (!"org.jbpm.domain".equals(descriptor.getAuditPersistenceUnit())) {
return new TransactionalCommandService(EntityManagerFactoryManager.get().getOrCreate(descriptor.getAuditPersistenceUnit()));
}
return new TransactionalCommandService(emf);
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class RuntimeDataServiceImplSecurityTest method deployKjar.
protected static void deployKjar() {
KieServices ks = KieServices.Factory.get();
ReleaseId releaseId = ks.newReleaseId(GROUP_ID, ARTIFACT_ID, VERSION);
List<String> processes = new ArrayList<String>();
processes.add("processes/EmptyHumanTask.bpmn");
processes.add("processes/humanTask.bpmn");
processes.add("processes/SimpleHTProcess.bpmn2");
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().addRequiredRole("view:managers");
Map<String, String> resources = new HashMap<String, String>();
resources.put("src/main/resources/" + DeploymentDescriptor.META_INF_LOCATION, customDescriptor.toXml());
InternalKieModule kJar1 = createKieJar(ks, releaseId, processes, resources);
File pom = new File("target/kmodule", "pom.xml");
pom.getParentFile().mkdir();
try {
FileOutputStream fs = new FileOutputStream(pom);
fs.write(getPom(releaseId).getBytes());
fs.close();
} catch (Exception e) {
}
KieMavenRepository repository = getKieMavenRepository();
repository.installArtifact(releaseId, kJar1, pom);
}
use of org.kie.internal.runtime.conf.DeploymentDescriptor in project jbpm by kiegroup.
the class MultipleDeploymentsProcessServiceEJBIntegrationTest method testStartProcessFromDifferentDeployments.
@Test
public void testStartProcessFromDifferentDeployments() {
assertNotNull(deploymentService);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentUnit.setDeploymentDescriptor(customDescriptor);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeploymentDescriptor customDescriptor2 = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE);
KModuleDeploymentUnit deploymentUnit2 = new KModuleDeploymentUnit(GROUP_ID2, ARTIFACT_ID2, VERSION2);
deploymentUnit2.setDeploymentDescriptor(customDescriptor2);
deploymentService.deploy(deploymentUnit2);
units.add(deploymentUnit2);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
isDeployed = deploymentService.isDeployed(deploymentUnit2.getIdentifier());
assertTrue(isDeployed);
assertNotNull(processService);
// first process from deployment 1
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "Import");
assertNotNull(processInstanceId);
try {
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNull(pi);
} catch (EJBException e) {
if (e.getCause() instanceof SessionNotFoundException) {
// ignore as this is expected when per process instance is used
} else {
throw e;
}
}
// second process from deployment 2
long processInstanceId2 = processService.startProcess(deploymentUnit2.getIdentifier(), "customtask");
assertNotNull(processInstanceId2);
try {
ProcessInstance pi2 = processService.getProcessInstance(processInstanceId2);
assertNull(pi2);
} catch (EJBException e) {
if (e.getCause() instanceof SessionNotFoundException) {
// ignore as this is expected when per process instance is used
} else {
throw e;
}
}
}
Aggregations