use of java.util.concurrent.locks.ReentrantReadWriteLock in project jena by apache.
the class TestTDBInternal method exclusive_2.
@Test
public void exclusive_2() {
DatasetGraph dsg = TDBFactory.createDatasetGraph();
TransactionManager txnmgr = TDBInternal.getTransactionManager(dsg);
checkTxnMgr(txnmgr, 0, 0);
ReentrantReadWriteLock rwx = (ReentrantReadWriteLock) txnmgr.getExclusivityLock$();
checkLock(rwx, 0, 0);
dsg.begin(ReadWrite.READ);
checkLock(rwx, 1, 0);
checkTxnMgr(txnmgr, 1, 0);
dsg.end();
checkLock(rwx, 0, 0);
checkTxnMgr(txnmgr, 0, 0);
}
use of java.util.concurrent.locks.ReentrantReadWriteLock in project tomee by apache.
the class SingletonInstanceManager method createInstance.
private Instance createInstance(final ThreadContext callContext, final BeanContext beanContext) throws ApplicationException {
try {
initializeDependencies(beanContext);
final InstanceContext context = beanContext.newInstance();
if (context.getBean() instanceof SessionBean) {
final Operation originalOperation = callContext.getCurrentOperation();
try {
callContext.setCurrentOperation(Operation.CREATE);
final Method create = beanContext.getCreateMethod();
final InterceptorStack ejbCreate = new InterceptorStack(context.getBean(), create, Operation.CREATE, new ArrayList<InterceptorData>(), new HashMap());
ejbCreate.invoke();
} finally {
callContext.setCurrentOperation(originalOperation);
}
}
final ReadWriteLock lock;
if (beanContext.isBeanManagedConcurrency()) {
// Bean-Managed Concurrency
lock = new BeanManagedLock();
} else {
// Container-Managed Concurrency
lock = new ReentrantReadWriteLock();
}
return new Instance(context.getBean(), context.getInterceptors(), context.getCreationalContext(), lock);
} catch (Throwable e) {
if (e instanceof InvocationTargetException) {
e = ((InvocationTargetException) e).getTargetException();
}
final String t = "The bean instance " + beanContext.getDeploymentID() + " threw a system exception:" + e;
logger.error(t, e);
throw new ApplicationException(new NoSuchEJBException("Singleton failed to initialize").initCause(e));
}
}
Aggregations