Search in sources :

Example 21 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class FilteredKModuleDeploymentServiceTest method testSerializationClassesLimitedInDeploymentDependencies.

@Test
public void testSerializationClassesLimitedInDeploymentDependencies() {
    String groupId = "org.test";
    String childArtifactId = "jbpm-kie-services-filter-test-dep";
    String parentArtifactId = "jbpm-kie-services-filter-test-parent";
    String version = VERSION;
    FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(childArtifactId).setVersion(version).addClass(Building.class, House.class, Person.class, OtherPerson.class, Thing.class).createKieJarAndDeployToMaven();
    FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(parentArtifactId).setVersion(version).addDependencies(groupId + ":" + childArtifactId + ":" + version).createKieJarAndDeployToMaven();
    configureServices();
    KModuleDeploymentUnit childDeploymentUnit = new KModuleDeploymentUnit(groupId, childArtifactId, version);
    DeploymentDescriptor depDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(// parent dictates behavior
    false).get();
    childDeploymentUnit.setDeploymentDescriptor(depDesc);
    deploymentService.deploy(childDeploymentUnit);
    KModuleDeploymentUnit parentDeploymentUnit = new KModuleDeploymentUnit(groupId, parentArtifactId, version);
    DeploymentDescriptor parentDepDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(true).get();
    parentDeploymentUnit.setDeploymentDescriptor(parentDepDesc);
    deploymentService.deploy(parentDeploymentUnit);
    verifyDeployedUnitContainsCorrectClasses(parentDeploymentUnit);
}
Also used : Building(org.jbpm.kie.test.objects.Building) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) House(org.jbpm.kie.test.objects.House) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) Person(org.jbpm.kie.test.objects.Person) OtherPerson(org.jbpm.kie.test.objects.OtherPerson) Thing(org.jbpm.kie.test.objects.Thing) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 22 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class KModuleDeploymentServiceTest method testDeploymentOfProcessWithDescriptorWitSecurityManager.

@Test(expected = SecurityException.class)
public void testDeploymentOfProcessWithDescriptorWitSecurityManager() {
    assertNotNull(deploymentService);
    KieServices ks = KieServices.Factory.get();
    ReleaseId releaseId = ks.newReleaseId(GROUP_ID, "kjar-with-dd", VERSION);
    List<String> processes = new ArrayList<String>();
    processes.add("repo/processes/general/customtask.bpmn");
    processes.add("repo/processes/general/humanTask.bpmn");
    processes.add("repo/processes/general/import.bpmn");
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().runtimeStrategy(RuntimeStrategy.PER_PROCESS_INSTANCE).addWorkItemHandler(new NamedObjectModel("Log", "org.jbpm.process.instance.impl.demo.SystemOutWorkItemHandler")).addRequiredRole("experts");
    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.deployArtifact(releaseId, kJar1, pom);
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, "kjar-with-dd", VERSION, "KBase-test", "ksession-test2");
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    DeployedUnit deployedGeneral = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNotNull(deployedGeneral);
    assertNotNull(deployedGeneral.getDeploymentUnit());
    assertNotNull(deployedGeneral.getRuntimeManager());
    DeploymentDescriptor descriptor = ((InternalRuntimeManager) deployedGeneral.getRuntimeManager()).getDeploymentDescriptor();
    assertNotNull(descriptor);
    assertEquals("org.jbpm.domain", descriptor.getPersistenceUnit());
    assertEquals("org.jbpm.domain", descriptor.getAuditPersistenceUnit());
    assertEquals(AuditMode.JPA, descriptor.getAuditMode());
    assertEquals(PersistenceMode.JPA, descriptor.getPersistenceMode());
    assertEquals(RuntimeStrategy.PER_PROCESS_INSTANCE, descriptor.getRuntimeStrategy());
    assertEquals(0, descriptor.getMarshallingStrategies().size());
    assertEquals(0, descriptor.getConfiguration().size());
    assertEquals(0, descriptor.getEnvironmentEntries().size());
    assertEquals(0, descriptor.getEventListeners().size());
    assertEquals(0, descriptor.getGlobals().size());
    assertEquals(0, descriptor.getTaskEventListeners().size());
    assertEquals(1, descriptor.getWorkItemHandlers().size());
    assertEquals(1, descriptor.getRequiredRoles().size());
    RuntimeManager manager = deploymentService.getRuntimeManager(deploymentUnit.getIdentifier());
    assertNotNull(manager);
    manager.getRuntimeEngine(EmptyContext.get());
    checkFormsDeployment(deploymentUnit.getIdentifier());
}
Also used : InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) HashMap(java.util.HashMap) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) ArrayList(java.util.ArrayList) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KieServices(org.kie.api.KieServices) ReleaseId(org.kie.api.builder.ReleaseId) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) NamedObjectModel(org.kie.internal.runtime.conf.NamedObjectModel) FileOutputStream(java.io.FileOutputStream) KieMavenRepository.getKieMavenRepository(org.kie.scanner.KieMavenRepository.getKieMavenRepository) KieMavenRepository(org.kie.scanner.KieMavenRepository) File(java.io.File) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) InternalKieModule(org.drools.compiler.kie.builder.impl.InternalKieModule) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 23 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class ProcessServiceImplTest method testStartAndAbortProcessInExternalTransactions.

