Package javax.resource.spi.work

Examples of javax.resource.spi.work.WorkException


         result = verifyWorkMethods(workClass, RUN_METHOD_NAME, null, workClass.getName() +
                                    ": Run method is not defined");
    
         if (!result)
         {
            throw new WorkException(workClass.getName() + ": Run method is synchronized");
         }
     
         result = verifyWorkMethods(workClass, RELEASE_METHOD_NAME, null, workClass.getName() +
                                    ": Release method is not defined");
     
         if (!result)
         {
            throw new WorkException(workClass.getName() + ": Release method is synchronized");
         }

         validatedWork.add(work.getClass().getName());
      }
   }
View Full Code Here


            return false
         }
      }
      catch (NoSuchMethodException nsme)
      {
         throw new WorkException(errorMessage);
      }
     
      return true;
   }
View Full Code Here

    }
   
    @Override
    public void workRejected(WorkEvent e) {
        super.workRejected(e);
        WorkException we = e.getException();
        if (WorkException.START_TIMED_OUT.equals(we.getErrorCode()) && !isLowOnThreads) {
            setIsLowOnThreads(true);
            dispatch(theJob);
        }
    }
View Full Code Here

        });
        long t = System.currentTimeMillis();
        try {
            latch.await();
        } catch (InterruptedException e) {
            throw new WorkException("Interrupted", e);
        }
        return System.currentTimeMillis() - t;
    }
View Full Code Here

  protected long executeWork(TaskExecutor taskExecutor, Work work, long startTimeout,
      boolean blockUntilStarted, ExecutionContext executionContext, WorkListener workListener)
      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));
    }
View Full Code Here

    }

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

         }
         catch (Throwable t)
         {
            log.error("SecurityContext setup failed: " + t.getMessage(), t);
            fireWorkContextSetupFailed(ctx);
            throw new WorkException("SecurityContext setup failed: " + t.getMessage(), t);
         }
      }
      else if (securityContext != null && workManager.getCallbackSecurity() == null)
      {
         log.error("SecurityContext setup failed since CallbackSecurity was null");
         fireWorkContextSetupFailed(ctx);
         throw new WorkException("SecurityContext setup failed since CallbackSecurity was null");
      }
     
      //Fires Context setup complete
      fireWorkContextSetupComplete(ctx);
     
View Full Code Here

                      long startTimeout,
                      ExecutionContext execContext,
                      WorkListener workListener)
      throws WorkException
   {
      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException("Work is null");

         if (startTimeout < 0)
            throw new WorkRejectedException("StartTimeout is negative: " + startTimeout);

         checkAndVerifyWork(work, execContext);
     
         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         final CountDownLatch completedLatch = new CountDownLatch(1);

         wrapper = new WorkWrapper(this, work, execContext, workListener, null, completedLatch);

         setup(wrapper);

         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }

         completedLatch.await();
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
View Full Code Here

                         long startTimeout,
                         ExecutionContext execContext,
                         WorkListener workListener)
      throws WorkException
   {
      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException("Work is null");

         if (startTimeout < 0)
            throw new WorkRejectedException("StartTimeout is negative: " + startTimeout);

         long started = System.currentTimeMillis();

         checkAndVerifyWork(work, execContext);
     
         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         final CountDownLatch startedLatch = new CountDownLatch(1);

         wrapper = new WorkWrapper(this, work, execContext, workListener, startedLatch, null);

         setup(wrapper);

         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }

         startedLatch.await();

         return System.currentTimeMillis() - started;
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
View Full Code Here

                            long startTimeout,
                            ExecutionContext execContext,
                            WorkListener workListener)
      throws WorkException
   {
      WorkException exception = null;
      WorkWrapper wrapper = null;
      try
      {
         if (work == null)
            throw new WorkRejectedException("Work is null");

         if (startTimeout < 0)
            throw new WorkRejectedException("StartTimeout is negative: " + startTimeout);

         checkAndVerifyWork(work, execContext);
     
         if (execContext == null)
         {
            execContext = new ExecutionContext()
         }

         wrapper = new WorkWrapper(this, work, execContext, workListener, null, null);

         setup(wrapper);

         if (workListener != null)
         {
            WorkEvent event = new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null);
            workListener.workAccepted(event);
         }

         BlockingExecutor executor = getExecutor(work);

         if (startTimeout == WorkManager.INDEFINITE)
         {
            executor.executeBlocking(wrapper);
         }
         else
         {
            executor.executeBlocking(wrapper, startTimeout, TimeUnit.MILLISECONDS);
         }
      }
      catch (ExecutionTimedOutException etoe)
      {
         exception = new WorkRejectedException(etoe);
         exception.setErrorCode(WorkRejectedException.START_TIMED_OUT)
      }
      catch (RejectedExecutionException ree)
      {
         exception = new WorkRejectedException(ree);
      }
View Full Code Here

TOP

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

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.