本文整理汇总了Java中javax.resource.spi.work.WorkException类的典型用法代码示例。如果您正苦于以下问题:Java WorkException类的具体用法?Java WorkException怎么用?Java WorkException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WorkException类属于javax.resource.spi.work包,在下文中一共展示了WorkException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startWork
import javax.resource.spi.work.WorkException; //导入依赖的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: execute
import javax.resource.spi.work.WorkException; //导入依赖的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: start
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
public void start() {
resourceAdapterCustomImpl = new ResourceAdapterCustomImpl(this);
try {
eisConnection = new EisConnectionWorker();
workManager.startWork(eisConnection);
try {
boolean bf = eisConnection.waitForStartupReady(10000);
log.debug("eisConnection={} bf={} isStartupReadyFlag={} isShutdownFlag={}", eisConnection, bf, eisConnection.isStartupReadyFlag(), eisConnection.isShutdownFlag());
} catch (InterruptedException e) {
log.warn("", e);
}
} catch (WorkException ex) {
log.debug("", ex);
}
}
示例4: invoke
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
private void invoke(final MessageEndpoint endpoint, final Method m, final Path path) throws WorkException {
resourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new Work() {
@Override
public void run() {
try {
Method endpointMethod = endpoint.getClass().getMethod(m.getName(), m.getParameterTypes());
endpoint.beforeDelivery(endpointMethod);
endpointMethod.invoke(endpoint, path.toFile());
endpoint.afterDelivery();
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void release() {}
});
}
示例5: testCannotDeclaredSynchronizedRunMethodWork
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* Test for paragraph 5
* Both the run and release methods in the Work implementation may contain synchronization
* synchronization but they must not be declared as synchronized methods.
* @throws Throwable throwable exception
*/
@Test(expected = WorkException.class)
public void testCannotDeclaredSynchronizedRunMethodWork() throws Throwable
{
SynchronizedRunWork sw = new SynchronizedRunWork();
WorkConnection wc = wcf.getConnection();
try
{
wc.doWork(sw);
fail("Synchronized method not catched");
}
finally
{
wc.close();
}
}
示例6: testCannotDeclaredSynchronizedReleaseMethodWork
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* Test for paragraph 5
* Both the run and release methods in the Work implementation may contain synchronization
* synchronization but they must not be declared as synchronized methods.
* @throws Throwable throwable exception
*/
@Test(expected = WorkException.class)
public void testCannotDeclaredSynchronizedReleaseMethodWork() throws Throwable
{
SynchronizedReleaseWork sw = new SynchronizedReleaseWork();
WorkConnection wc = wcf.getConnection();
try
{
wc.doWork(sw);
fail("Synchronized method not catched");
}
finally
{
wc.close();
}
}
示例7: doWork
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void doWork(Work work) throws WorkException
{
if (policy == null || selector == null || transport == null ||
work == null || !(work instanceof DistributableWork) || !doWorkDistributionEnabled)
{
localDoWork(work);
}
else
{
doFirstChecks(work, WorkManager.INDEFINITE, null);
checkTransport();
DistributableWork dw = (DistributableWork)work;
boolean executed = false;
if (policy.shouldDistribute(this, dw))
{
Address dwmAddress = selector.selectDistributedWorkManager(getLocalAddress(), dw);
if (dwmAddress != null && !getLocalAddress().equals(dwmAddress))
{
transport.doWork(dwmAddress, dw);
executed = true;
}
}
if (!executed)
{
localDoWork(work);
}
}
}
示例8: checkTransport
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* Check the transport
* @exception WorkException In case of an error
*/
private void checkTransport() throws WorkException
{
if (!transport.isInitialized())
{
try
{
transport.initialize();
initialize();
}
catch (Throwable t)
{
WorkException we = new WorkException("Exception during transport initialization");
we.initCause(t);
throw we;
}
}
}
示例9: deltaDoWorkAccepted
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaDoWorkAccepted()
{
if (trace)
log.trace("deltaDoWorkAccepted");
super.deltaDoWorkAccepted();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaDoWorkAccepted();
}
catch (WorkException we)
{
log.debugf("deltaDoWorkAccepted: %s", we.getMessage(), we);
}
}
}
示例10: deltaDoWorkRejected
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaDoWorkRejected()
{
if (trace)
log.trace("deltaDoWorkRejected");
super.deltaDoWorkRejected();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaDoWorkRejected();
}
catch (WorkException we)
{
log.debugf("deltaDoWorkRejected: %s", we.getMessage(), we);
}
}
}
示例11: deltaStartWorkAccepted
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaStartWorkAccepted()
{
if (trace)
log.trace("deltaStartWorkAccepted");
super.deltaStartWorkAccepted();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaStartWorkAccepted();
}
catch (WorkException we)
{
log.debugf("deltaStartWorkAccepted: %s", we.getMessage(), we);
}
}
}
示例12: deltaStartWorkRejected
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaStartWorkRejected()
{
if (trace)
log.trace("deltaStartWorkRejected");
super.deltaStartWorkRejected();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaStartWorkRejected();
}
catch (WorkException we)
{
log.debugf("deltaStartWorkRejected: %s", we.getMessage(), we);
}
}
}
示例13: deltaScheduleWorkAccepted
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaScheduleWorkAccepted()
{
if (trace)
log.trace("deltaScheduleWorkAccepted");
super.deltaScheduleWorkAccepted();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaScheduleWorkAccepted();
}
catch (WorkException we)
{
log.debugf("deltaScheduleWorkAccepted: %s", we.getMessage(), we);
}
}
}
示例14: deltaScheduleWorkRejected
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaScheduleWorkRejected()
{
if (trace)
log.trace("deltaScheduleWorkRejected");
super.deltaScheduleWorkRejected();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaScheduleWorkRejected();
}
catch (WorkException we)
{
log.debugf("deltaScheduleWorkRejected: %s", we.getMessage(), we);
}
}
}
示例15: deltaWorkSuccessful
import javax.resource.spi.work.WorkException; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void deltaWorkSuccessful()
{
if (trace)
log.trace("deltaWorkSuccessful");
super.deltaWorkSuccessful();
if (distributedStatisticsEnabled && distributedStatistics != null && transport != null)
{
try
{
checkTransport();
distributedStatistics.sendDeltaWorkSuccessful();
}
catch (WorkException we)
{
log.debugf("deltaWorkSuccessful: %s", we.getMessage(), we);
}
}
}