Search in sources :

Example 11 with DeploymentBuilder

use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.

the class TestHelper method annotationDeploymentSetUp.

// Test annotation support /////////////////////////////////////////////
public static String annotationDeploymentSetUp(ProcessEngine processEngine, Class<?> testClass, String methodName) {
    String deploymentId = null;
    Method method = null;
    try {
        method = testClass.getMethod(methodName, (Class<?>[]) null);
    } catch (Exception e) {
        log.warn("Could not get method by reflection. This could happen if you are using @Parameters in combination with annotations.", e);
        return null;
    }
    Deployment deploymentAnnotation = method.getAnnotation(Deployment.class);
    if (deploymentAnnotation != null) {
        log.debug("annotation @Deployment creates deployment for {}.{}", testClass.getSimpleName(), methodName);
        String[] resources = deploymentAnnotation.resources();
        if (resources.length == 0) {
            String name = method.getName();
            String resource = getBpmnProcessDefinitionResource(testClass, name);
            resources = new String[] { resource };
        }
        DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment().name(testClass.getSimpleName() + "." + methodName);
        for (String resource : resources) {
            deploymentBuilder.addClasspathResource(resource);
        }
        deploymentId = deploymentBuilder.deploy().getId();
    }
    return deploymentId;
}
Also used : Deployment(org.activiti.engine.test.Deployment) Method(java.lang.reflect.Method) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder)

Example 12 with DeploymentBuilder

use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.

the class ProcessDefinitionsMBean method deployProcessDefinition.

@ManagedOperation(description = "Deploy Process Definition")
public void deployProcessDefinition(String resourceName, String processDefinitionFile) throws FileNotFoundException {
    DeploymentBuilder deploymentBuilder = repositoryService.createDeployment();
    Deployment deployment = deploymentBuilder.addInputStream(resourceName, new FileInputStream(processDefinitionFile)).deploy();
}
Also used : Deployment(org.activiti.engine.repository.Deployment) DeploymentBuilder(org.activiti.engine.repository.DeploymentBuilder) FileInputStream(java.io.FileInputStream) ManagedOperation(org.activiti.management.jmx.annotations.ManagedOperation)

Aggregations

DeploymentBuilder (org.activiti.engine.repository.DeploymentBuilder)12 IOException (java.io.IOException)6 ZipInputStream (java.util.zip.ZipInputStream)5 ActivitiException (org.activiti.engine.ActivitiException)5 Deployment (org.activiti.engine.repository.Deployment)3 Resource (org.springframework.core.io.Resource)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 FileInputStream (java.io.FileInputStream)1 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 ActivitiIllegalArgumentException (org.activiti.engine.ActivitiIllegalArgumentException)1 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)1 ProcessEngine (org.activiti.engine.ProcessEngine)1 RepositoryService (org.activiti.engine.RepositoryService)1