private static BeanLockManager createBeanLockManager(Container container, boolean reentrant, String beanLock, ClassLoader cl) throws Exception { // The bean lock manager BeanLockManager lockManager = new BeanLockManager(container); Class lockClass = null; try { if (beanLock == null) beanLock = "org.jboss.ejb.plugins.lock.QueuedPessimisticEJBLock"; lockClass = cl.loadClass(beanLock); } catch (Exception e) { throw new DeploymentException("Missing or invalid lock class (in jboss.xml or standardjboss.xml): " + beanLock + " - " + e); } lockManager.setLockCLass(lockClass); lockManager.setReentrant(reentrant); return lockManager; }
throw new IllegalArgumentException("Attempt to get lock ref with a null object"); HashMap mapInUse = getHashMap(id); BeanLock lock2 = (BeanLock)createLock(id); synchronized(mapInUse)
/** * Create a new instance synchronization instance. */ InstanceSynchronization(Transaction tx, EntityEnterpriseContext ctx) { this.tx = tx; this.ctx = ctx; this.lock = container.getLockManager().getLock(ctx.getCacheKey()); }
BeanLock lock = getLockManager().getLock(id); lock.sync(); try getLockManager().removeLockRef(id);
protected boolean canPassivate(EnterpriseContext ctx) { if (ctx.isLocked()) { // The context is in the interceptor chain return false; } if (ctx.getTransaction() != null) { return false; } Object key = ((EntityEnterpriseContext)ctx).getCacheKey(); return m_container.getLockManager().canPassivate(key); }
container.getLockManager().removeLockRef(lock.getId());
public boolean canPassivate(Object id) { if (id == null) throw new IllegalArgumentException("Attempt to passivate with a null object"); HashMap mapInUse = getHashMap(id); synchronized (mapInUse) { BeanLock lock = (BeanLock) mapInUse.get(id); if (lock == null) throw new IllegalStateException("Attempt to passivate without a lock"); return (lock.getRefs() <= 1); } }
public void setLockManager(final BeanLockManager lockManager) { this.lockManager = lockManager; lockManager.setContainer(this); }
public void setContainer(Container container) { this.container = container; lockMonitor = container.getLockManager().getLockMonitor(); }
lock = container.getLockManager().getLock(key); try container.getLockManager().removeLockRef(key);
protected boolean canPassivate(EnterpriseContext ctx) { if(ctx.isLocked()) { // The context is in the interceptor chain return false; } if(ctx.getTransaction() != null) { return false; } Object key = ((EntityEnterpriseContext) ctx).getCacheKey(); return container.getLockManager().canPassivate(key); }
getContainer().getLockManager().removeLockRef(lock.getId()); throw ex;
throw new IllegalArgumentException("Attempt to remove lock ref with a null object"); HashMap mapInUse = getHashMap(id);
if(id != null) BeanLock lock = container.getLockManager().getLock(id); try container.getLockManager().removeLockRef(id);
protected boolean canPassivate(EnterpriseContext ctx) { if (ctx.isLocked()) { // The context is in the interceptor chain return false; } else if (m_container.getLockManager().canPassivate(ctx.getId()) == false) { return false; } else { if (ctx.getTransaction() != null) { try { return (ctx.getTransaction().getStatus() == Status.STATUS_NO_TRANSACTION); } catch (SystemException e) { // SA FIXME: not sure what to do here return false; } } } return true; }
container.getLockManager().removeLockRef(lock.getId()); container.popENC(); if(setCl)
public Object invokeHome(Invocation mi) throws Exception { EntityEnterpriseContext ctx = (EntityEnterpriseContext)mi.getEnterpriseContext(); Transaction tx = mi.getTransaction(); Object rtn = getNext().invokeHome(mi); // An anonymous context was sent in, so if it has an id it is a real instance now if(ctx.getId() != null) { // it doesn't need to be read, but it might have been changed from the db already. ctx.setValid(true); if(tx != null) { BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); try { lock.schedule(mi); register(ctx, tx); // Set tx lock.endInvocation(mi); } finally { container.getLockManager().removeLockRef(lock.getId()); } } } return rtn; }
BeanLock lock = getContainer().getLockManager().getLock(id); boolean lockedBean = false; try getContainer().getLockManager().removeLockRef(id);
EnterpriseContext ctx = null; BeanLock lock = container.getLockManager().getLock(methodID); boolean callerRunAsIdentityPresent = SecurityActions.peekRunAsIdentity() != null; boolean pushSecurityContext = SecurityActions.getSecurityContext() == null; container.getLockManager().removeLockRef(lock.getId()); if(!callerRunAsIdentityPresent && pushSecurityContext) SecurityActions.clearSecurityContext();
BeanLock lock = container.getLockManager().getLock(ctx.getCacheKey()); container.getLockManager().removeLockRef(ctx.getCacheKey());