Author: andreas
Date: Sun Aug 19 15:37:59 2007
New Revision: 567495
URL: http://svn.apache.org/viewvc?rev=567495&view=rev
Log:
Don't create session UUID for immutable sessions
Modified:
lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
Modified: lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java?rev=567495&r1=567494&r2=567495&view=diff
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/repository/SessionImpl.java Sun Aug 19 15:37:59 2007
@@ -49,14 +49,14 @@
*/
public class SessionImpl extends AbstractLogEnabled implements Session {
+ protected static final String UNMODIFIABLE_SESSION_ID = "unmodifiable";
private ServiceManager manager;
private Identity identity;
/**
* Ctor.
* @param identity The identity.
- * @param modifiable Determins if the repository items in this session can
- * be modified.
+ * @param modifiable Determins if the repository items in this session can be modified.
* @param manager The service manager.
* @param logger The logger.
*/
@@ -69,24 +69,18 @@
this.identityMap = new IdentityMapImpl(logger);
this.identity = identity;
+ this.id = modifiable ? createUuid() : UNMODIFIABLE_SESSION_ID;
ObservationRegistry registry = null;
- UUIDGenerator generator = null;
try {
registry = (ObservationRegistry) this.manager.lookup(ObservationRegistry.ROLE);
addListener(registry);
-
- generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
- this.id = generator.nextUUID();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
if (registry != null) {
this.manager.release(registry);
}
- if (generator == null) {
- this.manager.release(generator);
- }
}
if (modifiable) {
@@ -94,6 +88,23 @@
}
}
+ protected String createUuid() {
+ String id;
+ UUIDGenerator generator = null;
+ try {
+
+ generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
+ id = generator.nextUUID();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (generator == null) {
+ this.manager.release(generator);
+ }
+ }
+ return id;
+ }
+
public Identity getIdentity() {
return this.identity;
}
@@ -116,8 +127,8 @@
/**
* Commits the transaction.
* @throws RepositoryException if an error occurs.
- * @throws ConcurrentModificationException if a transactionable has been
- * modified by another session.
+ * @throws ConcurrentModificationException if a transactionable has been modified by another
+ * session.
*/
public void commit() throws RepositoryException, ConcurrentModificationException {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.