001 package org.apache.ojb.otm.swizzle;
002
003 /* Copyright 2003-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
019 import org.apache.ojb.broker.PersistenceBroker;
020 import org.apache.ojb.broker.cache.ObjectCache;
021
022 /**
023 * @todo document
024 */
025 public interface Swizzling
026 {
027
028 /**
029 *
030 * Swizzle object references.
031 *
032 * @param newObj the object being inserted into the EditingContext,
033 * is null if the object is being invalidated
034 * @param oldObj the object present in the EditingContext,
035 * is null if no object is present
036 * @param pb the PersistenceBroker that is used to get
037 * persistent class info
038 * @param cache the "cache" of old objects, only lookup() method
039 * can be used by the Swizzling implementation to seek for old objects
040 * that should be set as a new value of relations.
041 *
042 * @return the Swizzled Object
043 *
044 */
045 public Object swizzle(Object newObj, Object oldObj, PersistenceBroker pb,
046 ObjectCache cache);
047
048 /**
049 *
050 * Test if the given swizzled object is the same as the given object. By same object we mean,
051 * that the System.identityHashCode() of the given object is the same as that of the object
052 * represented by the swizzled object.
053 *
054 * @param swizzledObject The swizzled object
055 * @param object The other object to be compared to
056 * @return true, if they are the same. false, otherwise.
057 *
058 */
059 public boolean isSameInstance(Object swizzledObject, Object object);
060
061 /**
062 *
063 * Get the real object associated with the given swizzled object.
064 *
065 * @param swizzledObject the swizzled object
066 * @return the real object
067 *
068 */
069 public Object getRealTarget(Object swizzledObject);
070 }