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.ejb3.cache;
023:
024: import javax.ejb.EJBException;
025: import org.jboss.ejb3.Container;
026: import org.jboss.ejb3.stateful.StatefulBeanContext;
027:
028: /**
029: * Stateful StatelessBean Bean cache
030: *
031: * @author <a href="mailto:bill@jboss.org">Bill Burke</a>
032: * @version $Revision: 61329 $
033: */
034: public interface StatefulCache {
035: /**
036: * returns a key not the actual object
037: */
038: public StatefulBeanContext create();
039:
040: public StatefulBeanContext create(Class[] initTypes,
041: Object[] initValues);
042:
043: /**
044: * Gets the context with the given id.
045: * <p/>
046: * Same as <code>getContext(key, true)</code>
047: *
048: * @param key the id
049: * @return the context
050: *
051: * @throws NoSuchEJBException if no context with the given id exists or
052: * if the context exists but has been marked
053: * as removed
054: * @throws EJBException
055: */
056: public StatefulBeanContext get(Object key) throws EJBException;
057:
058: /**
059: * Get the context with the given id, optionally marking the context as
060: * being in use.
061: *
062: * @param key the context's id
063: * @param markInUse if <code>true</code>, marks any returned context as
064: * being in use. If <code>false</code>, will return
065: * contexts that are marked as removed; otherwise will
066: * throw NoSuchEJBException if such a context is found
067: *
068: * @return the context
069: *
070: * @throws NoSuchEJBException if no context with the given id exists or
071: * if the context exists but has been marked
072: * as removed and <code>markInUse</code> is
073: * <code>true</code>
074: * @throws EJBException
075: */
076: public StatefulBeanContext get(Object key, boolean markInUse)
077: throws EJBException;
078:
079: public void remove(Object key);
080:
081: public void finished(StatefulBeanContext ctx);
082:
083: public void initialize(Container container) throws Exception;
084:
085: void start();
086:
087: void stop();
088:
089: int getCacheSize();
090:
091: int getTotalSize();
092:
093: int getCreateCount();
094:
095: int getPassivatedCount();
096:
097: int getRemoveCount();
098:
099: int getAvailableCount();
100:
101: int getMaxSize();
102:
103: int getCurrentSize();
104: }
|