コード例 #1
0
  protected void activate(ComponentContext ctxt) {
    log.info("Initializing the BPMN core component...");
    try {
      BundleContext bundleContext = ctxt.getBundleContext();
      BPMNServerHolder holder = BPMNServerHolder.getInstance();
      ActivitiEngineBuilder activitiEngineBuilder = new ActivitiEngineBuilder();
      holder.setEngine(activitiEngineBuilder.buildEngine());
      holder.setTenantManager(new TenantManager());

      BPMNRestExtensionHolder restHolder = BPMNRestExtensionHolder.getInstance();

      restHolder.setRestInvoker(new RESTInvoker());
      bundleContext.registerService(
          WaitBeforeShutdownObserver.class.getName(), new BPMNEngineShutdown(), null);

      //            DataSourceHandler dataSourceHandler = new DataSourceHandler();
      //            dataSourceHandler.initDataSource(activitiEngineBuilder.getDataSourceJndiName());
      //            dataSourceHandler.closeDataSource();
      //        } catch (BPMNMetaDataTableCreationException e) {
      //            log.error("Could not create BPMN checksum table", e);
      //        } catch (DatabaseConfigurationException e) {
      //            log.error("Could not create BPMN checksum table", e);
    } catch (Throwable e) {
      log.error("Failed to initialize the BPMN core component.", e);
    }
  }
 /**
  * Get completed process instances which were finished after the given date and time
  *
  * @return BPMNProcessInstance array if the historic process instance list is not null
  */
 public BPMNProcessInstance[] getCompletedProcessInstances() {
   HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
   HistoricProcessInstanceQuery instanceQuery =
       historyService.createHistoricProcessInstanceQuery();
   List<HistoricProcessInstance> historicProcessInstanceList = null;
   String time =
       readPublishTimeFromRegistry(
           AnalyticsPublisherConstants.PROCESS_RESOURCE_PATH,
           AnalyticsPublisherConstants.LAST_PROCESS_INSTANCE_PUBLISH_TIME);
   if (time == null) {
     if (instanceQuery.finished().list().size() != 0) {
       // if the stored time is null in the registry file then send all completed process
       // instances.
       historicProcessInstanceList =
           instanceQuery.finished().orderByProcessInstanceStartTime().asc().list();
     }
   } else {
     Date timeInDateFormat = DateConverter.convertStringToDate(time);
     int listSize = instanceQuery.finished().startedAfter(timeInDateFormat).list().size();
     if (listSize != 0) {
       /*When using the startedAfter() method it returns the finished objects according to the time stored of
       last completed instance. But if the list length is one then it always return the same object in the
       list twice from the last updated time which stored in the carbon registry.
       (avoid to return same object repeatedly if the list has only one object)*/
       if (listSize == 1) {
         return null;
       }
       // send the process instances which were finished after the given date/time in registry
       historicProcessInstanceList =
           instanceQuery
               .finished()
               .startedAfter(timeInDateFormat)
               .orderByProcessInstanceStartTime()
               .asc()
               .listPage(1, listSize);
     }
   }
   if (historicProcessInstanceList != null) {
     if (log.isDebugEnabled()) {
       log.debug(
           "Write the published time of the last BPMN process instance to the carbon registry..."
               + historicProcessInstanceList.toString());
     }
     /*write the last published time to the registry because lets say as an example when a new process is completed,
     then the attributes belong to that process instance should be published to the DAS and if we are not stored
     the last published time, then all the completed processes which were previously published are also re-published
     to the DAS.*/
     writePublishTimeToRegistry(historicProcessInstanceList);
     // return ProcessInstances set as BPMNProcessInstance array
     return getBPMNProcessInstances(historicProcessInstanceList);
   }
   return null;
 }
 /**
  * Get completed task instances which were finished after the given date and time
  *
  * @return BPMNTaskInstance array if the historic task instance list is not null
  */
 public BPMNTaskInstance[] getCompletedTaskInstances() {
   HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
   HistoricTaskInstanceQuery instanceQuery = historyService.createHistoricTaskInstanceQuery();
   List<HistoricTaskInstance> historicTaskInstanceList = null;
   String time =
       readPublishTimeFromRegistry(
           AnalyticsPublisherConstants.TASK_RESOURCE_PATH,
           AnalyticsPublisherConstants.LAST_TASK_INSTANCE_END_TIME);
   if (time == null) {
     if (instanceQuery.finished().list().size() != 0) {
       historicTaskInstanceList =
           instanceQuery.finished().orderByHistoricTaskInstanceEndTime().asc().list();
     }
   } else {
     Date dateFormat = DateConverter.convertStringToDate(time);
     int listSize = instanceQuery.finished().taskCompletedAfter(dateFormat).list().size();
     if (listSize != 0) {
       /*When using the startedAfter() method it returns the finished objects according to the time stored of
       last completed instance. But if the list length is one then it always return the same object in the
       list twice from the last updated time which stored in the carbon registry.
       (avoid to return same object repeatedly if the list has only one object)*/
       if (listSize == 1) {
         return null;
       }
       historicTaskInstanceList =
           instanceQuery
               .finished()
               .taskCompletedAfter(dateFormat)
               .orderByHistoricTaskInstanceEndTime()
               .asc()
               .listPage(1, listSize);
     }
   }
   if (historicTaskInstanceList != null) {
     if (log.isDebugEnabled()) {
       log.debug(
           "Write BPMN task instance to the carbon registry..."
               + historicTaskInstanceList.toString());
     }
     writeTaskEndTimeToRegistry(historicTaskInstanceList);
     return getBPMNTaskInstances(historicTaskInstanceList);
   }
   return null;
 }
コード例 #4
0
 private static class BPMNServerInstanceHolder {
   private static final BPMNServerHolder INSTANCE = BPMNServerHolder.getInstance();
 }
コード例 #5
0
 public void unsetRegistryService(RegistryService registryService) {
   if (log.isDebugEnabled()) {
     log.debug("RegistryService unbound from the BPMN component");
   }
   BPMNServerHolder.getInstance().unsetRegistryService(registryService);
 }
コード例 #6
0
 protected void setRegistryService(RegistryService registrySvc) {
   if (log.isDebugEnabled()) {
     log.debug("RegistryService bound to the BPMN component");
   }
   BPMNServerHolder.getInstance().setRegistryService(registrySvc);
 }