Java Code Examples for javax.resource.spi.work.WorkEvent#WORK_COMPLETED

The following examples show how to use javax.resource.spi.work.WorkEvent#WORK_COMPLETED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StatusWorkAdapter.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * complete work 
 *
 * @param e workEvent
 */
@Override
public void workCompleted(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_COMPLETED)
      fail("Wrong completed type");

   if (callbackCount != null)
   {
      synchronized (this)
      {
         callbackCount.setCompletedCount(callbackCount.getCompletedCount() + 1);
      }
   }

   super.workCompleted(e);
}
 
Example 2
Source File: ContextWorkAdapter.java    From ironjacamar with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * complete work 
 *
 * @param e workEvent
 */
@Override
public void workCompleted(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_COMPLETED)
      fail("Wrong completed type");
   timeCompleted = System.currentTimeMillis();
   super.workCompleted(e);
   Work work = e.getWork();
   if (work instanceof NestProviderWork)
   {
      NestProviderWork nw = (NestProviderWork) work;
      done.append(nw.getName());
      exception = e.getException();
   }

}
 
Example 3
Source File: WorkWrapper.java    From ironjacamar with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Run
 */
public void run()
{
   ClassLoader oldCL = SecurityActions.getThreadContextClassLoader();
   SecurityActions.setThreadContextClassLoader(work.getClass().getClassLoader());

   org.ironjacamar.core.spi.security.SecurityContext oldSC = securityIntegration.getSecurityContext();

   try
   {
      start();
      workManager.addWorkWrapper(this);

      if (startedLatch != null)
         startedLatch.countDown();

      work.run();

      end();
   }
   catch (Throwable t)
   {
      exception = new WorkCompletedException(t.getMessage(), t);

      cancel();
   } 
   finally
   {
      workManager.removeWorkWrapper(this);
      work.release();

      if (workListener != null)
      {
         WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_COMPLETED, work, exception);
         workListener.workCompleted(event);
      }

      securityIntegration.setSecurityContext(oldSC);
      SecurityActions.setThreadContextClassLoader(oldCL);

      if (startedLatch != null)
      {
         while (startedLatch.getCount() != 0)
            startedLatch.countDown();
      }

      if (completedLatch != null)
         completedLatch.countDown();

      if (trace)
         log.tracef("Executed work: %s", this);
   }
}