KickJava   Java API By Example, From Geeks To Geeks.

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


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 org.apache.cayenne.DataChannel;
22 import org.apache.cayenne.ObjectContext;
23 import org.apache.cayenne.QueryResponse;
24 import org.apache.cayenne.event.EventManager;
25 import org.apache.cayenne.graph.GraphDiff;
26 import org.apache.cayenne.map.EntityResolver;
27 import org.apache.cayenne.query.Query;
28
29 /**
30  * A helper {@link DataChannel} implementation that passes all requests to the underlying
31  * decorated channel for execution. Intended for subclassing.
32  *
33  * @since 3.0
34  * @author Andrus Adamchik
35  */

36 public class DataChannelDecorator implements DataChannel {
37
38     protected DataChannel channel;
39
40     protected DataChannelDecorator() {
41
42     }
43
44     public DataChannelDecorator(DataChannel channel) {
45         setChannel(channel);
46     }
47
48     public EntityResolver getEntityResolver() {
49         return channel.getEntityResolver();
50     }
51
52     public EventManager getEventManager() {
53         return channel.getEventManager();
54     }
55
56     public QueryResponse onQuery(ObjectContext originatingContext, Query query) {
57         return channel.onQuery(originatingContext, query);
58     }
59
60     public GraphDiff onSync(
61             ObjectContext originatingContext,
62             GraphDiff changes,
63             int syncType) {
64         return channel.onSync(originatingContext, changes, syncType);
65     }
66
67     public DataChannel getChannel() {
68         return channel;
69     }
70
71     public void setChannel(DataChannel channel) {
72         // TODO: andrus, 9/20/2006 - register as listener of the channel events
73
this.channel = channel;
74     }
75 }
76
Popular Tags