use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.
the class DeployProcessArchiveStep method cancelOperationStep.
@Override
public void cancelOperationStep(DeploymentOperation operationContext) {
final PlatformServiceContainer serviceContainer = operationContext.getServiceContainer();
ProcessEngine processEngine = getProcessEngine(serviceContainer);
// if a registration was performed, remove it.
if (deployment != null && deployment.getProcessApplicationRegistration() != null) {
processEngine.getManagementService().unregisterProcessApplication(deployment.getProcessApplicationRegistration().getDeploymentIds(), true);
}
// isDeleteUponUndeploy is set.
if (deployment != null && PropertyHelper.getBooleanProperty(processArchive.getProperties(), ProcessArchiveXml.PROP_IS_DELETE_UPON_UNDEPLOY, false)) {
if (processEngine != null) {
processEngine.getRepositoryService().deleteDeployment(deployment.getId(), true);
}
}
}
use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.
the class DeployBarTask method execute.
public void execute() throws BuildException {
List<File> files = new ArrayList<File>();
if (file != null) {
files.add(file);
}
if (fileSets != null) {
for (FileSet fileSet : fileSets) {
DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject());
File baseDir = directoryScanner.getBasedir();
String[] includedFiles = directoryScanner.getIncludedFiles();
String[] excludedFiles = directoryScanner.getExcludedFiles();
List<String> excludedFilesList = Arrays.asList(excludedFiles);
for (String includedFile : includedFiles) {
if (!excludedFilesList.contains(includedFile)) {
files.add(new File(baseDir, includedFile));
}
}
}
}
Thread currentThread = Thread.currentThread();
ClassLoader originalClassLoader = currentThread.getContextClassLoader();
currentThread.setContextClassLoader(DeployBarTask.class.getClassLoader());
LogUtil.readJavaUtilLoggingConfigFromClasspath();
try {
log("Initializing process engine " + processEngineName);
ProcessEngines.init();
ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName);
if (processEngine == null) {
List<ProcessEngineInfo> processEngineInfos = ProcessEngines.getProcessEngineInfos();
if (processEngineInfos != null && processEngineInfos.size() > 0) {
// Since no engine with the given name is found, we can't be 100% sure which ProcessEngineInfo
// is causing the error. We should show ALL errors and process engine names / resource URL's.
String message = getErrorMessage(processEngineInfos, processEngineName);
throw new ProcessEngineException(message);
} else
throw new ProcessEngineException("Could not find a process engine with name '" + processEngineName + "', no engines found. " + "Make sure an engine configuration is present on the classpath");
}
RepositoryService repositoryService = processEngine.getRepositoryService();
log("Starting to deploy " + files.size() + " files");
for (File file : files) {
String path = file.getAbsolutePath();
log("Handling file " + path);
try {
FileInputStream inputStream = new FileInputStream(file);
try {
log("deploying bar " + path);
repositoryService.createDeployment().name(file.getName()).addZipInputStream(new ZipInputStream(inputStream)).deploy();
} finally {
IoUtil.closeSilently(inputStream);
}
} catch (Exception e) {
throw new BuildException("couldn't deploy bar " + path + ": " + e.getMessage(), e);
}
}
} finally {
currentThread.setContextClassLoader(originalClassLoader);
}
}
use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.
the class EmbeddedProcessApplicationTest method testDeployAppWithoutProcesses.
public void testDeployAppWithoutProcesses() {
registerProcessEngine();
TestApplicationWithoutProcesses processApplication = new TestApplicationWithoutProcesses();
processApplication.deploy();
ProcessEngine processEngine = BpmPlatform.getProcessEngineService().getDefaultProcessEngine();
long deployments = processEngine.getRepositoryService().createDeploymentQuery().count();
assertEquals(0, deployments);
processApplication.undeploy();
}
use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.
the class PlatformJobExecutorActivateTest method shouldAutoActivateIfNoPropertySet.
@Test
public void shouldAutoActivateIfNoPropertySet() {
// given
JobExecutorXmlImpl jobExecutorXml = defineJobExecutor();
ProcessEngineXmlImpl processEngineXml = defineProcessEngine();
BpmPlatformXmlImpl bpmPlatformXml = new BpmPlatformXmlImpl(jobExecutorXml, Collections.<ProcessEngineXml>singletonList(processEngineXml));
// when
deployPlatform(bpmPlatformXml);
try {
ProcessEngine processEngine = getProcessEngine(ENGINE_NAME);
ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl) processEngine.getProcessEngineConfiguration();
// then
assertEquals(true, processEngineConfiguration.getJobExecutor().isActive());
} finally {
undeployPlatform();
}
}
use of org.camunda.bpm.engine.ProcessEngine in project camunda-bpm-platform by camunda.
the class ForceCloseMybatisConnectionPoolTest method testForceCloseMybatisConnectionPoolFalse.
@Test
public void testForceCloseMybatisConnectionPoolFalse() {
// given
// that the process engine is configured with forceCloseMybatisConnectionPool = false
ProcessEngineConfigurationImpl configurationImpl = new StandaloneInMemProcessEngineConfiguration().setJdbcUrl("jdbc:h2:mem:camunda-forceclose").setProcessEngineName("engine-forceclose").setForceCloseMybatisConnectionPool(false);
ProcessEngine processEngine = configurationImpl.buildProcessEngine();
PooledDataSource pooledDataSource = (PooledDataSource) configurationImpl.getDataSource();
PoolState state = pooledDataSource.getPoolState();
int idleConnections = state.getIdleConnectionCount();
// then
// if the process engine is closed
processEngine.close();
// the idle connections are not closed
Assert.assertEquals(state.getIdleConnectionCount(), idleConnections);
pooledDataSource.forceCloseAll();
Assert.assertTrue(state.getIdleConnectionCount() == 0);
}
Aggregations