Package org.jbpm

Examples of org.jbpm.JbpmContext


  JobSession jobSession;
  LocalTimerService localTimerService;
 
  public EntitySchedulerService() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext==null) {
      throw new JbpmException("instantiation of the EjbSchedulerService requires a current JbpmContext");
    }
    this.jobSession = jbpmContext.getJobSession();
   
    try {
      Context initial = new InitialContext();
      LocalTimerServiceHome localTimerServiceHome = (LocalTimerServiceHome) initial.lookup("java:comp/env/ejb/LocalTimerServiceBean");
      localTimerService = localTimerServiceHome.create();
View Full Code Here


  public Object execute(Command command) {
    log.debug("handing over the command execution to the command service");
   
    Object result = null;
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      log.debug("executing " + command);
      result = command.execute(jbpmContext);
    } catch (Exception e) {
      throw new JbpmException("couldn't execute "+command, e);
    } finally {
      jbpmContext.close();
    }
    return result;
  }
View Full Code Here

    this.connection = connection;
    this.session = session;
    this.destination = destination;
    this.isCommitEnabled = isCommitEnabled;
   
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext==null) {
      throw new JbpmException("instantiation of the JmsMessageService requires a current JbpmContext");
    }
    this.jobSession = jbpmContext.getJobSession();
  }
View Full Code Here

  JobSession jobSession;
  LocalTimerService localTimerService;
 
  public EjbSchedulerService() {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext==null) {
      throw new JbpmException("instantiation of the EjbSchedulerService requires a current JbpmContext");
    }
    this.jobSession = jbpmContext.getJobSession();
   
    try {
      Context initial = new InitialContext();
      LocalTimerServiceHome localTimerServiceHome = (LocalTimerServiceHome) initial.lookup("java:comp/env/ejb/LocalTimerServiceBean");
      localTimerService = localTimerServiceHome.create();
View Full Code Here

  public Object execute(Command command) {
    log.debug("handing over the command execution to the command service");
   
    Object result = null;
    JbpmContext jbpmContext = jbpmConfiguration.createJbpmContext();
    try {
      log.debug("executing " + command);
      result = command.execute(jbpmContext);
    } catch (Exception e) {
      throw new JbpmException("couldn't execute "+command, e);
    } finally {
      jbpmContext.close();
    }
    return result;
  }
View Full Code Here

    return getCurrentService(name, true);
  }

  public static Service getCurrentService(String name, boolean isRequired) {
    Service service = null;
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext != null) {
      service = jbpmContext.getServices().getService(name);
    }
    if (isRequired && (service == null)) {
      throw new JbpmServiceException("service '" + name + "' unavailable");
    }
    return service;
View Full Code Here

      }
    }
  }

  public static void assignId(Object object) {
    JbpmContext jbpmContext = JbpmContext.getCurrentJbpmContext();
    if (jbpmContext != null) {
      // assign id to the given object
      Services services = jbpmContext.getServices();
      if (services.hasService(Services.SERVICENAME_PERSISTENCE)) {
        PersistenceService persistenceService = services.getPersistenceService();
        persistenceService.assignId(object);
      }
    }
View Full Code Here

        }
    }

    private void startNewTxn(final JbpmJsfContextImpl jbpmJsfContext) {
        if (jbpmJsfContext.hasJbpmContext()) {
            final JbpmContext jbpmContext = jbpmJsfContext.getJbpmContext();
            DbPersistenceService dbPersistenceService = (DbPersistenceService) jbpmContext.getServices().getPersistenceService();
            log.fine("Committing transaction");
            dbPersistenceService.endTransaction();
            dbPersistenceService.beginTransaction();
        }
    }
View Full Code Here

                final String idPart = matcher.group(1);
                final long id = Long.parseLong(idPart);
                final String contentType = fileMatcher.getContentType();
                final String file = fileMatcher.getFile();
                final HttpServletResponse response = (HttpServletResponse) externalContext.getResponse();
                final JbpmContext jbpmContext = JbpmConfiguration.getInstance().createJbpmContext();
                try {
                    final ProcessDefinition processDefinition = jbpmContext.getGraphSession().getProcessDefinition(id);
                    if (processDefinition == null) {
                        try {
                            response.sendError(404, "Process definition " + id + " does not exist");
                            facesContext.responseComplete();
                            break;
                        } catch (IOException e) {
                            log.log(Level.SEVERE, "Failed to send 404 Not Found to client", e);
                        }
                    }
                    if (!processDefinition.getFileDefinition().hasFile(file)) {
                        try {
                            response.sendError(404, "Process definition " + id + " does not contain file '" + file + "'");
                            facesContext.responseComplete();
                            break;
                        } catch (IOException e) {
                            log.log(Level.SEVERE, "Failed to send 404 Not Found to client", e);
                        }
                    }
                    final byte[] bytes;
                    bytes = processDefinition.getFileDefinition().getBytes(file);
                    response.setContentLength(bytes.length);
                    response.setContentType(contentType);
                    try {
                        final OutputStream outputStream = response.getOutputStream();
                        try {
                            outputStream.write(bytes);
                            outputStream.flush();
                        } finally {
                            try {
                                outputStream.close();
                            } catch (IOException e) {
                                log.log(Level.WARNING, "Failed to close output stream", e);
                            }
                        }
                    } catch (IOException e) {
                        log.log(Level.SEVERE, "Failed to send process file", e);
                    }
                    facesContext.responseComplete();
                    if (log.isLoggable(Level.FINE)) {
                        log.fine("Sent process file '" + path + "'");
                    }
                    break;
                } finally {
                    jbpmContext.close();
                }
            }
        }
    }
View Full Code Here

    log.debug("event '" + eventType + "' on " + this + " for " + executionContext.getToken());
    try {
      executionContext.setEventSource(this);

      // TODO: Is it a valid condition that the jbpmContext is not there?
      JbpmContext jbpmContext = executionContext.getJbpmContext();
      if (jbpmContext != null) {
        Services services = jbpmContext.getServices();
        if (services != null) {
          EventService evService = (EventService) services.getService(EventService.SERVICE_NAME);
          if (evService != null) {
            evService.fireEvent(eventType, this, executionContext);
          }
View Full Code Here

TOP

Related Classes of org.jbpm.JbpmContext

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.