Package org.activiti.engine

Examples of org.activiti.engine.ProcessEngineConfiguration


        }

        GetBpmnModelCmd getBpmnModelCmd = new GetBpmnModelCmd(
                processDefinitionId);
        BpmnModel bpmnModel = getBpmnModelCmd.execute(commandContext);
        ProcessEngineConfiguration processEngineConfiguration = Context
                .getProcessEngineConfiguration();
        InputStream is = new DefaultProcessDiagramGenerator().generateDiagram(
                bpmnModel, "png",
                processEngineConfiguration.getActivityFontName(),
                processEngineConfiguration.getLabelFontName(), null);

        return is;
    }
View Full Code Here


    properties.put("dateTime", sdf.format(ca.getTime()) + "T" + sdft.format(ca.getTime()));
    taskService.complete(task.getId(), properties);
  }
 
  public void startProcessWithJob() throws Exception {
    ProcessEngineConfiguration createStandaloneInMemProcessEngineConfiguration = StandaloneInMemProcessEngineConfiguration.createStandaloneInMemProcessEngineConfiguration();
    createStandaloneInMemProcessEngineConfiguration.setJobExecutorActivate(true);
    ProcessEngine processEngine = createStandaloneInMemProcessEngineConfiguration.buildProcessEngine();
    RepositoryService repositoryService = processEngine.getRepositoryService();
    repositoryService.createDeployment().addInputStream("TimeBoundaryIntermediateEvent.bpmn20.xml",
        new FileInputStream(filename)).deploy();
    RuntimeService runtimeService = processEngine.getRuntimeService();
    Map<String, Object> variableMap = new HashMap<String, Object>();
View Full Code Here

    String hostName = Utils.getHostName();
    JMXServiceURL url =
            new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/activiti");
  
   
    ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
    ProcessEngine processEngine = processEngineConfig.buildProcessEngine();
   
   
    // wait for jmx server to come up
    Thread.sleep(500);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
View Full Code Here

 
  protected void setAppropriateCamelContext(ActivityExecution execution) {
    //Check to see if the springConfiguration has been set. If not, set it.
    if (springConfiguration == null) {
      //Get the ProcessEngineConfiguration object.
      ProcessEngineConfiguration engineConfiguration = Context.getProcessEngineConfiguration();
         
      //Convert it to a SpringProcessEngineConfiguration. If this doesn't work, throw a RuntimeException.
      // (ActivitiException extends RuntimeException.)
      try {
        springConfiguration = (SpringProcessEngineConfiguration) engineConfiguration;
View Full Code Here

  @Override
  protected void initializeProcessEngine() {
    Clock clock = new DefaultClockImpl();

    ProcessEngineConfiguration processEngineConfiguration = ProcessEngineConfiguration.createProcessEngineConfigurationFromResourceDefault();
    processEngineConfiguration.setClock(clock);

    this.processEngine = (new RecordableProcessEngineFactory(
        (ProcessEngineConfigurationImpl) processEngineConfiguration
        , listener)).
      getObject();
View Full Code Here

  @Test
  public void testJobExecutorJMXClient() throws InterruptedException, IOException, MalformedObjectNameException, AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException {
    String hostName = Utils.getHostName();
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi://" + hostName + ":10111/jndi/rmi://" + hostName + ":1099/jmxrmi/activiti");
    ProcessEngineConfiguration processEngineConfig = ProcessEngineConfiguration.createProcessEngineConfigurationFromResource("activiti.cfg.xml");
   
    Thread.sleep(500);
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    ObjectName jobExecutorBeanName = new ObjectName("org.activiti.jmx.Mbeans:type=JobExecutor");
   
    processEngineConfig.getJobExecutor().shutdown();
   
    // first check that job executor is not activated and correctly reported as being inactive
    assertFalse(processEngineConfig.isJobExecutorActivate());
    assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
    // now activate it remotely
    mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate", new Boolean[]{true}, new String[]{Boolean.class.getName()});
   
    // check if it has the effect and correctly reported
//    assertTrue(processEngineConfig.getJobExecutor().isActive());
    assertTrue((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
   
    //agani disable and check it   
    mbsc.invoke(jobExecutorBeanName, "setJobExecutorActivate"new Boolean[]{false}, new String[]{Boolean.class.getName()});
   
    // check if it has the effect and correctly reported
    assertFalse(processEngineConfig.isJobExecutorActivate());
    assertFalse((Boolean) mbsc.getAttribute(jobExecutorBeanName, "JobExecutorActivated"));
  }
View Full Code Here

      public InputStream getStream() {
        WorkflowDefinitionConversion workflowDefinitionConversion =
                ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(createWorkflow());
        final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
        final ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine.getProcessEngineConfiguration();
        final ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();

        return diagramGenerator.generateDiagram(workflowDefinitionConversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
            processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader());
      }
    };
   
    // resource must have unique id (or cache-crap can happen)!
    StreamResource imageresource = new StreamResource(streamSource,UUID.randomUUID() + ".png", ExplorerApp.get());
View Full Code Here

  protected void save() {
    WorkflowDefinition workflowDefinition = createWorkflow();

    final ProcessEngineImpl defaultProcessEngine = (ProcessEngineImpl) ProcessEngines.getDefaultProcessEngine();
    RepositoryService repositoryService = defaultProcessEngine.getRepositoryService();
    ProcessEngineConfiguration processEngineConfiguration = defaultProcessEngine.getProcessEngineConfiguration();
    ProcessDiagramGenerator diagramGenerator = processEngineConfiguration.getProcessDiagramGenerator();
   
    Model model = null;
    if (modelId == null) { // new process
      model = repositoryService.newModel();
    } else { // update existing process
      model = repositoryService.getModel(modelId);
    }

    model.setName(workflowDefinition.getName());
    model.setCategory(SimpleTableEditorConstants.TABLE_EDITOR_CATEGORY);
    repositoryService.saveModel(model);

    // Store model entity
    WorkflowDefinitionConversion conversion =
            ExplorerApp.get().getWorkflowDefinitionConversionFactory().createWorkflowDefinitionConversion(workflowDefinition);
    conversion.convert();
   
    try {
      // Write JSON to byte-array and set as editor-source
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      ExplorerApp.get().getSimpleWorkflowJsonConverter().writeWorkflowDefinition(workflowDefinition, new OutputStreamWriter(baos));
      repositoryService.addModelEditorSource(model.getId(), baos.toByteArray());
     
      // Store process image
      // TODO: we should really allow the service to take an inputstream as input. Now we load it into memory ...
      repositoryService.addModelEditorSourceExtra(model.getId(), IOUtils.toByteArray(
          diagramGenerator.generateDiagram(conversion.getBpmnModel(), "png", processEngineConfiguration.getActivityFontName(),
              processEngineConfiguration.getLabelFontName(), processEngineConfiguration.getClassLoader())));
    } catch (IOException e) {
      logger.warn("Could not generate process image. Image is not stored and will not be shown.", e);
    }
   
    ExplorerApp.get().getViewManager().showEditorProcessDefinitionPage(model.getId());
View Full Code Here

    if (job == null) {
      return null;
    }
    
    ActivityImpl activity = getCurrentActivity(commandContext, job);
    ProcessEngineConfiguration processEngineConfig = commandContext.getProcessEngineConfiguration();
  
    if (activity == null || activity.getFailedJobRetryTimeCycleValue() == null) {
      log.error("activitiy or FailedJobRetryTimerCycleValue is null in job " + jobId + "'. only decrementing retries.");
      job.setRetries(job.getRetries() - 1);
      job.setLockOwner(null);
      job.setLockExpirationTime(null);
      if (job.getDuedate() == null) {
        // add wait time for failed async job
        job.setDuedate(calculateDueDate(commandContext, processEngineConfig.getAsyncFailedJobWaitTime(), null));
      } else {
        // add default wait time for failed job
        job.setDuedate(calculateDueDate(commandContext, processEngineConfig.getDefaultFailedJobWaitTime(), job.getDuedate()));
      }
     
    } else {     
      String failedJobRetryTimeCycle = activity.getFailedJobRetryTimeCycleValue();
      try {
        DurationHelper durationHelper = new DurationHelper(failedJobRetryTimeCycle, processEngineConfig.getClock());
        job.setLockOwner(null);
        job.setLockExpirationTime(null);
        job.setDuedate(durationHelper.getDateAfter());
        
        if (job.getExceptionMessage() == null) {  // is it the first exception
          log.debug("Applying JobRetryStrategy '" + failedJobRetryTimeCycle+ "' the first time for job " + job.getId() + " with "+ durationHelper.getTimes()+" retries");
          // then change default retries to the ones configured
          job.setRetries(durationHelper.getTimes());
         
        } else {
          log.debug("Decrementing retries of JobRetryStrategy '" + failedJobRetryTimeCycle+ "' for job " + job.getId());
        }
        job.setRetries(job.getRetries() - 1);
        
      } catch (Exception e) {
        throw new ActivitiException("failedJobRetryTimeCylcle has wrong format:" + failedJobRetryTimeCycle, exception);
     
    }
   
    if (exception != null) {
      job.setExceptionMessage(exception.getMessage());
      job.setExceptionStacktrace(getExceptionStacktrace());
    }
   
    // Dispatch both an update and a retry-decrement event
    ActivitiEventDispatcher eventDispatcher = commandContext.getEventDispatcher();
    if (eventDispatcher.isEnabled()) {
      eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(
          ActivitiEventType.ENTITY_UPDATED, job));
      eventDispatcher.dispatchEvent(ActivitiEventBuilder.createEntityEvent(
          ActivitiEventType.JOB_RETRIES_DECREMENTED, job));
    }
   
    if (processEngineConfig.isAsyncExecutorEnabled() == false) {
      JobExecutor jobExecutor = processEngineConfig.getJobExecutor();
      JobAddedNotification messageAddedNotification = new JobAddedNotification(jobExecutor);
      TransactionContext transactionContext = commandContext.getTransactionContext();
      transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
    }
View Full Code Here

    message.setJobHandlerType(AsyncContinuationJobHandler.TYPE);
    // At the moment, only AtomicOperationTransitionCreateScope can be performed asynchronously,
    // so there is no need to pass it to the handler
   
    GregorianCalendar expireCal = new GregorianCalendar();
    ProcessEngineConfiguration processEngineConfig = Context.getCommandContext().getProcessEngineConfiguration();
    expireCal.setTime(processEngineConfig.getClock().getCurrentTime());
    expireCal.add(Calendar.SECOND, processEngineConfig.getLockTimeAsyncJobWaitTime());
    message.setLockExpirationTime(expireCal.getTime());
   
    // Inherit tenant id (if applicable)
    if (getTenantId() != null) {
      message.setTenantId(getTenantId());
View Full Code Here

TOP

Related Classes of org.activiti.engine.ProcessEngineConfiguration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.