Exemple #1
0
 public void doService(DataCollection dc, Connection con) throws TaskFailedException {
   String serviceID = dc.getValue("serviceID");
   if (serviceID == null) {
     dc.addMessage("exilNoServiceID", serviceID);
   } else {
     Job aJob = (Job) this.jobs.get(serviceID); // Get based on the Id from the hashmap.
     /*if(aJob.previliged(dc.getValue("rolesToValidate"))){
     	dc.addMessage("exilRPError","User Has No Previlige");
     	throw new TaskFailedException();
     }*/
     if (LOGGER.isDebugEnabled()) LOGGER.debug(aJob);
     if (aJob == null) {
       dc.addMessage("exilNoJobDefinition", serviceID);
     } else {
       if (aJob.hasAccess(dc, con)) aJob.execute(dc, con);
       else dc.addMessage("exilNoAccess", serviceID);
     }
   }
 }
  /** @param args */
  public static void main(String[] args) {

    BlockingQueue<PendingMessage> messages = new LinkedBlockingQueue<PendingMessage>();

    BlockingQueueEmailService emailService = new BlockingQueueEmailService(messages);
    Thread emailServiceThread = new Thread(emailService, "EmailService Thread");
    emailServiceThread.start();

    Job job = new Job(messages);
    try {
      job.execute();
    } catch (JobExecutionException e1) {
      LOGGER.severe("error executing job, to retry");
      System.exit(-1);
    }

    try {
      emailServiceThread.join();
    } catch (InterruptedException e) {
      // ignore
    }
  }