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.pm.api;
027:
028: import org.objectweb.jorm.naming.api.PName;
029: import org.objectweb.perseus.persistence.api.TransactionalPersistenceManager;
030: import org.objectweb.perseus.concurrency.lib.Semaphore;
031: import org.objectweb.speedo.mim.api.FetchPlanItf;
032: import org.objectweb.speedo.mim.api.PersistentObjectItf;
033: import org.objectweb.speedo.workingset.api.TransactionItf;
034:
035: import java.util.Collection;
036: import java.util.Map;
037:
038: import javax.transaction.Synchronization;
039:
040: /**
041: * defines a manager of persistent instance.
042: * A POManagerItf is a javax.transaction.Synchronization for the JTA
043: * integration. This permits to support the container transaction demarcation.
044: * On the beforeCompletion method the perseus transaction is prepared.
045: * A po manager used a TransactionalPersistenceManager for managing the
046: * concurrency, the loading and the caching aspects.
047: *
048: * @see org.objectweb.speedo.pm.api.POManagerFactoryItf
049: * @see org.objectweb.speedo.pm.api.POManagerSwitchItf
050: * @see org.objectweb.perseus.persistence.api.TransactionalPersistenceManager
051: *
052: * @author S.Chassande-Barrioz
053: */
054: public interface POManagerItf extends Synchronization {
055:
056: /**
057: * Retrieves the TransactionalPersistenceManager used by this POManagerItf.
058: */
059: TransactionalPersistenceManager getTransactionalPersistenceManager();
060:
061: /**
062: * Opens the persistent manager. This operation is the opposite of the
063: * javax.jdo.PersistenceManager.close() method. It prepares a POManagerItf
064: * to be used. During the preparation, the optimistic and multithread modes
065: * are initialized.
066: * @param connectionSpec is the information to access to the data store
067: * (user, password, ...)
068: */
069: void open(Object connectionSpec);
070:
071: /**
072: * @return the connection information to access the data store
073: */
074: Object getConnectionSpec();
075:
076: /**
077: * Signal to the persistence maneger that it is used. A persistence managed
078: * can be used by several thread. In this case each thread have done a
079: * PersistenceManagerFactory.getPersistentceManager() to obtain a po
080: * manager instance. The threads will do a close() operation, but only the
081: * last has to be taken in account. This method permits to knwon how many
082: * users uses the current pomanager.
083: */
084: void addUse();
085:
086: /**
087: * Retrieves the semaphore object permiting the multithreading mode.
088: */
089: Semaphore getSemaphore();
090:
091: /**
092: * @return the unique transaction associate to the POM.
093: */
094: TransactionItf getSpeedoTransaction();
095:
096: /**
097: * Close the POM
098: */
099: void closePOManager();
100:
101: /**
102: * @return true if the POM is closed, otherwise false.
103: */
104: boolean isPOMClosed();
105:
106: /**
107: * @return the factory of this POM.
108: */
109: POManagerFactoryItf getPOManagerFactory();
110:
111: /**
112: * Encodes a PName into a serializable representation which could be decoded
113: * later. The representation depends on the PName structure.
114: * @param po is a persistent object
115: */
116: Object getEncodedPName(PersistentObjectItf po);
117:
118: PName decodeIdentifier(Class aClass, Object s);
119:
120: /**
121: * Make persistent a PersistentObjectItf. This method does the same thing than the
122: * PersistenceManager.makePersistent(Object) method except the call to the
123: * bind to the POManagerItf to the current thread.
124: * @param sp is the instance to make persistent.
125: * @param map is the context of the attachment process if any. If no attachment, it is null.
126: *
127: * @return TODO
128: */
129: Object speedoMakePersistent(PersistentObjectItf sp, Map map);
130:
131: /**
132: * Delete persistent a PersistentObjectItf. This method does the same thing than the
133: * PersistenceManager.deletePersistent(Object) method except the call to the
134: * bind to the POManagerItf to the current thread.
135: *
136: * @param o is the instance to make persistent.
137: */
138: void speedoDeletePersistent(Object o);
139:
140: void speedoDeletePersistentAll(Object[] o);
141:
142: void speedoDeletePersistent(Object oid, Class pc);
143:
144: Object speedoGetObject(PName pn, boolean validate);
145:
146: Object speedoDetachCopy(PersistentObjectItf sp, Map map,
147: Collection fgHints);
148:
149: Object speedoAttachCopy(Object detached, Map map);
150:
151: void speedoRefresh(PersistentObjectItf sp, Map map,
152: Collection fgHints);
153:
154: void speedoRetrieve(PersistentObjectItf sp, Map map,
155: Collection fgHints);
156:
157: FetchPlanItf speedoGetFetchPlan();
158: }
|