KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > descriptors > copying > CopyPolicy


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
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
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 in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2005, Oracle. All rights reserved.
22
package oracle.toplink.essentials.descriptors.copying;
23
24 import java.io.*;
25 import oracle.toplink.essentials.exceptions.*;
26 import oracle.toplink.essentials.descriptors.ClassDescriptor;
27 import oracle.toplink.essentials.queryframework.ObjectBuildingQuery;
28 import oracle.toplink.essentials.queryframework.ObjectLevelReadQuery;
29 import oracle.toplink.essentials.sessions.*;
30
31
32 /**
33  * <p><b>Purpose</b>: Allows customization of how an object is cloned.
34  * An implementer of CopyPolicy can be set on a descriptor to provide
35  * special cloning routine for how an object is cloned in a unit of work.
36  * By default the InstantiationCopyPolicy is used which creates a new instance of
37  * the class to be copied into.
38  * The MethodBasedCopyPolicy can also be used that uses a clone method in the object
39  * to clone the object. When a clone method is used it avoid the requirement of having to
40  * copy over each of the direct attributes.
41  */

42 public interface CopyPolicy extends Cloneable JavaDoc, Serializable {
43
44     /**
45      * Return a shallow clone of the object for usage with object copying, or unit of work backup cloning.
46      */

47     Object JavaDoc buildClone(Object JavaDoc object, Session session) throws DescriptorException;
48
49     /**
50      * Return a shallow clone of the object for usage with the unit of work working copy.
51      */

52     Object JavaDoc buildWorkingCopyClone(Object JavaDoc object, Session session) throws DescriptorException;
53
54     /**
55      * Return an instance with the primary key set from the row, used for building a working copy during a unit of work transactional read.
56      */

57     Object JavaDoc buildWorkingCopyCloneFromRow(Record row, ObjectBuildingQuery query) throws DescriptorException;
58
59     /**
60      * Return an instance with the primary key set from the row, used for building a working copy during a unit of work transactional read.
61      */

62     Object JavaDoc buildWorkingCopyCloneFromRow(Record row, ObjectLevelReadQuery query) throws DescriptorException;
63
64    /**
65      * Clone the CopyPolicy.
66      */

67     Object JavaDoc clone();
68
69     /**
70      * Allow for any initialization or validation required.
71      */

72     void initialize(Session session) throws DescriptorException;
73
74     /**
75      * Set the descriptor.
76      */

77     void setDescriptor(ClassDescriptor descriptor);
78
79     /**
80      * Return if this copy policy creates a new instance, vs a clone.
81      */

82     boolean buildsNewInstance();
83 }
84
Popular Tags