KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jdo > spi > persistence > support > sqlstore > ejb > JDOEJB11Helper


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24
25
26 /*
27  * JDOEJB11Helper.java
28  *
29  * Created on January 17, 2002
30  */

31
32 package com.sun.jdo.spi.persistence.support.sqlstore.ejb;
33
34 import java.util.Collection JavaDoc;
35 import java.util.Set JavaDoc;
36
37 import javax.ejb.EJBObject JavaDoc;
38
39 import com.sun.jdo.api.persistence.support.PersistenceManager;
40 import com.sun.jdo.spi.persistence.support.sqlstore.utility.NumericConverter;
41
42 /**
43  * This is the helper interface for conversion of persistence-capable instances
44  * to and from EJB objects of type: EJBObject, PrimaryKey, and Collections of those.
45  * This interface is generic for CMP1.1 and CMP2.0.
46  *
47  * @author Marina Vatkina
48  */

49 public interface JDOEJB11Helper {
50
51     /**
52      * Converts persistence-capable instance to EJBObject.
53      * @param pc the persistence-capable instance to be converted as an Object.
54      * @param pm the associated instance of PersistenceManager.
55      * @return instance of EJBObject.
56      */

57     EJBObject JavaDoc convertPCToEJBObject (Object JavaDoc pc, PersistenceManager pm);
58
59     /**
60      * Converts EJBObject to persistence-capable instance.
61      * @param o the EJBObject instance to be converted.
62      * @param pm the associated instance of PersistenceManager.
63      * @param validate true if the existence of the instance is to be validated.
64      * @return persistence-capable instance.
65      * @throw IllegalArgumentException if validate is true and instance does
66      * not exist in the database or is deleted.
67      */

68     Object JavaDoc convertEJBObjectToPC(EJBObject JavaDoc o, PersistenceManager pm, boolean validate);
69
70     /**
71      * Converts Collection of persistence-capable instances to a Collection of
72      * EJBObjects.
73      * @param pcs the Collection of persistence-capable instance to be converted.
74      * @param pm the associated instance of PersistenceManager.
75      * @return Collection of EJBObjects.
76      */

77     Collection JavaDoc convertCollectionPCToEJBObject (Collection JavaDoc pcs, PersistenceManager pm);
78
79     /**
80      * Converts Collection of persistence-capable instances to a Set of
81      * EJBObjects.
82      * @param pcs the Collection of persistence-capable instance to be converted.
83      * @param pm the associated instance of PersistenceManager.
84      * @return Set of EJBObjects.
85      */

86     Set JavaDoc convertCollectionPCToEJBObjectSet (Collection JavaDoc pcs, PersistenceManager pm);
87
88     /**
89      * Converts Collection of EJBObjects to a Collection of
90      * persistence-capable instances.
91      * @param coll the Collection of EJBObject instances to be converted.
92      * @param pm the associated instance of PersistenceManager.
93      * @param validate true if the existence of the instances is to be validated.
94      * @return Collection of persistence-capable instance.
95      * @throw IllegalArgumentException if validate is true and at least one instance does
96      * not exist in the database or is deleted.
97      */

98     Collection JavaDoc convertCollectionEJBObjectToPC (Collection JavaDoc coll, PersistenceManager pm,
99         boolean validate);
100
101     /**
102      * Converts persistence-capable instance to an instance of the PrimaryKey Class.
103      * @param pc the persistence-capable instance to be converted as an Object.
104      * @param pm the associated instance of PersistenceManager.
105      * @return instance of the PrimaryKey Class.
106      */

107     Object JavaDoc convertPCToPrimaryKey (Object JavaDoc pc, PersistenceManager pm);
108
109     /**
110      * Converts Collection of persistence-capable instances to a Collection of
111      * the PrimaryKey Class instances.
112      * @param pcs Collection of the persistence-capable instances.
113      * @param pm the associated instance of PersistenceManager.
114      * @return Collection of the PrimaryKey Class instances.
115      */

116     Collection JavaDoc convertCollectionPCToPrimaryKey (Collection JavaDoc pcs, PersistenceManager pm);
117
118    /**
119      * Converts Object Id of a persistence-capable instance to an instance of the
120      * PrimaryKey Class.
121      * @param objectId the Object Id to be converted.
122      * @return instance of the PrimaryKey Class.
123      */

124     Object JavaDoc convertObjectIdToPrimaryKey (Object JavaDoc objectId);
125
126    /**
127      * Converts instance of a PrimaryKey Class to an instance of the Object Id of a
128      * corresponding persistence-capable Class.
129      * @param key the PrimaryKey instance to be converted.
130      * @return instance of the Object Id.
131      */

132     Object JavaDoc convertPrimaryKeyToObjectId (Object JavaDoc key);
133
134    /**
135      * Converts Collection of Object Id's of persistence-capable instances to a
136      * Collection of of the PrimaryKey instances.
137      * @param oids Collection of the Object Id to be converted.
138      * @return Collection of of the PrimaryKey Class instances.
139      */

140     Collection JavaDoc convertCollectionObjectIdToPrimaryKey (Collection JavaDoc oids);
141
142    /**
143      * Converts Collection of PrimaryKey instances to a Collection of Object Id's
144      * of a corresponding persistence-capable Class.
145      * @param keys Collection of the PrimaryKey instances to be converted.
146      * @return Collection of the Object Id's.
147      */

148     Collection JavaDoc convertCollectionPrimaryKeyToObjectId (Collection JavaDoc key);
149
150     /**
151      * Returns the class object of the corresponding persistence-capable class
152      * of the concrete bean class.
153      * @return the pc class object
154      */

155     Class JavaDoc getPCClass ();
156
157     /**
158      * Serializes serializableObject into a byte array
159      * @param serializableObject Instance of a Serializable Object
160      * @return serializableObject serialized into a byte array
161      */

162     byte[] writeSerializableObjectToByteArray(java.io.Serializable JavaDoc serializableObject);
163
164     /**
165      * Constructs a Serializable object from byteArray. It is expected that
166      * byteArray was constructed using a previous call to writeSerializableObjectToByteArray
167      * @param byteArray Array of byte obtained from a call to writeSerializableObjectToByteArray
168      * @return A Serializable object contructed from byteArray
169      * @see #writeSerializableObjectToByteArray(Serializable)
170      */

171     java.io.Serializable JavaDoc readSerializableObjectFromByteArray(byte[] byteArray);
172
173
174     /**
175      * Returns Container object associated with the corresponding concrete bean class.
176      * @return a Container object.
177      */

178     Object JavaDoc getContainer();
179
180     /**
181      * Validates that this instance is of the correct implementation class
182      * of a remote interface type.
183      *
184      * @param o the instance to validate.
185      * @return true if the type is correct.
186      * @throw IllegalArgumentException if validation fails.
187      */

188     void assertInstanceOfRemoteInterfaceImpl(Object JavaDoc o);
189
190     /**
191      * Return NumericConverter for conversion from Number to BigDecimal or
192      * BigInteger for this bean type. It is responsible for passing the
193      * correct policy value to the NumericConverterFactory.
194      * @return NumericConverter for given object policy
195      */

196     NumericConverter getNumericConverter();
197 }
198
Popular Tags