Search in sources :

Example 1 with TransientNamedObjectModel

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

the class DeploymentStoreTest method testEnableAndGetActiveDeploymentsWithTransientNamedObject.

@Test
public void testEnableAndGetActiveDeploymentsWithTransientNamedObject() {
    Collection<DeploymentUnit> enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(0, enabled.size());
    KModuleDeploymentUnit unit = new KModuleDeploymentUnit("org.jbpm", "test", "1.0");
    DeploymentDescriptor descriptor = unit.getDeploymentDescriptor();
    if (descriptor == null) {
        descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
    }
    // add transient named object model that should not be persisted
    descriptor.getBuilder().addWorkItemHandler(new TransientNamedObjectModel("ejb", "async", "org.jbpm.executor.impl.wih.AsyncWorkItemHandler", new Object[] { "jndi:java:module/ExecutorServiceEJBImpl", "org.jbpm.executor.commands.PrintOutCommand" })).addEventListener(new TransientObjectModel("ejb", "not.existing.listener"));
    unit.setDeploymentDescriptor(descriptor);
    store.enableDeploymentUnit(unit);
    enabled = store.getEnabledDeploymentUnits();
    assertNotNull(enabled);
    assertEquals(1, enabled.size());
    DeploymentUnit unitEnabled = enabled.iterator().next();
    assertTrue(unitEnabled instanceof KModuleDeploymentUnit);
    DeploymentDescriptor descriptorEnabled = ((KModuleDeploymentUnit) unitEnabled).getDeploymentDescriptor();
    assertNotNull(descriptorEnabled);
    assertEquals(0, descriptorEnabled.getWorkItemHandlers().size());
    assertEquals(0, descriptorEnabled.getEventListeners().size());
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) TransientObjectModel(org.jbpm.runtime.manager.impl.deploy.TransientObjectModel) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) TransientNamedObjectModel(org.jbpm.runtime.manager.impl.deploy.TransientNamedObjectModel) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Example 2 with TransientNamedObjectModel

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

the class DeploymentServiceEJBImpl method addAsyncHandler.

protected void addAsyncHandler(KModuleDeploymentUnit unit) {
    // add async only when the executor component is not disabled
    if (isExecutorAvailable) {
        DeploymentDescriptor descriptor = unit.getDeploymentDescriptor();
        if (descriptor == null) {
            descriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
        }
        descriptor.getBuilder().addWorkItemHandler(new TransientNamedObjectModel("ejb", "async", "org.jbpm.executor.impl.wih.AsyncWorkItemHandler", new Object[] { EXECUTOR_EJB_JNDI_NAME, "org.jbpm.executor.commands.PrintOutCommand" }));
        unit.setDeploymentDescriptor(descriptor);
    }
}
Also used : DeploymentDescriptor(org.kie.internal.runtime.conf.DeploymentDescriptor) DeploymentDescriptorImpl(org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl) TransientNamedObjectModel(org.jbpm.runtime.manager.impl.deploy.TransientNamedObjectModel)

Aggregations

DeploymentDescriptorImpl (org.jbpm.runtime.manager.impl.deploy.DeploymentDescriptorImpl)2 TransientNamedObjectModel (org.jbpm.runtime.manager.impl.deploy.TransientNamedObjectModel)2 DeploymentDescriptor (org.kie.internal.runtime.conf.DeploymentDescriptor)2 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 TransientObjectModel (org.jbpm.runtime.manager.impl.deploy.TransientObjectModel)1 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)1 Test (org.junit.Test)1