Package javax.resource.spi.work

Examples of javax.resource.spi.work.WorkListener


        // We get here because we need to start a async worker.
        log.debug("Starting run.");
        try {
            workManager.scheduleWork(this, WorkManager.INDEFINITE, null,
                    new WorkListener() {
                        //The work listener is useful only for debugging...
                        public void workAccepted(WorkEvent event) {
                            log.debug("Work accepted: " + event);
                        }
View Full Code Here


      throws WorkException {

    if (executionContext != null && executionContext.getXid() != null) {
      throw new WorkException("SimpleTaskWorkManager does not supported imported XIDs: " + executionContext.getXid());
    }
    WorkListener workListenerToUse = workListener;
    if (workListenerToUse == null) {
      workListenerToUse = new WorkAdapter();
    }

    boolean isAsync = (taskExecutor instanceof AsyncTaskExecutor);
    DelegatingWorkAdapter workHandle = new DelegatingWorkAdapter(work, workListenerToUse, !isAsync);
    try {
      if (isAsync) {
        ((AsyncTaskExecutor) taskExecutor).execute(workHandle, startTimeout);
      }
      else {
        taskExecutor.execute(workHandle);
      }
    }
    catch (TaskTimeoutException ex) {
      WorkException wex = new WorkRejectedException("TaskExecutor rejected Work because of timeout: " + work, ex);
      wex.setErrorCode(WorkException.START_TIMED_OUT);
      workListenerToUse.workRejected(new WorkEvent(this, WorkEvent.WORK_REJECTED, work, wex));
      throw wex;
    }
    catch (TaskRejectedException ex) {
      WorkException wex = new WorkRejectedException("TaskExecutor rejected Work: " + work, ex);
      wex.setErrorCode(WorkException.INTERNAL);
      workListenerToUse.workRejected(new WorkEvent(this, WorkEvent.WORK_REJECTED, work, wex));
      throw wex;
    }
    catch (Throwable ex) {
      WorkException wex = new WorkException("TaskExecutor failed to execute Work: " + work, ex);
      wex.setErrorCode(WorkException.INTERNAL);
      throw wex;
    }
    if (isAsync) {
      workListenerToUse.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null));
    }

    if (blockUntilStarted) {
      long acceptanceTime = System.currentTimeMillis();
      synchronized (workHandle.monitor) {
View Full Code Here

        }

        // We get here because we need to start a async worker.
        log.debug("Starting run.");
        try {
            workManager.scheduleWork(this, WorkManager.INDEFINITE, null, new WorkListener() {
                // The work listener is useful only for debugging...
                public void workAccepted(WorkEvent event) {
                    log.debug("Work accepted: " + event);
                }
View Full Code Here

        }

        // We get here because we need to start a async worker.
        log.debug("Starting run.");
        try {
            workManager.scheduleWork(this, WorkManager.INDEFINITE, null, new WorkListener() {
                // The work listener is useful only for debugging...
                public void workAccepted(WorkEvent event) {
                    log.debug("Work accepted: " + event);
                }
View Full Code Here

        // We get here because we need to start a async worker.
        log.debug("ServerSession queuing request for a run.");
        try {
            workManager.scheduleWork(this, WorkManager.INDEFINITE, null,
                    new WorkListener() {
                        //The work listener is useful only for debugging...
                        public void workAccepted(WorkEvent event) {
                            log.debug("Work accepted: " + event);
                        }
View Full Code Here

        }

        // We get here because we need to start a async worker.
        log.debug("Starting run.");
        try {
            workManager.scheduleWork(this, WorkManager.INDEFINITE, null, new WorkListener() {
                // The work listener is useful only for debugging...
                public void workAccepted(WorkEvent event) {
                    log.debug("Work accepted: " + event);
                }
View Full Code Here

    public void delegatesParameterizedDoWork() throws WorkException
    {
        Work work = mock(Work.class);
        int startTimeout = 10;
        ExecutionContext execContext = mock(ExecutionContext.class);
        WorkListener workListener = mock(WorkListener.class);

        trackingWorkManager.doWork(work, startTimeout, execContext, workListener);

        verify(delegateWorkManager).doWork(work, startTimeout, execContext, workListener);
    }
View Full Code Here

    public void tracksWorkOnDoParameterizedWorkDelegation() throws Exception
    {
        Work work = mock(Work.class);
        int startTimeout = 10;
        ExecutionContext execContext = mock(ExecutionContext.class);
        WorkListener workListener = mock(WorkListener.class);

        trackingWorkManager.doWork(work, startTimeout, execContext, workListener);

        assertParameterizedWorkWasTracked(work, startTimeout, execContext, workListener);
    }
View Full Code Here

    public void untracksWorkOnDoParameterizedWorkException() throws Exception
    {
        Work work = mock(Work.class);
        int startTimeout = 10;
        ExecutionContext execContext = mock(ExecutionContext.class);
        WorkListener workListener = mock(WorkListener.class);

        doThrow(new WorkException()).when(delegateWorkManager).doWork(work, startTimeout, execContext, workListener);

        try
        {
View Full Code Here

    public void startsParameterizedWork() throws WorkException
    {
        final Work work = mock(Work.class);
        long startTimeout = 0;
        ExecutionContext execContext = mock(ExecutionContext.class);
        WorkListener workListener = mock(WorkListener.class);

        doAnswer(new Answer()
        {
            @Override
            public Object answer(InvocationOnMock invocation) throws Throwable
View Full Code Here

TOP

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

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.