Package commonj.work

Examples of commonj.work.WorkItem


            {
                log.error("Exceptiong during job killing.", e);
            }
            finally
            {
                WorkItem workItem = (WorkItem) job.getWorkerAttribute(COMMONJ_WORK_ITEM_ATTR);
               
                if (workItem != null)
                {
                    removeMonitoredJobWork(workItem);
                }
View Full Code Here


       * @see java.lang.Runnable#run()
       */
      public void run(  )
      {
         // TODO: fix this (what's wrong with it?)
         WorkItem  workItem = new WorkItemImpl(  );

         WorkEvent event = new WorkEventImpl( WorkEvent.WORK_STARTED, workItem );
         processEvent( event );
         if ( this.listener != null )
         {
View Full Code Here

      if ( work == null )
      {
         throw new IllegalArgumentException( MSG.getMessage( Keys.NULL_WORK ) );
      }

      WorkItem workItem = new WorkItemImpl(  );

      this.workItems.put( work, workItem );

      try
      {
View Full Code Here

   public boolean waitForAll( Collection workItems,
                              long       timeout )
   {
      Iterator workItemsIterator = workItems.iterator(  );
      Object   current;
      WorkItem workItem;
      int      status;

      if ( timeout == WorkManager.IMMEDIATE )
      {
         while ( workItemsIterator.hasNext(  ) )
         {
            current = workItemsIterator.next(  );
            if ( current instanceof WorkItem )
            {
               status = ( (WorkItem) current ).getStatus(  );
               if ( ( status != WorkEvent.WORK_COMPLETED ) && ( status != WorkEvent.WORK_REJECTED ) )
               {
                  return false;
               }
            }
         }
      }
      else if ( timeout == WorkManager.INDEFINITE )
      {
         while ( workItemsIterator.hasNext(  ) )
         {
            current = workItemsIterator.next(  );
            if ( current instanceof WorkItem )
            {
               workItem = (WorkItem) current;
               synchronized ( workItem )
               {
                  status = workItem.getStatus(  );
                  while ( ( status != WorkEvent.WORK_COMPLETED ) && ( status != WorkEvent.WORK_REJECTED ) )
                  {
                     try
                     {
                        workItem.wait(  );
                     }
                     catch ( InterruptedException e )
                     {
                        // not sure if this is the right thing to do
                        return false;
                     }

                     status = workItem.getStatus(  );
                  }
               }
            }
         }
      }
      else
      {
         long absTimeout = System.currentTimeMillis(  ) + timeout;
         while ( workItemsIterator.hasNext(  ) )
         {
            current = workItemsIterator.next(  );
            if ( current instanceof WorkItem )
            {
               workItem = (WorkItem) current;
               synchronized ( workItem )
               {
                  status = workItem.getStatus(  );
                  while ( ( status != WorkEvent.WORK_COMPLETED ) && ( status != WorkEvent.WORK_REJECTED ) )
                  {
                     if ( timeout > 0 )
                     {
                        try
                        {
                           workItem.wait( timeout );
                        }
                        catch ( InterruptedException e )
                        {
                           // not sure if this is the right thing to do
                           return false;
                        }

                        timeout = absTimeout - System.currentTimeMillis(  );
                     }
                     else
                     {
                        return false;
                     }

                     status = workItem.getStatus(  );
                  }
               }
            }
         }
      }
View Full Code Here

   public Collection waitForAny( Collection workItems,
                                 long       timeout )
   {
      Iterator   workItemsIterator = workItems.iterator(  );
      Object     current;
      WorkItem   workItem;
      int        status;
      Collection result = new Vector(  );

      if ( timeout == WorkManager.IMMEDIATE )
      {
         while ( workItemsIterator.hasNext(  ) )
         {
            current = workItemsIterator.next(  );
            if ( current instanceof WorkItem )
            {
               workItem    = (WorkItem) current;
               status      = workItem.getStatus(  );
               if ( ( status == WorkEvent.WORK_COMPLETED ) || ( status == WorkEvent.WORK_REJECTED ) )
               {
                  result.add( workItem );
               }
            }
         }
      }
      else if ( timeout == WorkManager.INDEFINITE )
      {
         if ( this.waitForAll( workItems, timeout ) )
         {
            return workItems;
         }
         else
         {
            return null;
         }
      }
      else
      {
         long absTimeout = System.currentTimeMillis(  ) + timeout;
         while ( workItemsIterator.hasNext(  ) )
         {
            current = workItemsIterator.next(  );
            if ( current instanceof WorkItem )
            {
               workItem = (WorkItem) current;
               synchronized ( workItem )
               {
                  status = workItem.getStatus(  );
                  while ( ( status != WorkEvent.WORK_COMPLETED )
                          && ( status != WorkEvent.WORK_REJECTED )
                          && ( timeout > 0 ) )
                  {
                     try
                     {
                        workItem.wait( timeout );
                     }
                     catch ( InterruptedException e )
                     {
                        // not sure if this is the right thing to do
                        return null;
                     }

                     timeout    = absTimeout - System.currentTimeMillis(  );
                     status     = workItem.getStatus(  );
                  }

                  if ( ( status == WorkEvent.WORK_COMPLETED ) || ( status == WorkEvent.WORK_REJECTED ) )
                  {
                     result.add( workItem );
View Full Code Here

        job.setWorkerAttribute(ACCESS_CONTROL_CONTEXT_WORKER_ATTR, context);
       
        try
        {
            RenderingJobCommonjWork jobWork = new RenderingJobCommonjWork(job);
            WorkItem workItem = this.workManager.schedule(jobWork, this);
            job.setWorkerAttribute(COMMONJ_WORK_ITEM_ATTR, workItem);
           
            if (this.jobWorksMonitorEnabled)
            {
                this.jobWorksMonitored.put(workItem, jobWork);
View Full Code Here

   
    // commonj.work.WorkListener implementations
   
    public void workAccepted(WorkEvent we)
    {
        WorkItem workItem = we.getWorkItem();
        if (log.isDebugEnabled())
        {
            log.debug("[CommonjWorkMonitorImpl] workAccepted: " + workItem);
        }
    }
View Full Code Here

        }
    }

    public void workRejected(WorkEvent we)
    {
        WorkItem workItem = we.getWorkItem();
        if (log.isDebugEnabled())
        {
            log.debug("[CommonjWorkMonitorImpl] workRejected: " + workItem);
        }
       
View Full Code Here

        }
    }

    public void workStarted(WorkEvent we)
    {
        WorkItem workItem = we.getWorkItem();
        if (log.isDebugEnabled())
        {
            log.debug("[CommonjWorkMonitorImpl] workStarted: " + workItem);
        }
    }
View Full Code Here

        }
    }

    public void workCompleted(WorkEvent we)
    {
        WorkItem workItem = we.getWorkItem();
        if (log.isDebugEnabled())
        {
            log.debug("[CommonjWorkMonitorImpl] workCompleted: " + workItem);
        }
       
View Full Code Here

TOP

Related Classes of commonj.work.WorkItem

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.