Wraps the resource adapter's work.
| Method from org.jboss.resource.work.WorkWrapper Detail: |
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,
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() {
return blockedTime;
}
Retrieve the time blocked |
public long getCompletionTimeout() {
return executionContext.getTransactionTimeout();
}
|
public ExecutionContext getExecutionContext() {
return executionContext;
}
Retrieve the exection context |
public int getPriority() {
return Thread.NORM_PRIORITY;
}
|
public long getStartTimeout() {
return startTimeout;
}
|
public int getWaitType() {
return waitType;
}
|
public Work getWork() {
return work;
}
|
public WorkException getWorkException() {
return exception;
}
|
public WorkListener getWorkListener() {
return workListener;
}
Retrieve the work listener |
public JBossWorkManager getWorkManager() {
return workManager;
}
|
public void rejected(long time,
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 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();
}
|