org.springframework.core.task.TaskRejectedException#javax.resource.spi.work.Work源码实例Demo

下面列出了org.springframework.core.task.TaskRejectedException#javax.resource.spi.work.Work 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ironjacamar   文件: ContextWorkAdapter.java
/**
 * start work 
 *
 * @param e workEvent
 */
@Override
public void workRejected(WorkEvent e)
{
   if (e.getType() != WorkEvent.WORK_REJECTED)
      fail("Wrong rejected type");
   timeRejected = System.currentTimeMillis();
   super.workRejected(e);
   Work work = e.getWork();
   if (work instanceof NestProviderWork)
   {
      NestProviderWork nw = (NestProviderWork) work;
      reject.append(nw.getName());
   }

}
 
源代码2 项目: ironjacamar   文件: WorkWrapper.java
/**
 * Create a new WorkWrapper
 *
 * @param workManager the work manager
 * @param si The security integration
 * @param work the work
 * @param executionContext the execution context
 * @param workListener the WorkListener
 * @param startedLatch The latch for when work has started
 * @param completedLatch The latch for when work has completed
 * @param startTime The start time
 * @throws IllegalArgumentException for null work, execution context or a negative start timeout
 */
public WorkWrapper(WorkManagerImpl workManager, 
                   SecurityIntegration si,
                   Work work,
                   ExecutionContext executionContext,
                   WorkListener workListener,
                   CountDownLatch startedLatch,
                   CountDownLatch completedLatch,
                   long startTime)
{
   super();

   if (workManager == null)
      throw new IllegalArgumentException("Null work manager");
   if (si == null)
      throw new IllegalArgumentException("Null security integration");
   if (work == null)
      throw new IllegalArgumentException("Null work");
   if (executionContext == null)
      throw new IllegalArgumentException("Null execution context");

   this.workManager = workManager;
   this.securityIntegration = si;
   this.work = work;
   this.executionContext = executionContext;
   this.workListener = workListener;
   this.startedLatch = startedLatch;
   this.completedLatch = completedLatch;
   this.startTime = startTime;
   this.workContexts = null;
}
 
源代码3 项目: ByteJTA   文件: SimpleWorkManager.java
public long startWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener)
		throws WorkException {
	SimpleWorkListener wrappedListener = new SimpleWorkListener(workListener);
	wrappedListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null));
	SimpleWork task = new SimpleWork();
	task.setSource(this);
	task.setWork(work);
	task.setWorkListener(wrappedListener);
	this.executor.submit(task);
	return wrappedListener.waitForStart();
}
 
@Override
public void scheduleWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
 
源代码5 项目: ByteJTA   文件: ResourceAdapterImpl.java
public void stop() {
	for (int i = 0; this.workList != null && i < this.workList.size(); i++) {
		Work work = this.workList.get(i);
		try {
			work.release();
		} catch (RuntimeException rex) {
			logger.debug(rex.getMessage(), rex);
		}
	}
}
 
@Override
public long startWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	return executeWork(this.asyncTaskExecutor, work, startTimeout, true, executionContext, workListener);
}
 
源代码7 项目: ironjacamar   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
@Override
public void scheduleWork(Work work) throws WorkException
{
   if (policy == null || selector == null || transport == null ||
       work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled)
   {
      localScheduleWork(work);
   }
   else
   {
      doFirstChecks(work, WorkManager.INDEFINITE, null);
      checkTransport();

      DistributableWork dw = (DistributableWork)work;
      boolean executed = false;

      if (policy.shouldDistribute(this, dw))
      {
         Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw);
         if (dwmAddress != null && !getLocalAddress().equals(dwmAddress))
         {
            transport.scheduleWork(dwmAddress, dw);
            executed = true;
         }
      }

      if (!executed)
      {
         localScheduleWork(work);
      }
   }
}
 
