KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb > InstanceCache


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.ejb;
23
24 import java.rmi.RemoteException JavaDoc;
25 import java.rmi.NoSuchObjectException JavaDoc;
26
27 /**
28  * The plugin that gives a container a cache for bean instances.
29  *
30  * @author <a HREF="mailto:rickard.oberg@telkel.com">Rickard Öberg</a>
31  * @author <a HREF="mailto:simone.bordet@compaq.com">Simone Bordet</a>
32  * @version $Revision: 37459 $
33  */

34 public interface InstanceCache
35    extends ContainerPlugin
36 {
37    /**
38     * Gets a bean instance from this cache given the identity. This method
39     * may involve activation if the instance is not in the cache.
40     *
41     * <p>Implementation should have O(1) complexity.
42     *
43     * <p>This method is never called for stateless session beans.
44     *
45     * @param id The primary key of the bean .
46     * @return The EnterpriseContext related to the given id.
47     *
48     * @throws RemoteException In case of illegal calls (concurrent /
49     * reentrant)
50     * @throws NoSuchObjectException if the bean cannot be found.
51     *
52     * @see #release
53     */

54    EnterpriseContext get(Object JavaDoc id)
55       throws RemoteException JavaDoc, NoSuchObjectException JavaDoc;
56
57    /**
58     * Inserts an active bean instance after creation or activation.
59     *
60     * <p>Implementation should guarantee proper locking and O(1) complexity.
61     *
62     * @param ctx The EnterpriseContext to insert in the cache
63     *
64     * @see #remove
65     */

66    void insert(EnterpriseContext ctx);
67
68    /**
69     * Releases the given bean instance from this cache.
70     * This method may passivate the bean to get it out of the cache.
71     * Implementation should return almost immediately leaving the
72     * passivation to be executed by another thread.
73     *
74     * @param ctx The EnterpriseContext to release
75     *
76     * @see #get
77     */

78    void release(EnterpriseContext ctx);
79
80    /**
81     * Removes a bean instance from this cache given the identity.
82     * Implementation should have O(1) complexity and guarantee proper locking.
83     *
84     * @param id The pimary key of the bean.
85     *
86     * @see #insert
87     */

88    void remove(Object JavaDoc id);
89
90    /**
91     * Checks whether an instance corresponding to a particular id is active.
92     *
93     * @param id The pimary key of the bean.
94     *
95     * @see #insert
96     */

97    boolean isActive(Object JavaDoc id);
98
99    /** Get the current cache size
100     *
101     * @return the size of the cache
102     */

103    long getCacheSize();
104    /** Flush the cache.
105     *
106     */

107    void flush();
108 }
109
Popular Tags