org.camunda.bpm.application.ProcessApplicationInterface Java Examples

The following examples show how to use org.camunda.bpm.application.ProcessApplicationInterface. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPaLocalScriptEngineTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ProcessApplicationInterface getProcessApplication() {
  ProcessApplicationReference reference = processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<ProcessApplicationReference>() {
    public ProcessApplicationReference execute(CommandContext commandContext) {
      ProcessDefinitionEntity definition = commandContext
          .getProcessDefinitionManager()
          .findLatestProcessDefinitionByKey(PROCESS_ID);
      String deploymentId = definition.getDeploymentId();
      ProcessApplicationManager processApplicationManager = processEngineConfiguration.getProcessApplicationManager();
      return processApplicationManager.getProcessApplicationForDeployment(deploymentId);
    }
  });

  assertNotNull(reference);

  ProcessApplicationInterface processApplication = null;
  try {
    processApplication = reference.getProcessApplication();
  } catch (ProcessApplicationUnavailableException e) {
    fail("Could not retrieve process application");
  }

  return processApplication.getRawObject();
}
 
Example #2
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void invokePreUndeploy(final ProcessApplicationInterface processApplication) throws ClassNotFoundException {
  if(preUndeployDescription != null) {
    Class<?> paClass = getPaClass(preUndeployDescription);
    final Method preUndeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, PreUndeploy.class);

    if(preUndeployMethod != null) {
      try {
        processApplication.execute(new Callable<Void>() {
          @Override
          public Void call() throws Exception {
            preUndeployMethod.invoke(processApplication.getRawObject(), getInjections(preUndeployMethod));
            return null;
          }
        });
      } catch(Exception e) {
        throw new RuntimeException("Exception while invoking the @PreUndeploy method ", e);
      }
    }
  }

}
 
Example #3
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void invokePostDeploy(final ProcessApplicationInterface processApplication) throws ClassNotFoundException, StartException {
  Class<?> paClass = getPaClass(postDeployDescription);
  final Method postDeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, PostDeploy.class);

  if(postDeployMethod != null) {
    try {
      processApplication.execute(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          postDeployMethod.invoke(processApplication.getRawObject(), getInjections(postDeployMethod));
          return null;
        }
      });
    }catch(Exception e) {
      throw new StartException("Exception while invoking the @PostDeploy method ", e);
    }
  }

}
 
Example #4
Source File: TypedValueField.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected static VariableSerializers getCurrentPaSerializers() {
  if (Context.getCurrentProcessApplication() != null) {
    ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
    try {
      ProcessApplicationInterface processApplicationInterface = processApplicationReference.getProcessApplication();

      ProcessApplicationInterface rawPa = processApplicationInterface.getRawObject();
      if (rawPa instanceof AbstractProcessApplication) {
        return ((AbstractProcessApplication) rawPa).getVariableSerializers();
      }
      else {
        return null;
      }
    } catch (ProcessApplicationUnavailableException e) {
      throw LOG.cannotDeterminePaDataformats(e);
    }
  }
  else {
    return null;
  }
}
 
Example #5
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void invokePreUndeploy(final ProcessApplicationInterface processApplication) throws ClassNotFoundException {
  if(preUndeployDescription != null) {
    Class<?> paClass = getPaClass(preUndeployDescription);
    final Method preUndeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, PreUndeploy.class);

    if(preUndeployMethod != null) {
      try {
        processApplication.execute(new Callable<Void>() {
          @Override
          public Void call() throws Exception {
            preUndeployMethod.invoke(processApplication.getRawObject(), getInjections(preUndeployMethod));
            return null;
          }
        });
      } catch(Exception e) {
        throw new RuntimeException("Exception while invoking the @PreUndeploy method ", e);
      }
    }
  }

}
 
Example #6
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void invokePostDeploy(final ProcessApplicationInterface processApplication) throws ClassNotFoundException, StartException {
  Class<?> paClass = getPaClass(postDeployDescription);
  final Method postDeployMethod = InjectionUtil.detectAnnotatedMethod(paClass, PostDeploy.class);

  if(postDeployMethod != null) {
    try {
      processApplication.execute(new Callable<Void>() {
        @Override
        public Void call() throws Exception {
          postDeployMethod.invoke(processApplication.getRawObject(), getInjections(postDeployMethod));
          return null;
        }
      });
    }catch(Exception e) {
      throw new StartException("Exception while invoking the @PostDeploy method ", e);
    }
  }

}
 
