本文整理汇总了Java中javax.resource.spi.work.ExecutionContext类的典型用法代码示例。如果您正苦于以下问题:Java ExecutionContext类的具体用法?Java ExecutionContext怎么用?Java ExecutionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExecutionContext类属于javax.resource.spi.work包,在下文中一共展示了ExecutionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@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);
}
示例2: testThrowWorkCompletedException
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* Test for bullet 4 Section 3.3.6
* When the application server is unable to recreate an execution context if it is
* specified for the submitted Work instance, it must throw a
* WorkCompletedException set to an appropriate error code.
* @throws Throwable throwable exception
*/
@Test(expected = WorkCompletedException.class)
public void testThrowWorkCompletedException() throws Throwable
{
ExecutionContext ec = new ExecutionContext();
ShortRunningWork work = new ShortRunningWork();
ec.setXid(new XidImpl());
ec.setTransactionTimeout(Long.MAX_VALUE);
WorkConnection wc = wcf.getConnection();
try
{
wc.doWork(work, WorkManager.INDEFINITE, ec, null);
}
finally
{
wc.close();
}
}
示例3: end
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* End
*/
protected void end()
{
if (trace)
log.tracef("Ending work: %s", this);
ExecutionContext ctx = getWorkContext(TransactionContext.class);
if (ctx == null)
{
ctx = getExecutionContext();
}
if (ctx != null)
{
Xid xid = ctx.getXid();
if (xid != null)
{
workManager.getXATerminator().endWork(work, xid);
}
}
if (trace)
log.tracef("Ended work: %s", this);
}
示例4: cancel
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* Cancel
*/
protected void cancel()
{
if (trace)
log.tracef("Cancel work: %s", this);
ExecutionContext ctx = getWorkContext(TransactionContext.class);
if (ctx == null)
{
ctx = getExecutionContext();
}
if (ctx != null)
{
Xid xid = ctx.getXid();
if (xid != null)
{
workManager.getXATerminator().cancelWork(work, xid);
}
}
if (trace)
log.tracef("Canceled work: %s", this);
}
示例5: doWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@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);
}
示例6: scheduleWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@Override
public void scheduleWork(Work work, long startTimeout, ExecutionContext executionContext, WorkListener workListener)
throws WorkException {
Assert.state(this.asyncTaskExecutor != null, "No 'asyncTaskExecutor' set");
executeWork(this.asyncTaskExecutor, work, startTimeout, false, executionContext, workListener);
}
示例7: startWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@Override
public long startWork(Work work,
long l,
ExecutionContext executionContext,
WorkListener workListener) throws WorkException {
return 0;
}
示例8: startWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
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();
}
示例9: scheduleWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
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: doFirstChecks
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* 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);
}
示例11: checkAndVerifyWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* 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());
}
}
示例12: WorkWrapper
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
/**
* 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;
}
示例13: doWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@Override
public void doWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
throws WorkException {
this.workManager.doWork(work, delay, executionContext, workListener);
}
示例14: startWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@Override
public long startWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
throws WorkException {
return this.workManager.startWork(work, delay, executionContext, workListener);
}
示例15: scheduleWork
import javax.resource.spi.work.ExecutionContext; //导入依赖的package包/类
@Override
public void scheduleWork(Work work, long delay, ExecutionContext executionContext, WorkListener workListener)
throws WorkException {
this.workManager.scheduleWork(work, delay, executionContext, workListener);
}