本文整理汇总了Java中javax.resource.spi.work.WorkEvent类的典型用法代码示例。如果您正苦于以下问题:Java WorkEvent类的具体用法?Java WorkEvent怎么用?Java WorkEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WorkEvent类属于javax.resource.spi.work包,在下文中一共展示了WorkEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: run
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
@Override
public void run() {
if (this.acceptOnExecution) {
this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null));
}
synchronized (this.monitor) {
this.started = true;
this.monitor.notify();
}
this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null));
try {
this.work.run();
}
catch (RuntimeException ex) {
this.workListener.workCompleted(
new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex)));
throw ex;
}
catch (Error err) {
this.workListener.workCompleted(
new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(err)));
throw err;
}
this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null));
}
示例2: execute
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
void execute(final Work arg0, final WorkListener arg3, boolean join) throws WorkException {
if (arg3 != null) {
arg3.workAccepted(Mockito.mock(WorkEvent.class));
arg3.workStarted(Mockito.mock(WorkEvent.class));
}
t = new Thread(new Runnable() {
@Override
public void run() {
arg0.run();
if (arg3 != null) {
arg3.workCompleted(Mockito.mock(WorkEvent.class));
}
}
});
t.start();
if (join) {
try {
t.join();
} catch (InterruptedException e) {
throw new WorkException(e);
}
}
}
示例3: run
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
public void run() {
if (this.acceptOnExecution) {
this.workListener.workAccepted(new WorkEvent(this, WorkEvent.WORK_ACCEPTED, work, null));
}
synchronized (this.monitor) {
this.started = true;
this.monitor.notify();
}
this.workListener.workStarted(new WorkEvent(this, WorkEvent.WORK_STARTED, this.work, null));
try {
this.work.run();
}
catch (RuntimeException ex) {
this.workListener.workCompleted(
new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(ex)));
throw ex;
}
catch (Error err) {
this.workListener.workCompleted(
new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, new WorkCompletedException(err)));
throw err;
}
this.workListener.workCompleted(new WorkEvent(this, WorkEvent.WORK_COMPLETED, this.work, null));
}
示例4: workAccepted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* accept work
*
* @param e workEvent
*/
@Override
public void workAccepted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_ACCEPTED)
fail("Wrong accepted type");
source = e.getSource();
work = e.getWork();
startDuration = e.getStartDuration();
exception = e.getException();
if (callbackCount != null)
{
synchronized (this)
{
callbackCount.setAcceptCount(callbackCount.getAcceptCount() + 1);
}
}
super.workAccepted(e);
}
示例5: workStarted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* start work
*
* @param e workEvent
*/
@Override
public void workStarted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_STARTED)
fail("Wrong started type");
if (callbackCount != null)
{
synchronized (this)
{
callbackCount.setStartCount(callbackCount.getStartCount() + 1);
}
}
super.workStarted(e);
}
示例6: workRejected
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* start work
*
* @param e workEvent
*/
@Override
public void workRejected(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_REJECTED)
fail("Wrong rejected type");
source = e.getSource();
work = e.getWork();
startDuration = e.getStartDuration();
exception = e.getException();
if (callbackCount != null)
{
synchronized (this)
{
callbackCount.setRejectedCount(callbackCount.getRejectedCount() + 1);
}
}
super.workRejected(e);
}
示例7: workCompleted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* complete work
*
* @param e workEvent
*/
@Override
public void workCompleted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_COMPLETED)
fail("Wrong completed type");
if (callbackCount != null)
{
synchronized (this)
{
callbackCount.setCompletedCount(callbackCount.getCompletedCount() + 1);
}
}
super.workCompleted(e);
}
示例8: workStarted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* start work
*
* @param e workEvent
*/
@Override
public void workStarted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_STARTED)
fail("Wrong started type");
timeStarted = System.currentTimeMillis();
super.workStarted(e);
Work work = e.getWork();
if (work instanceof NestProviderWork)
{
NestProviderWork nw = (NestProviderWork) work;
start.append(nw.getName());
}
}
示例9: workRejected
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* 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());
}
}
示例10: workCompleted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* complete work
*
* @param e workEvent
*/
@Override
public void workCompleted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_COMPLETED)
fail("Wrong completed type");
timeCompleted = System.currentTimeMillis();
super.workCompleted(e);
Work work = e.getWork();
if (work instanceof NestProviderWork)
{
NestProviderWork nw = (NestProviderWork) work;
done.append(nw.getName());
exception = e.getException();
}
}
示例11: workAccepted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
@Override
public void workAccepted(WorkEvent arg0) {
}
示例12: startWork
import javax.resource.spi.work.WorkEvent; //导入依赖的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();
}
示例13: workRejected
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
public void workRejected(WorkEvent event) {
if (this.delegate != null) {
delegate.workRejected(event);
}
}
示例14: workStarted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
public void workStarted(WorkEvent event) {
if (this.delegate != null) {
delegate.workStarted(event);
}
this.startedTime = System.currentTimeMillis();
this.signalStarted();
}
示例15: workAccepted
import javax.resource.spi.work.WorkEvent; //导入依赖的package包/类
/**
* accept work
*
* @param e workEvent
*/
@Override
public void workAccepted(WorkEvent e)
{
if (e.getType() != WorkEvent.WORK_ACCEPTED)
fail("Wrong accepted type");
timeAccepted = System.currentTimeMillis();
super.workAccepted(e);
}