create queue

来源:互联网 发布:局域网团队协作软件 编辑:程序博客网 时间:2024/06/16 20:37

  public static void createQueue() throws WTException{
  ScheduleQueue category = (ScheduleQueue) QueueHelper.manager.getQueue(
    "New Queue for Test", wt.queue.ScheduleQueue.class);
  if (category == null) {
   ScheduleItem schItem = ScheduleItem.newScheduleItem();
   schItem.setItemDescription("task test");
   schItem.setItemName("task");
   schItem.setTargetClass(Test2.class.getName());
   schItem.setTargetMethod("list");
   schItem.setImmediateMode(false);
   schItem.setQueueName("New Queue for Test");
   schItem.setPeriodicity(5L);
   schItem.setToBeRun(-1L);
   wt.org.WTPrincipal principal = SessionHelper.manager
     .getAdministrator();
   WTPrincipalReference reference = WTPrincipalReference
     .newWTPrincipalReference(principal);
   schItem.setPrincipalRef(reference);
   long millis = System.currentTimeMillis();
   Timestamp timestamp = new Timestamp(millis);
   Timestamp timestamp2 = Timestamp.valueOf("2009-07-03 9:25:00.000");
   
   schItem.setStartDate(timestamp2);
   timestamp = new Timestamp(millis + 5L);
   schItem.setNextTime(timestamp);
   SchedulingHelper.service.addItem(schItem, null);
  }
  else{
   System.out.println("it has a same queue........");
  }
 }