001: package org.apache.ojb.broker.accesslayer;
002:
003: /* Copyright 2002-2005 The Apache Software Foundation
004: *
005: * Licensed under the Apache License, Version 2.0 (the "License");
006: * you may not use this file except in compliance with the License.
007: * You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: import org.apache.ojb.broker.core.PersistenceBrokerImpl;
019: import org.apache.ojb.broker.metadata.ClassDescriptor;
020: import org.apache.ojb.broker.metadata.ObjectReferenceDescriptor;
021:
022: /**
023: * Abstract Relationship Prefetchers.
024: * Each Prefetcher handles a single Relationship (1:1 or 1:n)
025: *
026: * @author <a href="mailto:jbraeuchi@gmx.ch">Jakob Braeuchi</a>
027: * @version $Id: RelationshipPrefetcherImpl.java,v 1.13.2.1 2005/12/21 22:22:58 tomdz Exp $
028: */
029: public abstract class RelationshipPrefetcherImpl extends BasePrefetcher {
030: private ObjectReferenceDescriptor objectReferenceDescriptor;
031: private boolean cascadeRetrieve;
032:
033: /**
034: * Constructor for RelationshipPrefetcherImpl.
035: */
036: public RelationshipPrefetcherImpl(PersistenceBrokerImpl aBroker,
037: ObjectReferenceDescriptor anOrd) {
038: super (aBroker, anOrd.getItemClass());
039: objectReferenceDescriptor = anOrd;
040: }
041:
042: /**
043: * @see org.apache.ojb.broker.accesslayer.RelationshipPrefetcher#prepareRelationshipSettings()
044: */
045: public void prepareRelationshipSettings() {
046: setCascadeRetrieve(getObjectReferenceDescriptor()
047: .getCascadeRetrieve());
048:
049: // BRJ: do not modify reference-descriptor
050: // getObjectReferenceDescriptor().setCascadeRetrieve(false);
051: }
052:
053: /**
054: * Returns the ClassDescriptor of the owner Class
055: * @return ClassDescriptor
056: */
057: protected ClassDescriptor getOwnerClassDescriptor() {
058: return getObjectReferenceDescriptor().getClassDescriptor();
059: }
060:
061: /**
062: * @see org.apache.ojb.broker.accesslayer.RelationshipPrefetcher#restoreRelationshipSettings()
063: */
064: public void restoreRelationshipSettings() {
065: // BRJ: do not modify reference-descriptor
066: // getObjectReferenceDescriptor().setCascadeRetrieve(isCascadeRetrieve());
067: }
068:
069: /**
070: * Returns the objectReferenceDescriptor.
071: * @return ObjectReferenceDescriptor
072: */
073: protected ObjectReferenceDescriptor getObjectReferenceDescriptor() {
074: return objectReferenceDescriptor;
075: }
076:
077: /**
078: * Sets the objectReferenceDescriptor.
079: * @param objectReferenceDescriptor The objectReferenceDescriptor to set
080: */
081: protected void setObjectReferenceDescriptor(
082: ObjectReferenceDescriptor objectReferenceDescriptor) {
083: this .objectReferenceDescriptor = objectReferenceDescriptor;
084: }
085:
086: /**
087: * Returns the cascadeRetrieve.
088: * @return boolean
089: */
090: protected boolean isCascadeRetrieve() {
091: return cascadeRetrieve;
092: }
093:
094: /**
095: * Sets the cascadeRetrieve.
096: * @param cascadeRetrieve The cascadeRetrieve to set
097: */
098: protected void setCascadeRetrieve(boolean cascadeRetrieve) {
099: this.cascadeRetrieve = cascadeRetrieve;
100: }
101: }
|