Example #7
Source File: ProcessApplicationEventListenerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void notifyTaskListener(DelegateTask task) throws Exception {
  ProcessApplicationReference processApp = Context.getCurrentProcessApplication();
  try {
    ProcessApplicationInterface processApplication = processApp.getProcessApplication();
    TaskListener taskListener = processApplication.getTaskListener();
    if(taskListener != null) {
      taskListener.notify(task);

    } else {
      LOG.paDoesNotProvideTaskListener(processApp.getName());

    }
  } catch (ProcessApplicationUnavailableException e) {
    // Process Application unavailable => ignore silently
    LOG.cannotInvokeListenerPaUnavailable(processApp.getName(), e);
  }
}
 
Example #8
Source File: ProcessApplicationEventListenerDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void notifyExecutionListener(DelegateExecution execution) throws Exception {
  ProcessApplicationReference processApp = Context.getCurrentProcessApplication();
  try {
    ProcessApplicationInterface processApplication = processApp.getProcessApplication();
    ExecutionListener executionListener = processApplication.getExecutionListener();
    if(executionListener != null) {
      executionListener.notify(execution);

    } else {
      LOG.paDoesNotProvideExecutionListener(processApp.getName());

    }
  } catch (ProcessApplicationUnavailableException e) {
    // Process Application unavailable => ignore silently
    LOG.cannotInvokeListenerPaUnavailable(processApp.getName(), e);
  }
}
 
Example #9
Source File: EnvScriptCachingTest.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected void executeScript(final ProcessApplicationInterface processApplication) {
  processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<Void>() {
      public Void execute(CommandContext commandContext) {
        return Context.executeWithinProcessApplication(new Callable<Void>() {

          public Void call() throws Exception {
            ScriptingEngines scriptingEngines = processEngineConfiguration.getScriptingEngines();
            ScriptEngine scriptEngine = scriptingEngines.getScriptEngineForLanguage(SCRIPT_LANGUAGE);

            SourceExecutableScript script = createScript(SCRIPT_LANGUAGE, SCRIPT);

            ScriptingEnvironment scriptingEnvironment = processEngineConfiguration.getScriptingEnvironment();
            scriptingEnvironment.execute(script, null, null, scriptEngine);

            return null;
          }
        }, processApplication.getReference());
      }
    });
}
 
Example #10
Source File: ProcessApplicationBeanElResolverDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ELResolver getElResolverDelegate() {

    ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
    if(processApplicationReference != null) {

      try {
        ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
        return processApplication.getBeanElResolver();

      } catch (ProcessApplicationUnavailableException e) {
        throw new ProcessEngineException("Cannot access process application '"+processApplicationReference.getName()+"'", e);
      }

    } else {
      return new BeanELResolver();
    }

  }
 
Example #11
Source File: ProcessApplicationElResolverDelegate.java    From camunda-bpm-platform with Apache License 2.0 6 votes vote down vote up
protected ELResolver getElResolverDelegate() {

    ProcessApplicationReference processApplicationReference = Context.getCurrentProcessApplication();
    if(processApplicationReference != null) {

      try {
        ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
        return processApplication.getElResolver();

      } catch (ProcessApplicationUnavailableException e) {
        throw new ProcessEngineException("Cannot access process application '"+processApplicationReference.getName()+"'", e);
      }

    } else {
      return null;
    }

  }
 
Example #12
Source File: ScriptingEnvironment.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected Map<String, List<ExecutableScript>> getPaEnvScripts(ProcessApplicationReference pa) {
  try {
    ProcessApplicationInterface processApplication = pa.getProcessApplication();
    ProcessApplicationInterface rawObject = processApplication.getRawObject();

    if (rawObject instanceof AbstractProcessApplication) {
      AbstractProcessApplication abstractProcessApplication = (AbstractProcessApplication) rawObject;
      return abstractProcessApplication.getEnvironmentScripts();
    }
    return null;
  }
  catch (ProcessApplicationUnavailableException e) {
    throw new ProcessEngineException("Process Application is unavailable.", e);
  }
}
 
