01: package org.apache.ojb.broker.core;
02:
03: /* Copyright 2003-2005 The Apache Software Foundation
04: *
05: * Licensed under the Apache License, Version 2.0 (the "License");
06: * you may not use this file except in compliance with the License.
07: * You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17:
18: import org.apache.ojb.broker.accesslayer.RsIterator;
19: import org.apache.ojb.broker.accesslayer.SqlBasedRsIterator;
20: import org.apache.ojb.broker.accesslayer.RsQueryObject;
21: import org.apache.ojb.broker.metadata.ClassDescriptor;
22: import org.apache.ojb.broker.query.Query;
23: import org.apache.ojb.broker.query.QueryBySQL;
24:
25: /**
26: * Factory for RsIterator
27: *
28: * @author <a href="mailto:jbraeuchi@hotmail.com">Jakob Braeuchi</a>
29: * @version $Id: RsIteratorFactoryImpl.java,v 1.4.2.1 2005/12/21 22:25:01 tomdz Exp $
30: */
31: class RsIteratorFactoryImpl implements RsIteratorFactory {
32: private static RsIteratorFactory instance;
33:
34: /**
35: * Constructor for RsIteratorFactoryImpl.
36: */
37: public RsIteratorFactoryImpl() {
38: super ();
39: }
40:
41: static RsIteratorFactory getInstance() {
42: if (instance == null) {
43: instance = new RsIteratorFactoryImpl();
44: }
45:
46: return instance;
47: }
48:
49: /**
50: * @see org.apache.ojb.broker.core.RsIteratorFactory#createRsIterator(Query, ClassDescriptor, PersistenceBrokerImpl)
51: */
52: public RsIterator createRsIterator(Query query,
53: ClassDescriptor cld, PersistenceBrokerImpl broker) {
54: return new RsIterator(RsQueryObject.get(cld, query), broker);
55: }
56:
57: /**
58: * @see org.apache.ojb.broker.core.RsIteratorFactory#createRsIterator
59: * (org.apache.ojb.broker.query.QueryBySQL, org.apache.ojb.broker.metadata.ClassDescriptor, org.apache.ojb.broker.core.PersistenceBrokerImpl))
60: */
61: public RsIterator createRsIterator(QueryBySQL query,
62: ClassDescriptor cld, PersistenceBrokerImpl broker) {
63: return new SqlBasedRsIterator(RsQueryObject.get(cld, query),
64: broker);
65: }
66:
67: }
|