001: /**
002: * Copyright (C) 2001-2004 France Telecom R&D
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the Free Software
016: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
017: */package org.objectweb.speedo.mim.api;
018:
019: import org.objectweb.jorm.api.PClassMapping;
020: import org.objectweb.jorm.util.api.Loggable;
021: import org.objectweb.perseus.persistence.api.TransactionalPersistenceManager;
022: import org.objectweb.speedo.pm.api.POManagerItf;
023: import org.objectweb.speedo.pm.api.POManagerFactoryItf;
024: import org.objectweb.speedo.query.api.QueryDefinition;
025: import org.objectweb.speedo.usercache.api.UserCacheManager;
026:
027: import java.util.Collection;
028: import java.util.Map;
029: import java.util.Properties;
030:
031: /**
032: * It defines a home for a persitent class. Homes manage some properties
033: * (detacheable, cacheable, prefetch on query, prefetch on extent, ...)
034: * and some features (the user cache, named
035: * queries). It references the TPM, the PMF.
036: *
037: * @author S.Chassande-Barrioz
038: */
039: public interface HomeItf extends PClassMapping, UserCacheManager,
040: Loggable {
041:
042: int PRE_NEW = 1; // before make persistent
043: int POST_NEW = 2; // after make persistent
044: int PRE_CREATE = 3; // before flushing a new persistent (INSERT)
045: int POST_CREATE = 4; // after flushing a new persistent (INSERT)
046:
047: int PRE_REMOVE = 5; // before removing persistent an object
048: int POST_REMOVE = 6; // after removing persistent an object
049: int PRE_DELETE = 7; // before flushing a removed persistent (DELETE)
050: int POST_DELETE = 8; // after flushing a removed persistent (DELETE)
051:
052: int POST_LOAD = 9; // after loading state into a persistent object
053:
054: int PRE_UPDATE = 10; // before flushing a modified persistent (UPDATE)
055: int POST_UPDATE = 11; // after flushing a modified persistent (UPDATE)
056:
057: int PRE_CLEAR = 12;
058: int POST_CLEAR = 13;
059:
060: int PRE_DIRTY = 14;
061: int POST_DIRTY = 15;
062:
063: int PRE_DETACH = 16;
064: int POST_DETACH = 17;
065:
066: int PRE_ATTACH = 18;
067: int POST_ATTACH = 19;
068:
069: String getProjectName();
070:
071: /**
072: * Indicates if the class has been marked as detacheable
073: */
074: boolean isDetachable();
075:
076: /**
077: * Indicates if the state of persistent instance managed by this home, are
078: * kept between two transaction.
079: * @return true means the state is kept between transaction.
080: */
081: boolean isCacheable();
082:
083: boolean hasToFix();
084:
085: boolean allLoaded();
086:
087: /**
088: * Permit to Indicate if the state of persistent instance managed by this
089: * home, are kept between two transaction.
090: */
091: void setCachePolicy(byte v);
092:
093: byte NO_CACHE = 0;
094: byte CACHED = 1;
095: byte FIXED = 3;
096: byte ALL = 11;
097:
098: boolean isShareable();
099:
100: void setShareable(boolean v);
101:
102: /**
103: * Indicates if the locking level must be the field. A false value (default)
104: * means the locking level has to be done at instance level.
105: */
106: boolean isFieldLockingLevel();
107:
108: /**
109: * Permits to Indicate if the locking level must be the field. A false
110: * value (default) means the locking level has to be done at instance level.
111: */
112: void setFieldLockingLevel(boolean val);
113:
114: /**
115: * The versioning strategy.
116: * @see org.objectweb.speedo.metadata.SpeeedoVersion#DATE_TIME
117: * @see org.objectweb.speedo.metadata.SpeeedoVersion#STATE_COMPARISON
118: * @see org.objectweb.speedo.metadata.SpeeedoVersion#VERSION_NUMBER NO_VERSION
119: */
120: byte getVersioningStrategy();
121:
122: /**
123: * @return the PersistenceManagerFactory representing the data support
124: * where the po is persistent.
125: */
126: POManagerFactoryItf getPOManagerFactory();
127:
128: /**
129: * It assignes a PersistenceManagerFactory
130: * @param _pmf is the PersistenceManagerFactory representing the data
131: * support where the po is persistent.
132: */
133: void setPOManagerFactory(POManagerFactoryItf _pmf);
134:
135: /**
136: * @return the TransactionalPersistenceManager which manages the
137: * concurrency, loading, caching ... of the proxies.
138: */
139: TransactionalPersistenceManager getTransactionalPersistenceManager();
140:
141: /**
142: * It assignes a TransactionalPersistenceManager
143: * @param _tpm is the TransactionalPersistenceManager which manage the
144: * concurrency, loading, ... of the po.
145: */
146: void setTransactionalPersistenceManager(
147: TransactionalPersistenceManager _tpm);
148:
149: /**
150: * Notifies the transactional persistency manager of a read intention for
151: * the given persistent instance.
152: * @param sp is the PersistentObjectItf which the read access is requested.
153: * @param fields the ids of the fields that may be accessed by the caller
154: * of this method. If the i-th bit of 'fields' is set to 1, then the i-th
155: * field of the given speedo accessor may be accessed by the caller of this
156: * method.
157: */
158: StateItf readIntention(PersistentObjectItf sp, long[] fields);
159:
160: /**
161: * Notifies the transactional persistency manager of a write intention for
162: * the given persistent instance.
163: *
164: * @param sp is the PersistentObjectItf which the write access is requested.
165: * @param fields the ids of the fields that may be accessed by the caller
166: * of this method. If the i-th bit of 'fields' is set to 1, then the i-th
167: * field of the given speedo accessor may be accessed by the caller of this
168: * method.
169: * @param thinLock permits to allocate a lock on only a part of the
170: * resource. The locking size is thinner than a lock on the persistent
171: * object entirely. This parameter can be typically used to lock at the
172: * field or the genclass element levels.
173: */
174: StateItf writeIntention(PersistentObjectItf sp, long[] fields,
175: Object thinLock);
176:
177: StateItf writeIntention(PersistentObjectItf sp, long[] fields);
178:
179: StateItf getState(PersistentObjectItf sp);
180:
181: PersistentObjectItf detachCopy(PersistentObjectItf sp,
182: POManagerItf pm, Map map, Object clone, Collection fgHints);
183:
184: void attachCopy(PersistentObjectItf sp, POManagerItf pm, Map map,
185: Object clone, StateItf sa);
186:
187: Properties getClassProperties();
188:
189: /**
190: * Defines a named query
191: * @param name is the name identifying the query
192: * @param query is the definition of the query
193: * @return the old query definition corresponding to the name, if it
194: * existed one.
195: */
196: QueryDefinition addNamedQuery(String name, QueryDefinition query);
197:
198: /**
199: * Remove a named query
200: * @param name is the name of the query definition to remove
201: * @return the removed query definition (null if not found)
202: */
203: QueryDefinition removeNamedQuery(String name);
204:
205: /**
206: * Retrieves a query defintion from its name. If the name is not known, the
207: * null value is returned.
208: * @param name is the name the wanted query definition
209: */
210: QueryDefinition getNamedQuery(String name);
211:
212: void initSH();
213:
214: String getPath();
215:
216: /**
217: * Indicates if the prefetching must be activated on queries when they
218: * return instance corresponding to this home.
219: */
220: void setPrefetchOnQuery(boolean prefetch);
221:
222: boolean getPrefetchOnQuery();
223:
224: /**
225: * Indicates if the prefetching must be activated on extents when they
226: * return instance corresponding to this home.
227: */
228: void setPrefetchOnExtent(boolean prefetch);
229:
230: boolean getPrefetchOnExtent();
231:
232: /**
233: * Indicates if the prefetching must be activated genclass loading. This
234: * method is only applicable for gen class home.
235: */
236: void setPrefetchOnGenClass(boolean prefetch);
237:
238: boolean getPrefetchOnGenClass();
239:
240: void addInstanceLifeCycleListener(Object listener);
241:
242: void removeInstanceLifeCycleListener(Object listener);
243:
244: void sendEvent(int eventType, Object source, Object target);
245:
246: boolean hasInstanceLifeCycleListeners();
247: }
|