001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.ejb;
023:
024: import java.rmi.RemoteException;
025: import java.rmi.NoSuchObjectException;
026:
027: /**
028: * The plugin that gives a container a cache for bean instances.
029: *
030: * @author <a href="mailto:rickard.oberg@telkel.com">Rickard Öberg</a>
031: * @author <a href="mailto:simone.bordet@compaq.com">Simone Bordet</a>
032: * @version $Revision: 57209 $
033: */
034: public interface InstanceCache extends ContainerPlugin {
035: /**
036: * Gets a bean instance from this cache given the identity. This method
037: * may involve activation if the instance is not in the cache.
038: *
039: * <p>Implementation should have O(1) complexity.
040: *
041: * <p>This method is never called for stateless session beans.
042: *
043: * @param id The primary key of the bean .
044: * @return The EnterpriseContext related to the given id.
045: *
046: * @throws RemoteException In case of illegal calls (concurrent /
047: * reentrant)
048: * @throws NoSuchObjectException if the bean cannot be found.
049: *
050: * @see #release
051: */
052: EnterpriseContext get(Object id) throws RemoteException,
053: NoSuchObjectException;
054:
055: /**
056: * Inserts an active bean instance after creation or activation.
057: *
058: * <p>Implementation should guarantee proper locking and O(1) complexity.
059: *
060: * @param ctx The EnterpriseContext to insert in the cache
061: *
062: * @see #remove
063: */
064: void insert(EnterpriseContext ctx);
065:
066: /**
067: * Releases the given bean instance from this cache.
068: * This method may passivate the bean to get it out of the cache.
069: * Implementation should return almost immediately leaving the
070: * passivation to be executed by another thread.
071: *
072: * @param ctx The EnterpriseContext to release
073: *
074: * @see #get
075: */
076: void release(EnterpriseContext ctx);
077:
078: /**
079: * Removes a bean instance from this cache given the identity.
080: * Implementation should have O(1) complexity and guarantee proper locking.
081: *
082: * @param id The pimary key of the bean.
083: *
084: * @see #insert
085: */
086: void remove(Object id);
087:
088: /**
089: * Checks whether an instance corresponding to a particular id is active.
090: *
091: * @param id The pimary key of the bean.
092: *
093: * @see #insert
094: */
095: boolean isActive(Object id);
096:
097: /** Get the current cache size
098: *
099: * @return the size of the cache
100: */
101: long getCacheSize();
102:
103: /** Flush the cache.
104: *
105: */
106: void flush();
107: }
|