001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. 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: package org.apache.jetspeed.components.persistence.store;
018:
019: import java.util.Collection;
020: import java.util.Iterator;
021:
022: import org.apache.jetspeed.components.persistence.store.LockFailedException;
023:
024: /**
025: * <p>
026: * PersistenceStore
027: * </p>
028: *
029: * <p>
030: * The persistence store allows access to the persistent
031: * storage mechanism within the application.
032: * <br/>
033: * PersistenceStore instances <strong>ARE NOT</strong>
034: * thread safe. The best practices approach for using
035: * the persistence store is to use
036: * <code>PersistenceStoreContainer.getStoreForThread()</code>
037: * any time the store is to be accessed.
038: *
039: * </p>
040: *
041: * @
042: * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
043: * @version $ $
044: *
045: */
046: public interface PersistenceStore {
047: /**
048: * No lock at all aka the object is read only changes WILL NOT be persisted
049: * at checkPoints or commits.
050: */
051: int LOCK_NO_LOCK = 0;
052:
053: /**
054: * changes to the object will be written to the database, in this case the lock
055: * will be automatically upgraded to the write lock on transaction
056: */
057: int LOCK_READ = 1;
058:
059: /**
060: * changes to the object will be written to the database.
061: */
062: int LOCK_PESSIMISTIC = 2;
063:
064: void addEventListener(PersistenceStoreEventListener listener);
065:
066: void close();
067:
068: void deletePersistent(Object obj) throws LockFailedException;
069:
070: void deleteAll(Object query) throws LockFailedException;
071:
072: Collection getCollectionByQuery(Object query);
073:
074: Collection getCollectionByQuery(Object query, int lockLevel);
075:
076: Object getObjectByQuery(Object query);
077:
078: Object getObjectByQuery(Object query, int lockLevel);
079:
080: Object getObjectByIdentity(Object object)
081: throws LockFailedException;
082:
083: Object getObjectByIdentity(Object object, int lockLevel)
084: throws LockFailedException;
085:
086: int getCount(Object query);
087:
088: Iterator getIteratorByQuery(Object query);
089:
090: Iterator getIteratorByQuery(Object query, int lockLevel);
091:
092: /**
093: *
094: * <p>
095: * isClosed
096: * </p>
097: * <p>
098: * indicates whether or not this <code>PersistenceStore</code>
099: * instance has been closed. A closed store will generally
100: * throw exceptions when any operation is performed upon it.
101: * </p>
102: *
103: * @return
104: *
105: */
106: boolean isClosed();
107:
108: /**
109: *
110: * <p>
111: * getTransaction
112: * </p>
113: * <p>
114: * Returns the current <code>Transaction</code> for thsis
115: * <code>PersistenceStore</code> instance. The transaction
116: * will always be the same for the lifetime of the
117: * <code>PersistenceStore</code> instance.
118: * </p>
119: *
120: * @return <code>Transaction</code> for this
121: * <code>PersistenceStore</code>
122: *
123: */
124: Transaction getTransaction();
125:
126: void invalidate(Object obj) throws LockFailedException;
127:
128: void invalidateAll() throws LockFailedException;
129:
130: void invalidateExtent(Class clazz) throws LockFailedException;
131:
132: void invalidateByQuery(Object query) throws LockFailedException;
133:
134: void lockForWrite(Object obj) throws LockFailedException;
135:
136: void makePersistent(Object obj) throws LockFailedException;
137:
138: Filter newFilter();
139:
140: Object newQuery(Class clazz, Filter filter);
141:
142: Collection getExtent(Class clazz);
143:
144: Collection getExtent(Class clazz, int lockLevel);
145:
146: }
|