use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.
the class DeployClasspathResourcesEventHandler method handle.
@SuppressWarnings("unchecked")
@Override
public void handle(SimulationEvent event) {
List<String> resources = (List<String>) event.getProperty(resourcesKey);
DeploymentBuilder deploymentBuilder = SimulationRunContext.getRepositoryService().createDeployment();
for (String resource : resources) {
log.debug("adding resource [{}] to repository", resource, SimulationRunContext.getRepositoryService());
deploymentBuilder.addClasspathResource(resource);
}
deploymentBuilder.deploy();
}
use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.
the class Extender method checkBundle.
private void checkBundle(Bundle bundle) {
LOGGER.debug("Scanning bundle {} for activiti process", bundle.getSymbolicName());
try {
List<URL> pathList = new ArrayList<URL>();
String activitiHeader = (String) bundle.getHeaders().get(BUNDLE_ACTIVITI_HEADER);
if (activitiHeader == null) {
activitiHeader = "OSGI-INF/activiti/";
}
List<PathElement> paths = HeaderParser.parseHeader(activitiHeader);
for (PathElement path : paths) {
String name = path.getName();
if (name.endsWith("/")) {
addEntries(bundle, name, "*.*", pathList);
} else {
String baseName;
String filePattern;
int pos = name.lastIndexOf('/');
if (pos < 0) {
baseName = "/";
filePattern = name;
} else {
baseName = name.substring(0, pos + 1);
filePattern = name.substring(pos + 1);
}
if (hasWildcards(filePattern)) {
addEntries(bundle, baseName, filePattern, pathList);
} else {
addEntry(bundle, name, pathList);
}
}
}
if (!pathList.isEmpty()) {
LOGGER.debug("Found activiti process in bundle {} with paths: {}", bundle.getSymbolicName(), pathList);
ProcessEngine engine = (ProcessEngine) engineServiceTracker.waitForService(timeout);
if (engine == null) {
throw new IllegalStateException("Unable to find a ProcessEngine service");
}
RepositoryService service = engine.getRepositoryService();
DeploymentBuilder builder = service.createDeployment();
builder.name(bundle.getSymbolicName());
for (URL url : pathList) {
InputStream is = url.openStream();
if (is == null) {
throw new IOException("Error opening url: " + url);
}
try {
builder.addInputStream(getPath(url), is);
} finally {
is.close();
}
}
builder.enableDuplicateFiltering();
builder.deploy();
} else {
LOGGER.debug("No activiti process found in bundle {}", bundle.getSymbolicName());
}
} catch (Throwable t) {
LOGGER.error("Unable to deploy activiti bundle", t);
}
}
use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.
the class ProcessDeployer method deployProcess.
/**
* Deploys a single process
*
* @return the processDefinitionId of the deployed process as returned by
* {@link ProcessDefinition#getId()}
*/
public String deployProcess(String resourceName) {
logger.debug("Start deploying single process.");
// deploy processes as one deployment
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
deploymentBuilder.addClasspathResource(resourceName);
// deploy the processes
Deployment deployment = deploymentBuilder.deploy();
logger.debug("Process deployed");
// retreive the processDefinitionId for this process
return processEngine.getRepositoryService().createProcessDefinitionQuery().deploymentId(deployment.getId()).singleResult().getId();
}
use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.
the class ProcessDeployer method deployProcesses.
/**
* Deploys all processes listed in the {@link #PROCESSES_FILE_NAME}-file.
*/
public void deployProcesses() {
// build a single deployment containing all discovered processes
Set<String> resourceNames = getResourceNames();
if (resourceNames.isEmpty()) {
logger.debug("Not creating a deployment");
return;
}
logger.debug("Start deploying processes.");
DeploymentBuilder deploymentBuilder = processEngine.getRepositoryService().createDeployment();
for (String string : resourceNames) {
logger.info("Adding '" + string + "' to deployment.");
deploymentBuilder.addClasspathResource(string);
}
// deploy the processes
deploymentBuilder.deploy();
logger.debug("Done deploying processes.");
}
use of org.activiti.engine.repository.DeploymentBuilder in project Activiti by Activiti.
the class DeployResourcesEventHandler method handle.
@Override
public void handle(SimulationEvent event) {
@SuppressWarnings("unchecked") Map<String, ResourceEntity> resources = (Map<String, ResourceEntity>) event.getProperty(resourcesKey);
List<InputStream> inputStreams = new ArrayList<InputStream>();
try {
DeploymentBuilder deploymentBuilder = SimulationRunContext.getRepositoryService().createDeployment();
for (ResourceEntity resource : resources.values()) {
log.debug("adding resource [{}] to deploymnet", resource.getName());
InputStream is = new ByteArrayInputStream(resource.getBytes());
deploymentBuilder.addInputStream(resource.getName(), is);
inputStreams.add(is);
}
deploymentBuilder.deploy();
} finally {
for (InputStream is : inputStreams) {
try {
is.close();
} catch (IOException e) {
log.error("Unable to close resource input stream {}", is);
}
}
}
}
Aggregations