KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > intercept > ObjectContextDecorator


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19 package org.apache.cayenne.intercept;
20
21 import java.util.Collection JavaDoc;
22 import java.util.List JavaDoc;
23
24 import org.apache.cayenne.DataChannel;
25 import org.apache.cayenne.DeleteDenyException;
26 import org.apache.cayenne.ObjectContext;
27 import org.apache.cayenne.ObjectId;
28 import org.apache.cayenne.Persistent;
29 import org.apache.cayenne.QueryResponse;
30 import org.apache.cayenne.graph.GraphManager;
31 import org.apache.cayenne.map.EntityResolver;
32 import org.apache.cayenne.query.Query;
33
34 /**
35  * A pass-through decorator of an ObjectContext. Can serve as a superclass of various
36  * ObjectContext interceptors.
37  *
38  * @since 3.0
39  * @author Andrus Adamchik
40  */

41 public class ObjectContextDecorator implements ObjectContext {
42
43     protected ObjectContext context;
44
45     public void commitChanges() {
46         context.commitChanges();
47     }
48
49     public void commitChangesToParent() {
50         context.commitChangesToParent();
51     }
52
53     public Collection JavaDoc deletedObjects() {
54         return context.deletedObjects();
55     }
56
57     public void deleteObject(Object JavaDoc object) throws DeleteDenyException {
58         context.deleteObject(object);
59     }
60
61     public DataChannel getChannel() {
62         return context.getChannel();
63     }
64
65     public EntityResolver getEntityResolver() {
66         return context.getEntityResolver();
67     }
68
69     public GraphManager getGraphManager() {
70         return context.getGraphManager();
71     }
72
73     public Persistent localObject(ObjectId id, Object JavaDoc prototype) {
74         return context.localObject(id, prototype);
75     }
76
77     public Collection JavaDoc modifiedObjects() {
78         return context.modifiedObjects();
79     }
80
81     public Persistent newObject(Class JavaDoc persistentClass) {
82         return context.newObject(persistentClass);
83     }
84     
85     public void registerNewObject(Object JavaDoc object) {
86         context.registerNewObject(object);
87     }
88
89     public Collection JavaDoc newObjects() {
90         return context.newObjects();
91     }
92
93     public QueryResponse performGenericQuery(Query query) {
94         return context.performGenericQuery(query);
95     }
96
97     public List JavaDoc performQuery(Query query) {
98         return context.performQuery(query);
99     }
100
101     /**
102      * @deprecated since 3.0, use {@link #prepareForAccess(Persistent, String, boolean)}.
103      */

104     public void prepareForAccess(Persistent object, String JavaDoc property) {
105         context.prepareForAccess(object, property);
106     }
107     
108     public void prepareForAccess(Persistent object, String JavaDoc property, boolean lazyFaulting) {
109         context.prepareForAccess(object, property, lazyFaulting);
110     }
111
112     public void propertyChanged(
113             Persistent object,
114             String JavaDoc property,
115             Object JavaDoc oldValue,
116             Object JavaDoc newValue) {
117         context.propertyChanged(object, property, oldValue, newValue);
118     }
119
120     public void rollbackChanges() {
121         context.rollbackChanges();
122     }
123
124     public void rollbackChangesLocally() {
125         context.rollbackChangesLocally();
126     }
127
128     public Collection JavaDoc uncommittedObjects() {
129         return context.uncommittedObjects();
130     }
131
132     public ObjectContext getContext() {
133         return context;
134     }
135
136     public void setContext(ObjectContext context) {
137         this.context = context;
138     }
139 }
140
Popular Tags