Package javax.resource.spi.work

Examples of javax.resource.spi.work.WorkEvent


      if (trace)
         log.trace("Completed work " + this);

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


    private final TrackerWorkListener trackerWorkListener = new TrackerWorkListener(work, delegate);

    @Test
    public void notifiesWorkAccepted()
    {
        WorkEvent workEvent = createWorkEvent(WorkEvent.WORK_ACCEPTED);

        trackerWorkListener.workAccepted(workEvent);

        verify(delegate).workAccepted(anAcceptedWorkEventFor(this, work, workException, START_DURATION));
    }
View Full Code Here

    }

    @Test
    public void notifiesWorkCompleted()
    {
        WorkEvent workEvent = createWorkEvent(WorkEvent.WORK_COMPLETED);

        trackerWorkListener.workCompleted(workEvent);

        verify(delegate).workCompleted(aCompletedWorkEventFor(this, work, workException, START_DURATION));
    }
View Full Code Here

    }

    @Test
    public void notifiesWorkRejected()
    {
        WorkEvent workEvent = createWorkEvent(WorkEvent.WORK_REJECTED);

        trackerWorkListener.workRejected(workEvent);

        verify(delegate).workRejected(aRejectedWorkEventFor(this, work, workException, START_DURATION));
    }
View Full Code Here

        verify(delegate).workStarted(aStartedWorkEventFor(this, work, workException, START_DURATION));
    }

    private WorkEvent createWorkEvent(int type)
    {
        return new WorkEvent(this, type, originalWork, workException, START_DURATION);
    }
View Full Code Here

        delegate.workCompleted(unwrapWorkEvent(e));
    }

    private WorkEvent unwrapWorkEvent(WorkEvent e)
    {
        return new WorkEvent(e.getSource(), e.getType(), work, e.getException(), e.getStartDuration());
    }
View Full Code Here

        }
    }

    private WorkEvent getTestWorkEvent()
    {
        WorkEvent event = new WorkEvent(this, // source
            WorkEvent.WORK_REJECTED, getTestWork(), new WorkException(new Throwable("testThrowable")));
        return event;
    }
View Full Code Here

     *            work executor.
     */
    public synchronized void workAccepted(Object anObject)
    {
        acceptedTime = System.currentTimeMillis();
        workListener.workAccepted(new WorkEvent(anObject, WorkEvent.WORK_ACCEPTED, worker, null));
    }
View Full Code Here

                         + " retries have been performed.");
        }
        if (isTimeout)
        {
            workException = new WorkRejectedException(this + " has timed out.", WorkException.START_TIMED_OUT);
            workListener.workRejected(new WorkEvent(this, WorkEvent.WORK_REJECTED, worker, workException));
            return true;
        }
        retryCount++;
        return isTimeout;
    }
View Full Code Here

            return;
        }
        // Implementation note: the work listener is notified prior to release
        // the start lock. This behavior is intentional and seems to be the
        // more conservative.
        workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, worker, null));
        startLatch.countDown();
        // Implementation note: we assume this is being called without an
        // interesting TransactionContext,
        // and ignore/replace whatever is associated with the current thread.
        try
        {
            final ClassLoader originalCl = Thread.currentThread().getContextClassLoader();
            try
            {
                // execute with the application or domain specific classloader in the context
                Thread.currentThread().setContextClassLoader(executionClassLoader);
                worker.run();
            }
            finally
            {
                Thread.currentThread().setContextClassLoader(originalCl);
            }
            workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, worker, null));
        }
        catch (Throwable e)
        {
            workException = (WorkException)(e instanceof WorkCompletedException
                            ? e : new WorkCompletedException("Unknown error",
                                WorkCompletedException.UNDEFINED).initCause(e));
            workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_REJECTED, worker, workException));
        }
        finally
        {
            RequestContext.clear();
            TransactionCoordination.getInstance().clear();
View Full Code Here

TOP

Related Classes of javax.resource.spi.work.WorkEvent

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.