Fields Summary |
---|
private static final Logger | logThe log |
private boolean | traceWhether we are tracing |
private javax.resource.spi.work.Work | workThe work |
private javax.resource.spi.work.ExecutionContext | executionContextThe execution context |
private javax.resource.spi.work.WorkListener | workListenerthe work listener |
private long | startTimeoutThe start timeout |
private JBossWorkManager | workManagerThe work manager |
private int | waitTypeThe wait type |
private long | blockedTimeThe blocked time |
private javax.resource.spi.work.WorkException | exceptionAny exception |
Methods Summary |
---|
public void | accepted(long time)
blockedTime = time;
if (trace)
log.trace("Accepted work " + this);
if (workListener != null)
{
WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_ACCEPTED, work, null);
workListener.workAccepted(event);
}
|
public void | completed(long time, java.lang.Throwable throwable)
if (waitType == WAIT_FOR_COMPLETE)
blockedTime = time;
if (throwable != null)
exception = new WorkCompletedException(throwable);
if (trace)
log.trace("Completed work " + this);
if (workListener != null)
{
WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_COMPLETED, work, exception);
workListener.workCompleted(event);
}
|
public void | execute()
if (trace)
log.trace("Executing work " + this);
try
{
workManager.startWork(this);
}
catch (WorkException e)
{
taskRejected(new NestedRuntimeException(e));
return;
}
try
{
work.run();
}
finally
{
workManager.endWork(this);
}
if (trace)
log.trace("Executed work " + this);
|
public long | getBlockedElapsed()Retrieve the time blocked
return blockedTime;
|
public long | getCompletionTimeout()
return executionContext.getTransactionTimeout();
|
public javax.resource.spi.work.ExecutionContext | getExecutionContext()Retrieve the exection context
return executionContext;
|
public int | getPriority()
return Thread.NORM_PRIORITY;
|
public long | getStartTimeout()
return startTimeout;
|
public int | getWaitType()
return waitType;
|
public javax.resource.spi.work.Work | getWork()Retrieve the work
return work;
|
public javax.resource.spi.work.WorkException | getWorkException()Get any exception
return exception;
|
public javax.resource.spi.work.WorkListener | getWorkListener()Retrieve the work listener
return workListener;
|
public JBossWorkManager | getWorkManager()Get the work manager
return workManager;
|
public void | rejected(long time, java.lang.Throwable throwable)
blockedTime = time;
if (trace)
{
if (throwable != null)
log.trace("Rejecting work " + this, throwable);
else
log.trace("Rejecting work " + this);
}
if (throwable != null)
{
exception = new WorkRejectedException(throwable);
if (throwable instanceof StartTimeoutException)
exception.setErrorCode(WorkRejectedException.START_TIMED_OUT);
}
workManager.cancelWork(this);
if (workListener != null)
{
WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_ACCEPTED, work, exception);
workListener.workRejected(event);
}
|
public void | started(long time)
if (waitType != WAIT_NONE)
blockedTime = time;
if (workListener != null)
{
WorkEvent event = new WorkEvent(workManager, WorkEvent.WORK_STARTED, work, null);
workListener.workStarted(event);
}
|
public void | stop()
if (trace)
log.trace("Stopping work " + this);
work.release();
|
public java.lang.String | toString()
JBossStringBuilder buffer = new JBossStringBuilder(100);
buffer.append("WorkWrapper@").append(Integer.toHexString(System.identityHashCode(this)));
buffer.append("[workManger=").append(workManager);
buffer.append(" work=").append(work);
buffer.append(" state=").append(getStateString());
if (executionContext != null && executionContext.getXid() != null)
{
buffer.append(" xid=").append(executionContext.getXid());
buffer.append(" txTimeout=").append(executionContext.getTransactionTimeout());
}
buffer.append(" waitType=");
switch (waitType)
{
case WAIT_NONE:
{
buffer.append("WAIT_NONE");
break;
}
case WAIT_FOR_START:
{
buffer.append("WAIT_FOR_START");
break;
}
case WAIT_FOR_COMPLETE:
{
buffer.append("WAIT_FOR_COMPLETE");
break;
}
default:
buffer.append("???");
}
if (startTimeout != WorkManager.INDEFINITE)
buffer.append(" startTimeout=").append(startTimeout);
long completionTimeout = getCompletionTimeout();
if (completionTimeout != -1)
buffer.append(" completionTimeout=").append(completionTimeout);
if (blockedTime != 0)
buffer.append(" blockTime=").append(blockedTime);
buffer.append(" elapsedTime=").append(getElapsedTime());
if (workListener != null)
buffer.append(" workListener=").append(workListener);
if (exception != null)
buffer.append(" exception=").append(exception);
buffer.append("]");
return buffer.toString();
|