Java 类javax.ejb.ConcurrentAccessException 实例源码

项目:tomee    文件:StatelessPoolStatsTest.java   
/**
 * Requires an invocation against a maxed pool with all instances checked out, must be a strict pool
 * javax.management.MBeanAttributeInfo[description=, name=AccessTimeouts, type=long, read-only, descriptor={}]
 *
 * @throws Exception On error
 */
public void testAccessTimeouts() throws Exception {
    final Properties properties = new Properties();
    properties.put("MaxSize", "10");
    properties.put("AccessTimeout", "0");
    properties.put("StrictPooling", "true");

    final CounterBean bean = deploy("testAccessTimeouts", properties);

    assertAttribute("AccessTimeouts", 0l);

    final Checkout checkout = checkout(bean, 10);

    for (int i = 0; i < 7; i++) {
        try {
            bean.doSomething();
            fail("ConcurrentAccessException should have been thrown");
        } catch (final ConcurrentAccessException expected) {
        }
    }

    checkout.release();

    assertAttribute("AccessTimeouts", 7l);
}
项目:sinkit-core    文件:CacheBuilderEJB.java   
@Asynchronous
@Override
public Future<Integer> runCacheRebuilding() throws ConcurrentAccessException {

    if (!cacheRebuilding.compareAndSet(false, true)) {
        log.info("Cache rebuilding still in process -> skipping");
        throw new ConcurrentAccessException("Cache rebuilding already in progress...");
    }

    try {
        return new AsyncResult<>(this.rebuildCache());
    } finally {
        cacheRebuilding.set(false);
    }
}
项目:sinkit-core    文件:CacheBuilder.java   
Future<Integer> runCacheRebuilding() throws ConcurrentAccessException;