@Override
public void scheduleWork(Work work, long startTimeout, @Nullable ExecutionContext executionContext, @Nullable WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
 
源代码9 项目: ByteJTA   文件: SimpleWorkManager.java
public void scheduleWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener)
		throws WorkException {
	// SimpleWorkListener wrappedListener = new SimpleWorkListener(workListener);
	// wrappedListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null));
	// SimpleWork task = new SimpleWork();
	// task.setSource(this);
	// task.setWork(work);
	// task.setWorkListener(wrappedListener);
	// // ScheduledFuture<?> future =
	// this.scheduled.scheduleAtFixedRate(task, 0, 1000, TimeUnit.MILLISECONDS);
	throw new WorkException("not supported yet!");
}
 
源代码10 项目: lams   文件: SimpleTaskWorkManager.java
@Override
public long startWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
	return executeWork(this.asyncTaskExecutor, work, startTimeout, true, executionContext, workListener);
}
 
源代码11 项目: activemq-artemis   文件: ActiveMQRATestBase.java
@Override
public long startWork(Work work,
                      long l,
                      ExecutionContext executionContext,
                      WorkListener workListener) throws WorkException {
   return 0;
}
 
源代码12 项目: ironjacamar   文件: WorkManagerImpl.java
/**
 * Do first checks for work starting methods
 * @param work to check
 * @param startTimeout to check
 * @param execContext to check
 * @throws WorkException in case of check don't pass
 */
public void doFirstChecks(Work work, long startTimeout, ExecutionContext execContext) throws WorkException
{
   if (isShutdown())
      throw new WorkRejectedException(bundle.workmanagerShutdown());

   if (work == null)
      throw new WorkRejectedException(bundle.workIsNull());

   if (startTimeout < 0)
      throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout));

   checkAndVerifyWork(work, execContext);
}
 
源代码13 项目: ironjacamar   文件: WorkManagerImpl.java
/**
 * Fire complete for HintsContext
 * @param work The work instance
 */
private void fireHintsComplete(Work work)
{
   if (work != null && work instanceof WorkContextProvider)
   {
      WorkContextProvider wcProvider = (WorkContextProvider) work;
      List<WorkContext> contexts = wcProvider.getWorkContexts();

      if (contexts != null && !contexts.isEmpty())
      {
         Iterator<WorkContext> it = contexts.iterator();
         while (it.hasNext())
         {
            WorkContext wc = it.next();
            if (wc instanceof HintsContext)
            {
               HintsContext hc = (HintsContext) wc;
               if (hc instanceof WorkContextLifecycleListener)
               {
                  WorkContextLifecycleListener listener = (WorkContextLifecycleListener)hc;
                  listener.contextSetupComplete();   
               }
            }
         }
      }
   }
}
 
源代码14 项目: ironjacamar   文件: WorkManagerImpl.java
/**
 * Check and verify work before submitting.
 * @param work the work instance
 * @param executionContext any execution context that is passed by apadater
 * @throws WorkException if any exception occurs
 */
private void checkAndVerifyWork(Work work, ExecutionContext executionContext) throws WorkException
{
   if (specCompliant)
   {
      verifyWork(work);
   }

   if (work instanceof WorkContextProvider && executionContext != null)
   {
      //Implements WorkContextProvider and not-null ExecutionContext
      throw new WorkRejectedException(bundle.workExecutionContextMustNullImplementsWorkContextProvider());
   }
}
 
源代码15 项目: lams   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
public void localDoWork(Work work) throws WorkException
{
   if (transport != null)
   {
      checkTransport();

      if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work))
      {
         transport.updateLongRunningFree(getLocalAddress(),
                                         getLongRunningThreadPool().getNumberOfFreeThreads() - 1);
      }
      else
      {
         transport.updateShortRunningFree(getLocalAddress(),
                                          getShortRunningThreadPool().getNumberOfFreeThreads() - 1);
      }

      WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work),
                                                    getShortRunningThreadPool(),
                                                    getLongRunningThreadPool(),
                                                    getLocalAddress(),
                                                    transport);

      super.doWork(work, WorkManager.INDEFINITE, null, wel);
   }
   else
   {
      super.doWork(work);
   }
}
 
