01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.lenya.cms.repository;
19:
20: import org.apache.lenya.ac.Identity;
21: import org.apache.lenya.cms.observation.RepositoryEvent;
22: import org.apache.lenya.cms.observation.RepositoryListener;
23: import org.apache.lenya.transaction.ConcurrentModificationException;
24: import org.apache.lenya.transaction.UnitOfWork;
25:
26: /**
27: * Repository session.
28: */
29: public interface Session extends UnitOfWork {
30:
31: /**
32: * @return the identity this session belongs to.
33: */
34: Identity getIdentity();
35:
36: /**
37: * Commits the transaction.
38: * @throws RepositoryException if an error occurs.
39: * @throws ConcurrentModificationException if a transactionable has been
40: * modified by another session.
41: */
42: void commit() throws RepositoryException,
43: ConcurrentModificationException;
44:
45: /**
46: * Rolls the transaction back.
47: * @throws RepositoryException if an error occurs.
48: */
49: void rollback() throws RepositoryException;
50:
51: /**
52: * @param factory The factory.
53: * @param key The key.
54: * @return The item for the specific key.
55: * @throws RepositoryException if an error occurs.
56: */
57: RepositoryItem getRepositoryItem(RepositoryItemFactory factory,
58: String key) throws RepositoryException;
59:
60: /**
61: * @param listener The listener to add.
62: * @throws RepositoryException if the listener is already registered.
63: */
64: void addListener(RepositoryListener listener)
65: throws RepositoryException;
66:
67: /**
68: * Checks if a listener is registered.
69: * @param listener The listener.
70: * @return A boolean value.
71: */
72: boolean isListenerRegistered(RepositoryListener listener);
73:
74: /**
75: * @param event The event to add to the queue.
76: */
77: void enqueueEvent(RepositoryEvent event);
78:
79: /**
80: * @param identity The identity.
81: */
82: void setIdentity(Identity identity);
83:
84: /**
85: * @return if the repository items in this session can be modified.
86: */
87: boolean isModifiable();
88:
89: /**
90: * @return The ID of this session.
91: */
92: String getId();
93: }
|