FileDocCategorySizeDatePackage
JBossWorkManager.javaAPI DocJBoss 4.2.16089Fri Jul 13 20:53:50 BST 2007org.jboss.ejb3.embedded.resource

JBossWorkManager

public class JBossWorkManager extends Object implements javax.resource.spi.work.WorkManager
version
$Revision: 60233 $
author
William DeCoste

Fields Summary
private static final Logger
log
private org.jboss.util.threadpool.ThreadPool
threadPool
private org.jboss.tm.JBossXATerminator
xaTerminator
The xa terminator
private ObjectName
xaTerminatorName
The xa terminator name
Constructors Summary
Methods Summary
protected voidcancelWork(WorkWrapper wrapper)
Cancel work

param
wrapper the work wrapper
throws
WorkException for any error

      ExecutionContext ctx = wrapper.getExecutionContext();
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            xaTerminator.cancelWork(wrapper.getWork(), xid);
         }
      }
   
public voiddoWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext ctx, javax.resource.spi.work.WorkListener listener)

      if (ctx == null)
         ctx = new ExecutionContext();
      WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_FOR_COMPLETE, startTimeout, ctx, listener);
      importWork(wrapper);
      executeWork(wrapper);
      if (wrapper.getWorkException() != null)
         throw wrapper.getWorkException();
   
public voiddoWork(javax.resource.spi.work.Work work)

      doWork(work, WorkManager.INDEFINITE, null, null);
   
protected voidendWork(WorkWrapper wrapper)
End work

param
wrapper the work wrapper
throws
WorkException for any error

      ExecutionContext ctx = wrapper.getExecutionContext();
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            xaTerminator.endWork(wrapper.getWork(), xid);
         }
      }
   
protected voidexecuteWork(WorkWrapper wrapper)
Execute the work

param
wrapper the work wrapper
throws
WorkException for any error

      threadPool.runTaskWrapper(wrapper);
   
public javax.resource.spi.work.WorkManagergetInstance()

      return this;
   
public javax.management.ObjectNamegetXATerminatorName()


     
   
      return xaTerminatorName;
   
protected voidimportWork(WorkWrapper wrapper)
Import any work

param
wrapper the work wrapper
throws
WorkException for any error

      ExecutionContext ctx = wrapper.getExecutionContext();
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            long timeout = ctx.getTransactionTimeout();
            xaTerminator.registerWork(wrapper.getWork(), xid, timeout);
         }
      }
   
public voidscheduleWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext ctx, javax.resource.spi.work.WorkListener listener)

      if (ctx == null)
         ctx = new ExecutionContext();
      WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_NONE, startTimeout, ctx, listener);
      importWork(wrapper);
      executeWork(wrapper);
      if (wrapper.getWorkException() != null)
         throw wrapper.getWorkException();
   
public voidscheduleWork(javax.resource.spi.work.Work work)

      scheduleWork(work, WorkManager.INDEFINITE, null, null);
   
public voidsetXATerminatorName(javax.management.ObjectName xaTerminatorName)

      this.xaTerminatorName = xaTerminatorName;
   
protected voidstartWork(WorkWrapper wrapper)
Start work

param
wrapper the work wrapper
throws
WorkException for any error

      ExecutionContext ctx = wrapper.getExecutionContext();
      if (ctx != null)
      {
         Xid xid = ctx.getXid();
         if (xid != null)
         {
            xaTerminator.startWork(wrapper.getWork(), xid);
         }
      }
   
public longstartWork(javax.resource.spi.work.Work work, long startTimeout, javax.resource.spi.work.ExecutionContext ctx, javax.resource.spi.work.WorkListener listener)

      if (ctx == null)
         ctx = new ExecutionContext();
      WorkWrapper wrapper = new WorkWrapper(this, work, Task.WAIT_FOR_START, startTimeout, ctx, listener);
      importWork(wrapper);
      executeWork(wrapper);
      if (wrapper.getWorkException() != null)
         throw wrapper.getWorkException();
      return wrapper.getBlockedElapsed();
   
public longstartWork(javax.resource.spi.work.Work work)

      return startWork(work, WorkManager.INDEFINITE, null, null);