Search in sources :

Example 51 with DeploymentDescriptor

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;
}
Also used : NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor)

Example 52 with DeploymentDescriptor

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());
    }
}
Also used : JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) BAMTaskEventListener(org.jbpm.services.task.lifecycle.listeners.BAMTaskEventListener) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) EntityManagerFactory(javax.persistence.EntityManagerFactory) DeploymentDescriptorManager(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager) AmbiguousResolutionException(javax.enterprise.inject.AmbiguousResolutionException) JPATaskLifeCycleEventListener(org.jbpm.services.task.audit.JPATaskLifeCycleEventListener) TaskLifeCycleEventListener(org.kie.api.task.TaskLifeCycleEventListener)

Example 53 with DeploymentDescriptor

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);
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorManager(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager) TransactionalCommandService(org.jbpm.shared.services.impl.TransactionalCommandService) Audit(org.jbpm.services.cdi.Audit) Produces(javax.enterprise.inject.Produces)

Example 54 with DeploymentDescriptor

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);
}
Also used : HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule)

Example 55 with DeploymentDescriptor

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;
        }
    }
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) EJBException(javax.ejb.EJBException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException) Test(org.junit.Test)

Aggregations

DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)78 Test (org.junit.Test)39 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)30 HashMap (java.util.HashMap)27 DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)26 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)23 ObjectModel (org.kie.internal.runtime.conf.ObjectModel)23 KieServices (org.kie.api.KieServices)22 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)21 ReleaseId (org.kie.api.builder.ReleaseId)21 ArrayList (java.util.ArrayList)18 File (java.io.File)13 KieMavenRepository (org.kie.scanner.KieMavenRepository)12 FileOutputStream (java.io.FileOutputStream)11 KieMavenRepository.getKieMavenRepository (org.kie.scanner.KieMavenRepository.getKieMavenRepository)11 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)10 ByteArrayInputStream (java.io.ByteArrayInputStream)9 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)9 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)8 DeploymentDescriptorManager (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorManager)6