源代码16 项目: lams   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
public long localStartWork(Work work) throws WorkException
{
   if (transport != null)
   {
      checkTransport();

      if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work))
      {
         transport.updateLongRunningFree(getLocalAddress(),
                                         getLongRunningThreadPool().getNumberOfFreeThreads() - 1);
      }
      else
      {
         transport.updateShortRunningFree(getLocalAddress(),
                                          getShortRunningThreadPool().getNumberOfFreeThreads() - 1);
      }

      WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work),
                                                    getShortRunningThreadPool(),
                                                    getLongRunningThreadPool(),
                                                    getLocalAddress(),
                                                    transport);

      return super.startWork(work, WorkManager.INDEFINITE, null, wel);
   }
   else
   {
      return super.startWork(work);
   }
}
 
源代码17 项目: lams   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
@Override
public void doWork(Work work) throws WorkException
{
   if (policy == null || selector == null || transport == null ||
       work == null || !(work instanceof DistributableWork) || !doWorkDistributionEnabled)
   {
      localDoWork(work);
   }
   else
   {
      doFirstChecks(work, WorkManager.INDEFINITE, null);
      checkTransport();

      DistributableWork dw = (DistributableWork)work;
      boolean executed = false;

      if (policy.shouldDistribute(this, dw))
      {
         Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw);
         if (dwmAddress != null && !getLocalAddress().equals(dwmAddress))
         {
            transport.doWork(dwmAddress, dw);
            executed = true;
         }
      }

      if (!executed)
      {
         localDoWork(work);
      }
   }
}
 
@Override
public void doWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	Assert.state(this.syncTaskExecutor != null, "No 'syncTaskExecutor' set");
	executeWork(this.syncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
 
源代码19 项目: lams   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
@Override
public void scheduleWork(Work work) throws WorkException
{
   if (policy == null || selector == null || transport == null ||
       work == null || !(work instanceof DistributableWork) || !scheduleWorkDistributionEnabled)
   {
      localScheduleWork(work);
   }
   else
   {
      doFirstChecks(work, WorkManager.INDEFINITE, null);
      checkTransport();

      DistributableWork dw = (DistributableWork)work;
      boolean executed = false;

      if (policy.shouldDistribute(this, dw))
      {
         Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw);
         if (dwmAddress != null && !getLocalAddress().equals(dwmAddress))
         {
            transport.scheduleWork(dwmAddress, dw);
            executed = true;
         }
      }

      if (!executed)
      {
         localScheduleWork(work);
      }
   }
}
 
源代码20 项目: lams   文件: WorkManagerImpl.java
/**
 * Do first checks for work starting methods
 * @param work to check
 * @param startTimeout to check
 * @param execContext to check
 * @throws WorkException in case of check don't pass
 */
public void doFirstChecks(Work work, long startTimeout, ExecutionContext execContext) throws WorkException
{
   if (isShutdown())
      throw new WorkRejectedException(bundle.workmanagerShutdown());

   if (work == null)
      throw new WorkRejectedException(bundle.workIsNull());

   if (startTimeout < 0)
      throw new WorkRejectedException(bundle.startTimeoutIsNegative(startTimeout));

   checkAndVerifyWork(work, execContext);
}
 
源代码21 项目: lams   文件: WorkManagerImpl.java
/**
 * Get the executor
 * @param work The work instance
 * @return The executor
 */
private BlockingExecutor getExecutor(Work work)
{
   BlockingExecutor executor = shortRunningExecutor;
   if (longRunningExecutor != null && WorkManagerUtil.isLongRunning(work))
   {
      executor = longRunningExecutor;
   }

   fireHintsComplete(work);

   return executor;
}
 
源代码22 项目: lams   文件: WorkManagerImpl.java
/**
 * Fire complete for HintsContext
 * @param work The work instance
 */
