Implementation of a no passivation cache policy.
| Method from org.jboss.ejb.plugins.NoPassivationCachePolicy Detail: |
public void create() throws Exception {
m_map = new HashMap();
}
|
public void destroy() {
synchronized (m_map)
{
m_map.clear();
}
}
|
public void flush() {
if (flushEnabled)
{
synchronized (m_map)
{
m_map.clear();
}
}
}
|
public Object get(Object key) {
if (key == null)
{
throw new IllegalArgumentException("Requesting an object using a null key");
}
EnterpriseContext ctx = null;
synchronized (m_map)
{
ctx = (EnterpriseContext) m_map.get(key);
}
return ctx;
}
|
public void importXml(Element element) throws DeploymentException {
String flushString = MetaData.getElementContent(MetaData.getOptionalChild(element, "flush-enabled"));
flushEnabled = Boolean.valueOf(flushString).booleanValue();
}
|
public void insert(Object key,
Object ctx) {
if (ctx == null)
{
throw new IllegalArgumentException("Cannot insert a null object in the cache");
}
if (key == null)
{
throw new IllegalArgumentException("Cannot insert an object in the cache with null key");
}
synchronized (m_map)
{
Object obj = m_map.get(key);
if (obj == null)
{
m_map.put(key, ctx);
}
else
{
throw new IllegalStateException("Attempt to put in the cache an object that is already there");
}
}
}
|
public Object peek(Object key) {
return get(key);
}
|
public void remove(Object key) {
if (key == null)
{
throw new IllegalArgumentException("Removing an object using a null key");
}
synchronized (m_map)
{
Object value = m_map.get(key);
if (value != null)
{
m_map.remove(key);
}
else
{
throw new IllegalArgumentException("Cannot remove an object that isn't in the cache");
}
}
}
|
public void sample(Object s) {
if(m_map == null)
return;
synchronized(m_map)
{
BeanCacheSnapshot snapshot = (BeanCacheSnapshot)s;
snapshot.m_passivatingBeans = 0;
snapshot.m_cacheMinCapacity = 0;
snapshot.m_cacheMaxCapacity = Integer.MAX_VALUE;
snapshot.m_cacheCapacity = Integer.MAX_VALUE;
snapshot.m_cacheSize = m_map.size();
}
}
|
public int size() {
synchronized (m_map)
{
return m_map.size();
}
}
|
public void start() throws Exception {
}
|
public void stop() {
}
|