protected void testStartAndAbortProcessInExternalTransactions(RuntimeStrategy strategy) throws Exception {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().runtimeStrategy(strategy);
    deploymentUnit.setDeploymentDescriptor(customDescriptor);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
    ut.begin();
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    processService.signalEvent(deploymentUnit.getIdentifier(), "test", null);
    ut.commit();
    // now let's start another transaction
    ut.begin();
    processService.abortProcessInstance(processInstanceId);
    ut.commit();
    try {
        processService.getProcessInstance(processInstanceId);
    } catch (ProcessInstanceNotFoundException e) {
    // expected
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 24 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl in project jbpm by kiegroup.

the class ProcessServiceImplTest method testStartAndGetProcessInExternalTransactions.

protected void testStartAndGetProcessInExternalTransactions(RuntimeStrategy strategy) throws Exception {
    assertNotNull(deploymentService);
    KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
    DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    customDescriptor.getBuilder().runtimeStrategy(strategy);
    deploymentUnit.setDeploymentDescriptor(customDescriptor);
    deploymentService.deploy(deploymentUnit);
    units.add(deploymentUnit);
    assertNotNull(processService);
    boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
    assertTrue(isDeployed);
    UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
    ut.begin();
    long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
    assertNotNull(processInstanceId);
    ProcessInstance pi = processService.getProcessInstance(processInstanceId);
    assertNotNull(pi);
    processService.abortProcessInstance(processInstanceId);
    ut.commit();
    try {
        processService.getProcessInstance(processInstanceId);
    } catch (ProcessInstanceNotFoundException e) {
    // expected
    }
}
Also used : UserTransaction(javax.transaction.UserTransaction) 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) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 25 with DeploymentDescriptorImpl

use of org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl 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)

Aggregations

DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)27 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)26 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)19 KieServices (org.kie.api.KieServices)15 ReleaseId (org.kie.api.builder.ReleaseId)15 File (java.io.File)14 InternalKieModule (org.drools.compiler.kie.builder.impl.InternalKieModule)14 HashMap (java.util.HashMap)13 FileOutputStream (java.io.FileOutputStream)12 KieMavenRepository (org.kie.scanner.KieMavenRepository)12 KieMavenRepository.getKieMavenRepository (org.kie.scanner.KieMavenRepository.getKieMavenRepository)12 ArrayList (java.util.ArrayList)11 Test (org.junit.Test)11 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)9 Before (org.junit.Before)8 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)7 NamedObjectModel (org.kie.internal.runtime.conf.NamedObjectModel)7 ObjectModel (org.kie.internal.runtime.conf.ObjectModel)7 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)6 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)5