Example #13
Source File: Activator.java    From camunda-bpm-platform-osgi with Apache License 2.0 5 votes vote down vote up
@Override
public void init(BundleContext context, DependencyManager manager)
		throws Exception {

	RuntimeContainerDelegate.INSTANCE.set(new OSGiRuntimeContainerDelegate(
			context));
	manager.add(createComponent().setImplementation(
			ProcessApplicationDeployer.class).add(
			createServiceDependency().setService(
					ProcessApplicationInterface.class).setCallbacks(
					"addProcessApplication", "removeProcessApplication")));
}
 
Example #14
Source File: StopProcessApplicationsStep.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * <p> Stops a process application. Exceptions are logged but not re-thrown).
 *
 * @param processApplicationReference
 */
protected void stopProcessApplication(ProcessApplicationReference processApplicationReference) {

  try {
    // unless the user has overridden the stop behavior,
    // this causes the process application to remove its services
    // (triggers nested undeployment operation)
    ProcessApplicationInterface processApplication = processApplicationReference.getProcessApplication();
    processApplication.undeploy();
  }
  catch(Throwable t) {
    LOG.exceptionWhileStopping("Process Application", processApplicationReference.getName(), t);
  }

}
 
Example #15
Source File: ScriptEngineCachingTest.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ScriptEngine getScriptEngineFromPa(final String name, final ProcessApplicationInterface processApplication) {
  return processEngineConfiguration.getCommandExecutorTxRequired()
    .execute(new Command<ScriptEngine>() {
      public ScriptEngine execute(CommandContext commandContext) {
        return Context.executeWithinProcessApplication(new Callable<ScriptEngine>() {

          public ScriptEngine call() throws Exception {
            return getScriptEngine(name);
          }
        }, processApplication.getReference());
      }
    });
}
 
Example #16
Source File: NoViewProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessApplicationInterface getValue() throws IllegalStateException, IllegalArgumentException {
  try {
    return reference.getProcessApplication();
    
  } catch (ProcessApplicationUnavailableException e) {
    throw new IllegalStateException("Process application '"+reference.getName()+"' is not unavailable.", e);
  }
}
 
Example #17
Source File: NoViewProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessApplicationInterface getValue() throws IllegalStateException, IllegalArgumentException {
  try {
    return reference.getProcessApplication();
    
  } catch (ProcessApplicationUnavailableException e) {
    throw new IllegalStateException("Process application '"+reference.getName()+"' is not unavailable.", e);
  }
}
 
Example #18
Source File: EnsureCleanDbPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("resource")
@Override
public void postProcessApplicationUndeploy(ProcessApplicationInterface processApplication) {
  // some tests deploy multiple PAs. => only clean DB after last PA is undeployed
  // if the deployment fails for example during parsing the deployment counter was not incremented
  // so we have to check if the counter is already zero otherwise we go into the negative values
  // best example is TestWarDeploymentWithBrokenBpmnXml in integration-test-engine test suite
  if(counter.get() == 0 || counter.decrementAndGet() == 0) {

    final ProcessEngine defaultProcessEngine = BpmPlatform.getDefaultProcessEngine();
    try {
      logger.log(Level.INFO, "=== Ensure Clean Database ===");
      ManagementServiceImpl managementService = (ManagementServiceImpl) defaultProcessEngine.getManagementService();
      PurgeReport report = managementService.purge();

      if (report.isEmpty()) {
        logger.log(Level.INFO, "Clean DB and cache.");
      } else {
        StringBuilder builder = new StringBuilder();

        DatabasePurgeReport databasePurgeReport = report.getDatabasePurgeReport();
        if (!databasePurgeReport.isEmpty()) {
          builder.append(DATABASE_NOT_CLEAN).append(databasePurgeReport.getPurgeReportAsString());
        }

        CachePurgeReport cachePurgeReport = report.getCachePurgeReport();
        if (!cachePurgeReport.isEmpty()) {
          builder.append(CACHE_IS_NOT_CLEAN).append(cachePurgeReport.getPurgeReportAsString());
        }
        logger.log(Level.INFO, builder.toString());
      }
    }
    catch(Throwable e) {
      logger.log(Level.SEVERE, "Could not clean DB:", e);
    }
  }

}
 
