Ejemplo n.º 1
0
 public void onApplicationEvent(ApplicationEvent event) {
   try {
     threadPool.execute(new Worker(event));
   } catch (InterruptedException e) {
     logger.error("Failed to process event: " + event.toString(), e);
   }
 }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see org.apache.oodt.cas.workflow.engine.WorkflowEngine#startWorkflow(org.apache.oodt.cas.workflow.structs.Workflow,
   *      org.apache.oodt.cas.metadata.Metadata)
   */
  public synchronized WorkflowInstance startWorkflow(Workflow workflow, Metadata metadata)
      throws EngineException {
    // to start the workflow, we create a default workflow instance
    // populate it
    // persist it
    // add it to the worker map
    // start it

    WorkflowInstance wInst = new WorkflowInstance();
    wInst.setWorkflow(workflow);
    wInst.setCurrentTaskId(((WorkflowTask) workflow.getTasks().get(0)).getTaskId());
    wInst.setSharedContext(metadata);
    wInst.setStatus(CREATED);
    persistWorkflowInstance(wInst);

    IterativeWorkflowProcessorThread worker =
        new IterativeWorkflowProcessorThread(wInst, instRep, this.wmgrUrl);
    worker.setRClient(rClient);
    workerMap.put(wInst.getId(), worker);

    wInst.setStatus(QUEUED);
    persistWorkflowInstance(wInst);

    try {
      pool.execute(worker);
    } catch (InterruptedException e) {
      throw new EngineException(e);
    }

    return wInst;
  }
Ejemplo n.º 3
0
 /**
  * Check, parse, verify the <code>req</code>. Attribute a client thread to serve the client.
  *
  * @see xsul.http_server.HttpMiniServlet#service(xsul.http_server.HttpServerRequest,
  *     xsul.http_server.HttpServerResponse)
  */
 public void service(HttpServerRequest req, HttpServerResponse resp) throws HttpServerException {
   // Thread allocation for the new client
   try {
     XmlElement el = builder.parseFragmentFromInputStream(req.getInputStream());
     // FIXME XmlElement el =
     // builder.parseFragmentFromInputStream(req.getInputStream(),
     // req.getCharset());
     SoapUtil soapUtil = SoapUtil.selectSoapFragrance(el, soapFragrances);
     String path = req.getPath();
     //          Path Treatment to get arguments
     String arguments = null;
     if (path != null) {
       // Analysiing path
       if (path.startsWith("/")) {
         path = path.substring(1);
       }
       String method = req.getMethod();
       if (method.equals("GET")) {
         // Remove arguments from path
         int argStart = path.indexOf('?');
         if (argStart != -1) {
           // There are some arguments
           arguments = path.substring(argStart, path.length());
           path = path.replaceAll("\\?.*", "");
         }
       }
     }
     ClientConnection client = new ClientConnection(path, arguments, el, soapUtil);
     pool.execute(
         client); // NOTE: pool will now "execute" client (the sentence may be delayed ...)
     // Successful HTTP message transmission
     // Send Ok to the client
     this.sendHttpOk(resp);
   } catch (Exception e) {
     SendError.send(resp, "500", "Thread Interrupted Exception");
     logger.warning("Couldn't allocate a thread to the client", e);
   }
 }
 @Override
 public void execute(Runnable r) throws InterruptedException {
   othersPooledExecutor.execute(r);
 }