use of javax.resource.spi.work.Work in project teiid by teiid.
the class TestThreadReuseExecutor method testFailingWork.
@Test
public void testFailingWork() throws Exception {
// $NON-NLS-1$
pool = new ThreadReuseExecutor("test", 5);
final Semaphore signal = new Semaphore(1);
pool.execute(new Work() {
@Override
public void run() {
signal.release();
throw new RuntimeException();
}
@Override
public void release() {
}
});
assertTrue(signal.tryAcquire(2, TimeUnit.SECONDS));
}
use of javax.resource.spi.work.Work in project narayana by jbosstm.
the class TxWorkManager method addWork.
/*
* Although we allow multiple units of work per transaction, currently
* JCA only allows one. Might not be worth the hassle of maintaing this
* support.
*/
/**
* Add the specified work unit to the specified transaction.
*
* @param work The work to associate with the transaction.
* @param tx The transaction to have associated with the work.
*
* @throws WorkCompletedException thrown if there is already work
* associated with the transaction.
*/
public static void addWork(Work work, Transaction tx) throws WorkCompletedException {
Stack<Work> workers;
synchronized (_transactions) {
workers = _transactions.get(tx);
if (workers == null) {
workers = new Stack<Work>();
_transactions.put(tx, workers);
} else
throw new WorkCompletedException(jtaLogger.i18NLogger.get_transaction_arjunacore_jca_busy(), WorkException.TX_CONCURRENT_WORK_DISALLOWED);
}
synchronized (workers) {
workers.push(work);
}
}
use of javax.resource.spi.work.Work in project javaee7-samples by javaee-samples.
the class WatchingThread method invoke.
private void invoke(final MessageEndpoint endpoint, final Method beanClassMethod, final Path path) throws WorkException {
out.println("Watch thread scheduling endpoint call via workmanager for method: " + beanClassMethod.getName() + " and file" + path.getFileName());
resourceAdapter.getBootstrapContext().getWorkManager().scheduleWork(new Work() {
@Override
public void run() {
try {
try {
endpoint.beforeDelivery(beanClassMethod);
beanClassMethod.invoke(endpoint, path.toFile());
} finally {
endpoint.afterDelivery();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void release() {
}
});
}
use of javax.resource.spi.work.Work in project wildfly by wildfly.
the class TelnetResourceAdapter method endpointActivation.
@Override
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException {
final TelnetActivationSpec telnetActivationSpec = (TelnetActivationSpec) activationSpec;
final MessageEndpoint messageEndpoint = messageEndpointFactory.createEndpoint(null);
// This messageEndpoint instance is also castable to the ejbClass of the MDB
final TelnetListener telnetListener = (TelnetListener) messageEndpoint;
try {
final TelnetServer telnetServer = new TelnetServer(telnetActivationSpec, telnetListener, port);
workManager.scheduleWork(new Work() {
@Override
public void release() {
}
@Override
public void run() {
try {
telnetServer.activate();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}, 0, null, null);
activated.put(port, telnetServer);
} catch (IOException e) {
throw new ResourceException(e);
}
}
use of javax.resource.spi.work.Work in project cxf by apache.
the class ResourceAdapterImpl method endpointActivation.
public void endpointActivation(MessageEndpointFactory mef, ActivationSpec as) throws ResourceException {
if (!(as instanceof MDBActivationSpec)) {
LOG.fine("Ignored unknown activation spec " + as);
return;
}
MDBActivationSpec spec = (MDBActivationSpec) as;
LOG.info("CXF resource adapter is activating " + spec.getDisplayName());
Work work = new MDBActivationWork(spec, mef, endpoints);
ctx.getWorkManager().scheduleWork(work);
}
Aggregations