private void fireHintsComplete(Work work)
{
   if (work != null && work instanceof WorkContextProvider)
   {
      WorkContextProvider wcProvider = (WorkContextProvider) work;
      List<WorkContext> contexts = wcProvider.getWorkContexts();

      if (contexts != null && contexts.size() > 0)
      {
         Iterator<WorkContext> it = contexts.iterator();
         while (it.hasNext())
         {
            WorkContext wc = it.next();
            if (wc instanceof HintsContext)
            {
               HintsContext hc = (HintsContext) wc;
               if (hc instanceof WorkContextLifecycleListener)
               {
                  WorkContextLifecycleListener listener = (WorkContextLifecycleListener)hc;
                  listener.contextSetupComplete();   
               }
            }
         }
      }
   }
}
 
源代码23 项目: lams   文件: WorkWrapper.java
/**
 * Create a new WorkWrapper
 *
 * @param workManager the work manager
 * @param si The security integration
 * @param work the work
 * @param executionContext the execution context
 * @param workListener the WorkListener
 * @param startedLatch The latch for when work has started
 * @param completedLatch The latch for when work has completed
 * @param startTime The start time
 * @throws IllegalArgumentException for null work, execution context or a negative start timeout
 */
public WorkWrapper(WorkManagerImpl workManager, 
                   SecurityIntegration si,
                   Work work, 
                   ExecutionContext executionContext, 
                   WorkListener workListener,
                   CountDownLatch startedLatch,
                   CountDownLatch completedLatch,
                   long startTime)
{
   super();

   if (workManager == null)
      throw new IllegalArgumentException("Null work manager");
   if (si == null)
      throw new IllegalArgumentException("Null security integration");
   if (work == null)
      throw new IllegalArgumentException("Null work");
   if (executionContext == null)
      throw new IllegalArgumentException("Null execution context");

   this.workManager = workManager;
   this.securityIntegration = si;
   this.work = work;
   this.executionContext = executionContext;
   this.workListener = workListener;
   this.startedLatch = startedLatch;
   this.completedLatch = completedLatch;
   this.startTime = startTime;
   this.workContexts = null;
}
 
源代码24 项目: ironjacamar   文件: DistributedWorkManagerImpl.java
/**
 * {@inheritDoc}
 */
public void localDoWork(Work work) throws WorkException
{
   if (transport != null)
   {
      checkTransport();

      if (getLongRunningThreadPool() != null && WorkManagerUtil.isLongRunning(work))
      {
         transport.updateLongRunningFree(getLocalAddress(),
                                         getLongRunningThreadPool().getNumberOfFreeThreads() - 1);
      }
      else
      {
         transport.updateShortRunningFree(getLocalAddress(),
                                          getShortRunningThreadPool().getNumberOfFreeThreads() - 1);
      }

      WorkEventListener wel = new WorkEventListener(WorkManagerUtil.isLongRunning(work),
                                                    getShortRunningThreadPool(),
                                                    getLongRunningThreadPool(),
                                                    getLocalAddress(),
                                                    transport);

      super.doWork(work, WorkManager.INDEFINITE, null, wel);
   }
   else
   {
      super.doWork(work);
   }
}
 
@Override
public void doWork(Work work) throws WorkException {
	obtainWorkManager().doWork(work);
}
 
@Override
public void doWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
		throws WorkException {

	obtainWorkManager().doWork(work, delay, executionContext, workListener);
}
 
源代码27 项目: ironjacamar   文件: WorkConnectionImpl.java
/**
 * {@inheritDoc}
 */
public void doWork(Work work, long startTimeout, ExecutionContext execContext, WorkListener workListener)
   throws WorkException
{
   mc.doWork(work, startTimeout, execContext, workListener);
}
 
@Override
public void scheduleWork(Work work) throws WorkException {
	obtainWorkManager().scheduleWork(work);
}
 
源代码29 项目: ironjacamar   文件: WorkConnectionImpl.java
/**
 * {@inheritDoc}
 */
public void doWork(Work work) throws WorkException
{
   mc.doWork(work);
}
 
@Override
public void scheduleWork(Work work) throws WorkException {
	scheduleWork(work, WorkManager.INDEFINITE, null, null);
}