Example #19
Source File: ScriptingEngines.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
protected ScriptEngine getPaScriptEngine(String language, ProcessApplicationReference pa) {
  try {
    ProcessApplicationInterface processApplication = pa.getProcessApplication();
    ProcessApplicationInterface rawObject = processApplication.getRawObject();

    if (rawObject instanceof AbstractProcessApplication) {
      AbstractProcessApplication abstractProcessApplication = (AbstractProcessApplication) rawObject;
      return abstractProcessApplication.getScriptEngineForName(language, enableScriptEngineCaching);
    }
    return null;
  }
  catch (ProcessApplicationUnavailableException e) {
    throw new ProcessEngineException("Process Application is unavailable.", e);
  }
}
 
Example #20
Source File: EjbProcessApplication.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
/**
 * lookup a proxy object representing the invoked business view of this component.
 */
protected ProcessApplicationInterface lookupSelfReference() {

  try {
    InitialContext ic = new InitialContext();
    SessionContext sctxLookup = (SessionContext) ic.lookup(EJB_CONTEXT_PATH);
    return sctxLookup.getBusinessObject(getBusinessInterface());
  }
  catch (NamingException e) {
    throw LOG.ejbPaCannotLookupSelfReference(e);
  }

}
 
Example #21
Source File: SpinBpmPlatformPlugin.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
@Override
public void postProcessApplicationDeploy(ProcessApplicationInterface processApplication) {
  ProcessApplicationInterface rawPa = processApplication.getRawObject();
  if (rawPa instanceof AbstractProcessApplication) {
    initializeVariableSerializers((AbstractProcessApplication) rawPa);
  }
  else {
    LOG.logNoDataFormatsInitiailized("process application data formats", "process application is not a sub class of " + AbstractProcessApplication.class.getName());
  }
}
 
Example #22
Source File: EjbProcessApplicationReference.java    From camunda-bpm-platform with Apache License 2.0 5 votes vote down vote up
public ProcessApplicationInterface getProcessApplication() throws ProcessApplicationUnavailableException {
  try {
    // check whether process application is still deployed
    selfReference.getName();
  }
  catch(EJBException e) {
    throw LOG.processApplicationUnavailableException(processApplicationName, e);
  }
  return selfReference;
}
 
Example #23
Source File: ProcessApplicationDeployer.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
public void removeProcessApplication(ServiceReference<ProcessApplicationInterface> reference, ProcessApplicationInterface service) {
  service.undeploy();
}
 
Example #24
Source File: ExampleBpmPlatformPlugin.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
@Override
public void postProcessApplicationDeploy(ProcessApplicationInterface processApplication) {
}
 
Example #25
Source File: OSGiProcessApplicationReference.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessApplicationInterface getProcessApplication() throws ProcessApplicationUnavailableException {
  return application;
}
 
Example #26
Source File: ProcessApplicationDeploymentService.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public InjectedValue<ProcessApplicationInterface> getNoViewProcessApplication() {
  return noViewProcessApplication;
}
 
Example #27
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
protected void notifyBpmPlatformPlugins(BpmPlatformPlugins value, ProcessApplicationInterface processApplication) {
  for (BpmPlatformPlugin plugin : value.getPlugins()) {
    plugin.postProcessApplicationDeploy(processApplication);
  }
}
 
Example #28
Source File: OSGiProcessApplicationReference.java    From camunda-bpm-platform-osgi with Apache License 2.0 4 votes vote down vote up
public OSGiProcessApplicationReference(ProcessApplicationInterface application, String name) {
  this.application = application;
  this.name = name;
}
 
Example #29
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public InjectedValue<ProcessApplicationInterface> getNoViewProcessApplication() {
  return noViewProcessApplication;
}
 
Example #30
Source File: ProcessApplicationStartService.java    From camunda-bpm-platform with Apache License 2.0 4 votes vote down vote up
public InjectedValue<ProcessApplicationInterface> getNoViewProcessApplication() {
  return noViewProcessApplication;
}