001: /**
002: * Speedo: an implementation of JDO compliant personality on top of JORM generic
003: * I/O sub-system.
004: * Copyright (C) 2001-2004 France Telecom R&D
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019: *
020: *
021: *
022: * Contact: speedo@objectweb.org
023: *
024: * Authors: S.Chassande-Barrioz.
025: *
026: */package org.objectweb.speedo.mim.api;
027:
028: import org.objectweb.jorm.api.PBinding;
029: import org.objectweb.perseus.cache.replacement.api.ReplaceableCacheEntry;
030: import org.objectweb.speedo.mim.api.StateItf;
031: import org.objectweb.speedo.pm.api.POManagerItf;
032:
033: /**
034: * This interface what is a Peristent Object in Speedo. It is the jorm PBinding
035: * because it is unique. The Persistent object is an entry of the L2 cache.
036: * A persistent object is linked to its home which is also the Mapping. A
037: * persistent object is linked to several state (StateIf) containing the
038: * persistent data.
039: *
040: * @see org.objectweb.speedo.mim.api.HomeItf
041: * @see org.objectweb.speedo.mim.api.StateItf
042: *
043: * @author S.Chassande-Barrioz
044: */
045: public interface PersistentObjectItf extends PBinding,
046: ReplaceableCacheEntry {
047:
048: /**
049: * Tests whether the po infrastructure has already been set.
050: * A po has a correct PClassMapping linked to a PBinder,
051: * a PName obtained thanks to this PClassMapping.
052: */
053: boolean speedoIsActive();
054:
055: /**
056: * Sets the new value of the po flags
057: *
058: * @see #speedoIsActive()
059: * @param newvalue the new value of the po flag
060: */
061: void speedoIsActive(boolean newvalue);
062:
063: boolean speedoIsPersistent();
064:
065: HomeItf speedoGetHome();
066:
067: /**
068: * It retrieves the StateItf instance used in the current context.
069: * If the po is not active then the reference state is returned.
070: * otherwise a $classNameFields is returned
071: */
072: StateItf speedoGetState();
073:
074: /**
075: * @return the reference accessor of the PersistentObjectItf instance. It can be *
076: * null.
077: * The Reference accessor is used for non persistent instance, as cache
078: * value and for pessimistic policy.
079: */
080: StateItf speedoGetReferenceState();
081:
082: /**
083: * Assignes the reference accessor to the PersistentObjectItf
084: * The Reference accessor is used for non persistent instance, as cache
085: * value and for pessimistic policy.
086: *
087: * @param refAcc the new reference accessor
088: */
089: void speedoSetReferenceState(StateItf refAcc);
090:
091: /**
092: * @return a new StateItf instance.
093: */
094: StateItf speedoCreateState();
095:
096: /**
097: * Copies persistent fields from an accessor to another.
098: * @param src is the accessor containing peristent fields to copy
099: * @param dest is the accessor where persistent fields have to be copied
100: */
101: void speedoCopyState(StateItf src, StateItf dest);
102:
103: /**
104: * Set the encoded PName of the detach copy to allow serialization.
105: * @param encodedPName : the encoded PName of the persistent object
106: */
107: void speedoSetEncodedPName(Object encodedPName);
108:
109: /**
110: * @return the encoded PName of the detached copy
111: */
112: Object speedoGetEncodedPName();
113:
114: /**
115: * Retrieves the hints needed to build the PName of the persistent object
116: * during the export action.
117: */
118: Object speedoGetPNameHints();
119:
120: /**
121: * Adds an element in the gen class field whose number is given. This method
122: * must call the speedoAdd method of the SpeedoGenClassCoherence interface,
123: * or the Collection.add method (if the field contains a collection that
124: * does implement the previous interface). If the field is null, a new
125: * (speedo) collection must be created first.
126: */
127: void speedoAdd(Object elem, int gcFieldNumber);
128:
129: POManagerItf speedoGetPOManager();
130: }
|