KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mx > persistence > AttributePersistenceManager


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.mx.persistence;
23
24 import javax.management.AttributeList JavaDoc;
25
26 import org.w3c.dom.Element JavaDoc;
27 /**
28  * AttributePersistenceManager interface.
29  *
30  * Implementations of this interface are created by an
31  * MBean service that acts as factory and a manager
32  * for the active AttributePersistenceManager implementation
33  *
34  * The DelegatingPersistenceManager will contact the MBean
35  * to get an AttributePersistenceManager implementation.
36  *
37  * In this way, the Persistence Manager can be controlled
38  * externally as an MBean.
39  *
40  * @author <a HREF="mailto:dimitris@jboss.org">Dimitris Andreadis</a>
41  * @version $Revision: 37459 $
42  */

43 public interface AttributePersistenceManager
44 {
45    // AttributePersistenceManager lifecycle -------------------------
46

47    /**
48     * Initializes the AttributePersistenceManager using
49     * the supplied configuration element CONFIG_ELEMENT
50     * whose content will be probably different for each
51     * particular implementation.
52     *
53     * The version string is a tag that must be used by the
54     * AttributePersistenceManager implementation to make
55     * sure that data saved/loaded under different version
56     * tags are partitioned. It can be null or empty to
57     * indicate that no particular version tag is required.
58     *
59     * Once created, the configuration of the implementation
60     * object cannot change.
61     *
62     * Calling any other method before create() is executed
63     * will result in a IllegalStateException
64     *
65     * Finally, the implementation should be prepared to
66     * receive multiple concurrent calls.
67     *
68     * @param version a tag to identify the version
69     * @param config XML Element to load arbitrary config
70     * @throws Exception when any error occurs during create
71     */

72    public void create(String JavaDoc version, Element JavaDoc config)
73       throws Exception JavaDoc;
74
75    /**
76     * Returns true if the AttributePersistenceManager
77     * is "in-service" state, i.e. after create() and
78     * before destroy() has been called, false otherwise.
79     *
80     * @return true if in operational state
81     */

82    public boolean getState();
83    
84    /**
85     * Releases resources and destroys the AttributePersistenceManager.
86     * The object is unusable after destroy() has been called.
87     *
88     * Any call to any method will result to an
89     * IllegalStateException.
90     *
91     */

92    public void destroy();
93    
94    // AttributePersistenceManager Persistence -----------------------
95

96    /**
97     * Checks if a persistened AttributeList for this particular
98     * id exists
99     *
100     * @param id the key of the image
101     * @return true if an image exists; false otherwise
102     * @throws Exception on any error
103     */

104    public boolean exists(String JavaDoc id)
105       throws Exception JavaDoc;
106
107    /**
108     * Uses the specified id to retrieve a previously persisted
109     * AttributeList. If no data can be found under the specified
110     * id, a null will be returned.
111     *
112     * @param id the key for retrieving the data
113     * @return the data, or null
114     * @throws Exception when an error occurs
115     */

116    public AttributeList JavaDoc load(String JavaDoc id)
117       throws Exception JavaDoc;
118    
119    /**
120     * Persists an AttributeList (name/value pair list),
121     * under a specified id. The id can be used to retrieve the
122     * AttributeList later on. The actual mechanism will differ
123     * among implementations.
124     *
125     * @param id the key for retrieving the data later on, not null
126     * @param attrs the data to be persisted, not null
127     * @throws Exception when data cannot be persisted
128     */

129    public void store(String JavaDoc id, AttributeList JavaDoc attrs)
130       throws Exception JavaDoc;
131    
132    /**
133     * Removes the persisted AttributeList, if exists
134     *
135     * @param id the key of the image
136     * @throws Exception when any error occurs
137     */

138    public void remove(String JavaDoc id)
139       throws Exception JavaDoc;
140    
141    /**
142     * Removes all the persisted data stored under
143     * the configured version tag.
144     *
145     * @throws Exception when any error occurs
146     */

147    public void removeAll()
148       throws Exception JavaDoc;
149    
150    /**
151     * Returns a String array with all the saved ids
152     * under the configured version tag.
153     *
154     * @return array with all persisted ids
155     * @throws Exception when any error occurs
156     */

157    public String JavaDoc[] listAll()
158       throws Exception JavaDoc;
159    
160 }
161
Popular Tags