AbstractEntityBeanCollection
程序员文章站
2024-03-12 21:58:32
...
以容器方式保存钝化是EntityBeans
package org.jboss.seam.contexts;
abstract class AbstractEntityBeanCollection implements Wrapper
{
private transient boolean initialized; //是否初始化
protected AbstractEntityBeanCollection()
{
initialized = true;
}
public final void activate()
{ //if all passivatedentities not null && any verions check
if ( isPassivatedEntitiesInitialized() && isAnyVersioned() )
{
activateAll();
initialized = true;
}
else
{
initialized = false;
}
}
public final Object getInstance()
{ //未初始化 && 实体是否初始化
// false or true true
if ( !initialized && isPassivatedEntitiesInitialized() )
{
activateAll();
}
initialized = true;
return getEntityCollection(); //获取容器保存所有的钝化实体,可能为SET LIST MAP
}
public final boolean passivate()
{
if ( PassivatedEntity.isTransactionRolledBackOrMarkedRollback() )//事务是否标记为回滚
{
clearPassivatedEntities(); //set passivated entities null
}
else
{
passivateAll();
}
return true;
}
/**
* 任何钝化实体具有版本check
*/
private boolean isAnyVersioned()
{
for ( PassivatedEntity passivatedEntity: getPassivatedEntities() )
{
if ( passivatedEntity!=null && passivatedEntity.isVersioned() ) return true;
}
return false;
}
protected abstract void activateAll();
protected abstract void passivateAll();
protected abstract Iterable<PassivatedEntity> getPassivatedEntities();
protected abstract void clearPassivatedEntities();
protected abstract boolean isPassivatedEntitiesInitialized();
protected abstract Object getEntityCollection();
}
上一篇: php头像上传预览实例代码
下一篇: Java8 时间类常用方法