logo       
Google Custom Search
    AddThis Social Bookmark Button

svn commit: r159587 - in lenya/trunk/src/java/org/apache/lenya: cms/ant/ cm: msg#00070

Subject: svn commit: r159587 - in lenya/trunk/src/java/org/apache/lenya: cms/ant/ cms/publication/ cms/publication/task/ cms/site/tree/ transaction/
Author: andreas
Date: Thu Mar 31 05:53:55 2005
New Revision: 159587

URL: http://svn.apache.org/viewcvs?view=rev&rev=159587
Log:
removed getSiteStructure() from DocumentIdentityMap

Added:
    lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
Modified:
    lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java
    lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java
    lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java
    lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
    lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
    
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
    
lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java
    lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
    lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMap.java
    lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java
    lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java
    
lenya/trunk/src/java/org/apache/lenya/transaction/TransactionableFactory.java

Modified: lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ant/InsertCopyNode.java Thu Mar 
31 05:53:55 2005
@@ -24,6 +24,7 @@
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.tree.SiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.transaction.TransactionException;
 
 /**
  * Ant task that copies a node of a tree and inserts it in tree
@@ -51,7 +52,7 @@
         SiteTree firsttree = getSiteTree(firstarea);
         SiteTree sectree = getSiteTree(secarea);
 
-               StringBuffer buf = new StringBuffer();
+        StringBuffer buf = new StringBuffer();
         StringTokenizer st = new StringTokenizer(secdocumentid, "/");
         int length = st.countTokens();
 
@@ -74,11 +75,15 @@
         } else {
             throw new SiteException("Node " + node + " couldn't be found");
         }
-        if (firstarea.equals(secarea)) {
-            firsttree.save();
-        } else {
-            firsttree.save();
-            sectree.save();
+        try {
+            if (firstarea.equals(secarea)) {
+                firsttree.save();
+            } else {
+                firsttree.save();
+                sectree.save();
+            }
+        } catch (TransactionException e) {
+            throw new SiteException(e);
         }
     }
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ant/MoveNode.java Thu Mar 31 
05:53:55 2005
@@ -24,6 +24,7 @@
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.tree.SiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.transaction.TransactionException;
 
 /**
  * Ant task that moves a node in a tree.
@@ -45,9 +46,10 @@
      * @param firstarea The area of the document corresponding to the source 
node.
      * @param secarea The area of the document corresponding to the 
destination node.
      * @throws SiteException if there are problems with creating or saving the 
site tree.
+     * @throws TransactionException
      */
     public void manipulateTree(String firstdocumentid, String secdocumentid, 
String firstarea,
-            String secarea) throws SiteException {
+            String secarea) throws SiteException, TransactionException {
 
         SiteTree firsttree = getSiteTree(firstarea);
         SiteTree sectree = getSiteTree(secarea);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ant/TreePublisher.java Thu Mar 31 
05:53:55 2005
@@ -26,6 +26,7 @@
 import org.apache.lenya.cms.site.SiteException;
 import org.apache.lenya.cms.site.tree.SiteTree;
 import org.apache.lenya.cms.site.tree.SiteTreeNode;
+import org.apache.lenya.transaction.TransactionException;
 import org.apache.tools.ant.BuildException;
 
 /**
@@ -149,7 +150,7 @@
             liveTree.save();
         } catch (final ParentNodeNotFoundException e) {
             throw new PublishingException("Couldn't publish to live tree :", 
e);
-        } catch (final SiteException e) {
+        } catch (final TransactionException e) {
             throw new PublishingException("Couldn't publish to live tree :", 
e);
         } catch (final PublishingException e) {
             throw new PublishingException("Couldn't publish to live tree :", 
e);

Modified: lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/ant/TwoNodesTask.java Thu Mar 31 
05:53:55 2005
@@ -20,6 +20,7 @@
 package org.apache.lenya.cms.ant;
 
 import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.transaction.TransactionException;
 import org.apache.tools.ant.BuildException;
 
 
@@ -108,10 +109,11 @@
      * @param _secarea : area of the tree of the 2nd node
      * 
      * @throws SiteException if an error occurs
+     * @throws TransactionException
      */
     public abstract void manipulateTree(String _firstdocumentid, String 
_secdocumentid,
         String _firstarea, String _secarea)
-        throws SiteException;
+        throws SiteException, TransactionException;
 
     /** 
      * @see org.apache.tools.ant.Task#execute()

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DefaultDocument.java 
Thu Mar 31 05:53:55 2005
@@ -542,4 +542,11 @@
         return false;
     }
 
+    /**
+     * @see 
org.apache.lenya.transaction.Transactionable#getTransactionableType()
+     */
+    public String getTransactionableType() {
+        return Document.TRANSACTIONABLE_TYPE;
+    }
+
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/Document.java Thu Mar 
31 05:53:55 2005
@@ -43,6 +43,11 @@
     String DEFAULT_PREFIX = "lenya";
     
     /**
+     * The transactionable type for document objects.
+     */
+    String TRANSACTIONABLE_TYPE = "document";
+    
+    /**
      * Returns the document ID of this document.
      * @return the document-id of this document.
      */

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentFactory.java 
Thu Mar 31 05:53:55 2005
@@ -51,7 +51,7 @@
      * @param language The language.
      * @return A key.
      */
-    public Object getKey(Publication publication, String area, String 
documentId, String language) {
+    public String getKey(Publication publication, String area, String 
documentId, String language) {
         return publication.getId() + ":" + area + ":" + documentId + ":" + 
language;
     }
 
@@ -61,7 +61,7 @@
      * @param webappUrl The web application URL.
      * @return A key.
      */
-    public Object getKey(DocumentIdentityMap map, String webappUrl) {
+    public String getKey(DocumentIdentityMap map, String webappUrl) {
         ServiceSelector selector = null;
         DocumentBuilder builder = null;
         SourceResolver resolver = null;
@@ -103,12 +103,11 @@
 
     /**
      * @see 
org.apache.lenya.transaction.TransactionableFactory#build(org.apache.lenya.transaction.IdentityMap,
-     *      java.lang.Object)
+     *      java.lang.String)
      */
-    public Transactionable build(IdentityMap map, Object key) throws Exception 
{
+    public Transactionable build(IdentityMap map, String key) throws Exception 
{
 
-        String keyString = (String) key;
-        String[] snippets = keyString.split(":");
+        String[] snippets = key.split(":");
         String publicationId = snippets[0];
         String area = snippets[1];
         String documentId = snippets[2];
@@ -147,15 +146,6 @@
             }
         }
         return document;
-    }
-
-    /**
-     * @see 
org.apache.lenya.transaction.TransactionableFactory#getKey(org.apache.lenya.transaction.Transactionable)
-     */
-    public Object getKey(Transactionable transactionable) {
-        Document document = (Document) transactionable;
-        return getKey(document.getPublication(), document.getArea(), 
document.getId(), document
-                .getLanguage());
     }
 
 }

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java?view=diff&r1=159586&r2=159587
==============================================================================
--- 
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java 
(original)
+++ 
lenya/trunk/src/java/org/apache/lenya/cms/publication/DocumentIdentityMap.java 
Thu Mar 31 05:53:55 2005
@@ -16,9 +16,6 @@
  */
 package org.apache.lenya.cms.publication;
 
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
@@ -38,8 +35,6 @@
  */
 public class DocumentIdentityMap extends IdentityMapImpl {
 
-    private Map key2siteStructure = new HashMap();
-
     /**
      * Ctor.
      * @param manager The service manager.
@@ -51,55 +46,19 @@
     }
 
     /**
-     * @see org.apache.lenya.transaction.IdentityMap#getFactory()
+     * @see 
org.apache.lenya.transaction.IdentityMap#getFactory(java.lang.String)
      */
-    public TransactionableFactory getFactory() {
-        TransactionableFactory factory = super.getFactory();
-        if (factory == null) {
+    public TransactionableFactory getFactory(String type) {
+        TransactionableFactory factory = super.getFactory(type);
+        if (factory == null && type.equals(Document.TRANSACTIONABLE_TYPE)) {
             factory = new DocumentFactory(this.manager);
             ContainerUtil.enableLogging(factory, getLogger());
-            setFactory(factory);
+            setFactory(type, factory);
         }
         return factory;
     }
 
     /**
-     * @see 
org.apache.lenya.transaction.IdentityMap#setFactory(org.apache.lenya.transaction.TransactionableFactory)
-     */
-    public void setFactory(TransactionableFactory factory) {
-        if (!(factory instanceof DocumentFactory)) {
-            throw new RuntimeException("Only document factories are 
supported.");
-        }
-        super.setFactory(factory);
-    }
-
-    /**
-     * Returns a site structure object.
-     * @param publication The publication.
-     * @param area The area.
-     * @return The site structure object.
-     */
-    public Object getSiteStructure(Publication publication, String area) {
-        String key = getSiteStructureKey(publication, area);
-        return this.key2siteStructure.get(key);
-    }
-
-    /**
-     * Adds a site structure object.
-     * @param publication The publication.
-     * @param area The area.
-     * @param siteStructure The site structure to add.
-     */
-    public void putSiteStructure(Publication publication, String area, Object 
siteStructure) {
-        String key = getSiteStructureKey(publication, area);
-        this.key2siteStructure.put(key, siteStructure);
-    }
-
-    protected String getSiteStructureKey(Publication publication, String area) 
{
-        return publication.getId() + ":" + area;
-    }
-
-    /**
      * Returns a document.
      * @param publication The publication.
      * @param area The area.
@@ -110,8 +69,11 @@
      */
     public Document get(Publication publication, String area, String 
documentId, String language)
             throws DocumentBuildException {
-        DocumentFactory factory = (DocumentFactory) getFactory();
-        return (Document) get(factory.getKey(publication, area, documentId, 
language));
+        DocumentFactory factory = (DocumentFactory) 
getFactory(Document.TRANSACTIONABLE_TYPE);
+        return (Document) get(Document.TRANSACTIONABLE_TYPE, 
factory.getKey(publication,
+                area,
+                documentId,
+                language));
     }
 
     /**
@@ -122,9 +84,9 @@
      */
     public Document getFromURL(String webappUrl) throws DocumentBuildException 
{
 
-        DocumentFactory factory = (DocumentFactory) getFactory();
-        Object key = factory.getKey(this, webappUrl);
-        return (Document) get(key);
+        DocumentFactory factory = (DocumentFactory) 
getFactory(Document.TRANSACTIONABLE_TYPE);
+        String key = factory.getKey(this, webappUrl);
+        return (Document) get(Document.TRANSACTIONABLE_TYPE, key);
     }
 
     protected ServiceManager manager;

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java?view=diff&r1=159586&r2=159587
==============================================================================
--- 
lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java 
(original)
+++ 
lenya/trunk/src/java/org/apache/lenya/cms/publication/task/PublicationTask.java 
Thu Mar 31 05:53:55 2005
@@ -26,6 +26,7 @@
 import java.util.List;
 
 import org.apache.avalon.excalibur.io.FileUtil;
+import org.apache.avalon.framework.container.ContainerUtil;
 import org.apache.avalon.framework.logger.ConsoleLogger;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.lenya.cms.publication.Document;
@@ -34,11 +35,13 @@
 import org.apache.lenya.cms.publication.PublicationFactory;
 import org.apache.lenya.cms.publication.ResourcesManager;
 import org.apache.lenya.cms.site.tree.SiteTree;
+import org.apache.lenya.cms.site.tree.SiteTreeFactory;
 import org.apache.lenya.cms.task.AbstractTask;
 import org.apache.lenya.cms.task.ExecutionException;
 import org.apache.lenya.cms.task.Task;
 import org.apache.lenya.cms.workflow.WorkflowManager;
 import org.apache.lenya.cms.workflow.WorkflowResolver;
+import org.apache.lenya.transaction.TransactionableFactory;
 import org.apache.lenya.workflow.Situation;
 import org.apache.log4j.Logger;
 
@@ -136,8 +139,7 @@
      */
     public static final String PARAMETER_ROLE_IDS = "role-ids";
     /**
-     * <code>ROLE_SEPARATOR_REGEXP</code> The role separator regular
-     * expression
+     * <code>ROLE_SEPARATOR_REGEXP</code> The role separator regular expression
      */
     public static final String ROLE_SEPARATOR_REGEXP = ",";
 
@@ -159,8 +161,7 @@
             return wfManager.canInvoke(document, getEventName());
         } catch (Exception e) {
             throw new ExecutionException(e);
-        }
-        finally {
+        } finally {
             if (wfManager != null) {
                 getServiceManager().release(wfManager);
             }
@@ -179,8 +180,7 @@
             return wfResolver.getSituation();
         } catch (Exception e) {
             throw new RuntimeException(e);
-        }
-        finally {
+        } finally {
             if (wfResolver != null) {
                 getServiceManager().release(wfResolver);
             }
@@ -204,8 +204,7 @@
             wfManager.invoke(document, getEventName());
         } catch (Exception e) {
             throw new ExecutionException(e);
-        }
-        finally {
+        } finally {
             if (wfManager != null) {
                 getServiceManager().release(wfManager);
             }
@@ -240,7 +239,18 @@
      */
     protected SiteTree getSiteTree1(String area) {
         try {
-            return (SiteTree) 
getIdentityMap().getSiteStructure(getPublication(), area);
+
+            TransactionableFactory factory = getIdentityMap()
+                    .getFactory(SiteTree.TRANSACTIONABLE_TYPE);
+            if (factory == null) {
+                factory = new SiteTreeFactory(getServiceManager());
+                ContainerUtil.enableLogging(factory, new ConsoleLogger());
+                getIdentityMap().setFactory(SiteTree.TRANSACTIONABLE_TYPE, 
factory);
+            }
+            
+            String key = getPublication().getId() + ":" + area;
+
+            return (SiteTree) 
getIdentityMap().get(SiteTree.TRANSACTIONABLE_TYPE, key);
         } catch (ExecutionException e) {
             throw new RuntimeException(e);
         }

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/DefaultSiteTree.java 
Thu Mar 31 05:53:55 2005
@@ -31,6 +31,7 @@
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.site.Label;
 import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.transaction.TransactionException;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
 import org.apache.xpath.XPathAPI;
@@ -80,8 +81,7 @@
      * Create a DefaultSiteTree from a filename.
      * @param treefilename file name of the tree
      * @throws SiteException if an error occurs
-     * @deprecated use the DefaultSiteTree(File pubDir, String area) 
constructor
-     *             instead.
+     * @deprecated use the DefaultSiteTree(File pubDir, String area) 
constructor instead.
      */
     protected DefaultSiteTree(String treefilename) throws SiteException {
         this(new File(treefilename));
@@ -118,8 +118,7 @@
     private long lastModified = 0;
 
     /**
-     * Checks if the tree file has been modified externally and reloads the 
site
-     * tree.
+     * Checks if the tree file has been modified externally and reloads the 
site tree.
      */
     protected synchronized void checkModified() {
         if (this.area.equals(Publication.LIVE_AREA) && this.treefile.isFile()
@@ -156,8 +155,8 @@
     }
 
     /**
-     * Find a node in a subtree. The search is started at the given node. The
-     * list of ids contains the document-id split by "/".
+     * Find a node in a subtree. The search is started at the given node. The 
list of ids contains
+     * the document-id split by "/".
      * @param node where to start the search
      * @param ids list of node ids
      * @return the node that matches the path given in the list of ids
@@ -198,10 +197,11 @@
     }
 
     /**
-     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
-     *      java.lang.String, org.apache.lenya.cms.site.Label[])
+     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, 
java.lang.String,
+     *      org.apache.lenya.cms.site.Label[])
      */
-    public synchronized void addNode(String parentid, String id, Label[] 
labels) throws SiteException {
+    public synchronized void addNode(String parentid, String id, Label[] 
labels)
+            throws SiteException {
         addNode(parentid, id, labels, null, null, false);
     }
 
@@ -214,12 +214,12 @@
 
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
-     *      org.apache.lenya.cms.site.Label[], java.lang.String,
-     *      java.lang.String, boolean, java.lang.String)
+     *      org.apache.lenya.cms.site.Label[], java.lang.String, 
java.lang.String, boolean,
+     *      java.lang.String)
      */
     public synchronized void addNode(String documentid, Label[] labels, String 
href, String suffix,
             boolean link, String refDocumentId) throws SiteException {
-               StringBuffer buf = new StringBuffer();
+        StringBuffer buf = new StringBuffer();
         StringTokenizer st = new StringTokenizer(documentid, "/");
         int length = st.countTokens();
 
@@ -233,36 +233,35 @@
 
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
-     *      org.apache.lenya.cms.site.Label[], java.lang.String,
-     *      java.lang.String, boolean)
+     *      org.apache.lenya.cms.site.Label[], java.lang.String, 
java.lang.String, boolean)
      */
-    public synchronized void addNode(String documentid, Label[] labels, String 
href, String suffix, boolean link)
-            throws SiteException {
+    public synchronized void addNode(String documentid, Label[] labels, String 
href, String suffix,
+            boolean link) throws SiteException {
         this.addNode(documentid, labels, href, suffix, link, null);
     }
 
     /**
-     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
-     *      java.lang.String, org.apache.lenya.cms.site.Label[],
-     *      java.lang.String, java.lang.String, boolean)
+     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, 
java.lang.String,
+     *      org.apache.lenya.cms.site.Label[], java.lang.String, 
java.lang.String, boolean)
      */
-    public synchronized void addNode(String parentid, String id, Label[] 
labels, String href, String suffix,
-            boolean link) throws SiteException {
+    public synchronized void addNode(String parentid, String id, Label[] 
labels, String href,
+            String suffix, boolean link) throws SiteException {
         this.addNode(parentid, id, labels, href, suffix, link, null);
     }
 
     /**
-     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String,
-     *      java.lang.String, org.apache.lenya.cms.site.Label[],
-     *      java.lang.String, java.lang.String, boolean, java.lang.String)
+     * @see org.apache.lenya.cms.site.tree.SiteTree#addNode(java.lang.String, 
java.lang.String,
+     *      org.apache.lenya.cms.site.Label[], java.lang.String, 
java.lang.String, boolean,
+     *      java.lang.String)
      */
-    public synchronized void addNode(String parentid, String id, Label[] 
labels, String href, String suffix,
-            boolean link, String refDocumentId) throws SiteException {
+    public synchronized void addNode(String parentid, String id, Label[] 
labels, String href,
+            String suffix, boolean link, String refDocumentId) throws 
SiteException {
 
         Node parentNode = getNodeInternal(parentid);
 
         if (parentNode == null) {
-            throw new SiteException("Parentid: " + parentid + " in " + 
this.area + " tree not found");
+            throw new SiteException("Parentid: " + parentid + " in " + 
this.area
+                    + " tree not found");
         }
 
         getLogger().debug("PARENT ELEMENT: " + parentNode);
@@ -377,8 +376,7 @@
      * 
      * @param documentId the document-id of the Node that we're trying to get
      * 
-     * @return the Node if there is a Node for the given document-id, null
-     *         otherwise
+     * @return the Node if there is a Node for the given document-id, null 
otherwise
      */
     private synchronized Node getNodeInternal(String documentId) {
         StringTokenizer st = new StringTokenizer(documentId, "/");
@@ -416,8 +414,9 @@
         List childElements = new ArrayList();
 
         NamespaceHelper helper = new NamespaceHelper(NAMESPACE_URI, "", 
this.document);
- 
-        Element[] elements = 
helper.getChildren(this.document.getDocumentElement(), 
SiteTreeNodeImpl.NODE_NAME);
+
+        Element[] elements = 
helper.getChildren(this.document.getDocumentElement(),
+                SiteTreeNodeImpl.NODE_NAME);
 
         for (int i = 0; i < elements.length; i++) {
             SiteTreeNode newNode = new SiteTreeNodeImpl(elements[i]);
@@ -426,7 +425,7 @@
 
         return (SiteTreeNode[]) childElements.toArray(new 
SiteTreeNode[childElements.size()]);
     }
-    
+
     /**
      * Move up the node amongst its siblings.
      * @param documentid The document id for the node.
@@ -495,11 +494,10 @@
 
     /**
      * @see 
org.apache.lenya.cms.site.tree.SiteTree#importSubtree(org.apache.lenya.cms.site.tree.SiteTreeNode,
-     *      org.apache.lenya.cms.site.tree.SiteTreeNode, java.lang.String,
-     *      java.lang.String)
+     *      org.apache.lenya.cms.site.tree.SiteTreeNode, java.lang.String, 
java.lang.String)
      */
-    public synchronized void importSubtree(SiteTreeNode newParent, 
SiteTreeNode subtreeRoot, String newid,
-            String refDocumentId) throws SiteException {
+    public synchronized void importSubtree(SiteTreeNode newParent, 
SiteTreeNode subtreeRoot,
+            String newid, String refDocumentId) throws SiteException {
         assert subtreeRoot != null;
         assert newParent != null;
         String parentId = newParent.getAbsoluteId();
@@ -524,15 +522,15 @@
     /**
      * @see org.apache.lenya.cms.site.tree.SiteTree#save()
      */
-    public synchronized void save() throws SiteException {
+    public synchronized void save() throws TransactionException {
         try {
             DocumentHelper.writeDocument(this.document, this.treefile);
         } catch (TransformerException e) {
-            throw new SiteException("The document [" + 
this.document.getLocalName()
+            throw new TransactionException("The document [" + 
this.document.getLocalName()
                     + "] could not be transformed");
         } catch (IOException e) {
-            throw new SiteException("The saving of document [" + 
this.document.getLocalName()
-                    + "] failed");
+            throw new TransactionException("The saving of document ["
+                    + this.document.getLocalName() + "] failed");
         }
     }
 
@@ -545,6 +543,61 @@
         if (node != null) {
             node.setLabel(label);
         }
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#checkin()
+     */
+    public void checkin() throws TransactionException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#checkout()
+     */
+    public void checkout() throws TransactionException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#isCheckedOut()
+     */
+    public boolean isCheckedOut() throws TransactionException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#lock()
+     */
+    public void lock() throws TransactionException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#unlock()
+     */
+    public void unlock() throws TransactionException {
+        // TODO Auto-generated method stub
+
+    }
+
+    /**
+     * @see org.apache.lenya.transaction.Transactionable#isLocked()
+     */
+    public boolean isLocked() throws TransactionException {
+        // TODO Auto-generated method stub
+        return false;
+    }
+
+    /**
+     * @see 
org.apache.lenya.transaction.Transactionable#getTransactionableType()
+     */
+    public String getTransactionableType() {
+        return SiteTree.TRANSACTIONABLE_TYPE;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTree.java Thu Mar 
31 05:53:55 2005
@@ -19,77 +19,67 @@
 
 import org.apache.lenya.cms.site.Label;
 import org.apache.lenya.cms.site.SiteException;
-
+import org.apache.lenya.transaction.Transactionable;
 
 /**
  * A sitetree.
  * 
  * @version $Id$
  */
-public interface SiteTree {
+public interface SiteTree extends Transactionable {
+
+    /**
+     * The type of sitetree transactionable objects.
+     */
+    String TRANSACTIONABLE_TYPE = "site";
 
     /**
      * Add a node.
-     *
+     * 
      * @param parentid where the node is to be added
      * @param id e.g. "concepts"
      * @param labels the labels of the node that is to be added
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(String parentid, String id, Label[] labels)
-        throws SiteException;
+    void addNode(String parentid, String id, Label[] labels) throws 
SiteException;
 
     /**
      * Add a node.
-     *
+     * 
      * @param parentid the node where the new node is to be inserted
      * @param id the node id
-     * @param labels the labels 
+     * @param labels the labels
      * @param href the href of the new node
      * @param suffix the suffix of the new node
-     * @param link the link 
+     * @param link the link
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(
-        String parentid,
-        String id,
-        Label[] labels,
-        String href,
-        String suffix,
-        boolean link)
-        throws SiteException;
+    void addNode(String parentid, String id, Label[] labels, String href, 
String suffix,
+            boolean link) throws SiteException;
 
     /**
-     * Insert a node before a given node 
-     *
+     * Insert a node before a given node
+     * 
      * @param parentid the node where the new node is to be inserted
      * @param id the node id
-     * @param labels the labels 
+     * @param labels the labels
      * @param href the href of the new node
      * @param suffix the suffix of the new node
-     * @param link the link 
+     * @param link the link
      * @param refDocumentId document-id of the node, before which the new node 
will be inserted.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(
-        String parentid,
-        String id,
-        Label[] labels,
-        String href,
-        String suffix,
-        boolean link,
-        String refDocumentId)
-        throws SiteException;
+    void addNode(String parentid, String id, Label[] labels, String href, 
String suffix,
+            boolean link, String refDocumentId) throws SiteException;
 
     /**
-     * Add a node.
-     * Compute the parent id and the id of the node from the document-id
-     *
-     * @param documentid the document-id of the new node. 
-     *  From this the parent-id and the id are computed
+     * Add a node. Compute the parent id and the id of the node from the 
document-id
+     * 
+     * @param documentid the document-id of the new node. From this the 
parent-id and the id are
+     *            computed
      * @param labels the labels
      * @param href the href
      * @param suffix the suffix
@@ -97,20 +87,15 @@
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(
-        String documentid,
-        Label[] labels,
-        String href,
-        String suffix,
-        boolean link)
-        throws SiteException;
+    void addNode(String documentid, Label[] labels, String href, String 
suffix, boolean link)
+            throws SiteException;
 
     /**
-     * Insert a node before a given node 
-     * Compute the parent id and the id of the node from the document-id
-     *
-     * @param documentid the document-id of the new node. 
-     *  From this the parent-id and the id are computed
+     * Insert a node before a given node Compute the parent id and the id of 
the node from the
+     * document-id
+     * 
+     * @param documentid the document-id of the new node. From this the 
parent-id and the id are
+     *            computed
      * @param labels the labels
      * @param href the href
      * @param suffix the suffix
@@ -119,23 +104,15 @@
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(
-        String documentid,
-        Label[] labels,
-        String href,
-        String suffix,
-        boolean link,
-        String refDocumentId)
-        throws SiteException;
-
-    /**
-     * Add a node. This method is typically used when publishing,
-     * i.e. when copying a node from the authoring tree to the live
-     * tree. The existing node already has a parent node (in the
-     * authoring tree). The node that is added will be a copy of
-     * the original node and will be inserted at the same parentid
-     * as the original node.
-     *
+    void addNode(String documentid, Label[] labels, String href, String 
suffix, boolean link,
+            String refDocumentId) throws SiteException;
+
+    /**
+     * Add a node. This method is typically used when publishing, i.e. when 
copying a node from the
+     * authoring tree to the live tree. The existing node already has a parent 
node (in the
+     * authoring tree). The node that is added will be a copy of the original 
node and will be
+     * inserted at the same parentid as the original node.
+     * 
      * @param node the <code>SiteTreeNode</code> that is to be added
      * 
      * @throws SiteException if the addition failed
@@ -143,20 +120,17 @@
     void addNode(SiteTreeNode node) throws SiteException;
 
     /**
-     * Add a node. This method is typically used when publishing,
-     * i.e. when copying a node from the authoring tree to the live
-     * tree. The existing node already has a parent node (in the
-     * authoring tree). The node that is added will be a copy of
-     * the original node and will be inserted at the same parentid
-     * as the original node.
-     *
+     * Add a node. This method is typically used when publishing, i.e. when 
copying a node from the
+     * authoring tree to the live tree. The existing node already has a parent 
node (in the
+     * authoring tree). The node that is added will be a copy of the original 
node and will be
+     * inserted at the same parentid as the original node.
+     * 
      * @param node the <code>SiteTreeNode</code> that is to be added
      * @param refDocumentId document-id of the node, before which the new node 
will be inserted.
      * 
      * @throws SiteException if the addition failed
      */
-    void addNode(SiteTreeNode node, String refDocumentId)
-        throws SiteException;
+    void addNode(SiteTreeNode node, String refDocumentId) throws SiteException;
 
     /**
      * Add a label to an existing node
@@ -167,8 +141,8 @@
     void addLabel(String documentId, Label label);
 
     /**
-     * Sets a label of an existing node. If the label does not exist, it is 
added.
-     * Otherwise, the existing label is replaced.
+     * Sets a label of an existing node. If the label does not exist, it is 
added. Otherwise, the
+     * existing label is replaced.
      * 
      * @param documentId the document-id to which the label is to be added.
      * @param label the label to add
@@ -184,9 +158,8 @@
     void removeLabel(String documentId, Label label);
 
     /**
-     * Removes the node corresponding to the given document-id
-     * from the tree, and returns it.
-     *
+     * Removes the node corresponding to the given document-id from the tree, 
and returns it.
+     * 
      * @param documentId the document-id of the node that is to be removed
      * 
      * @return the removed node
@@ -195,11 +168,11 @@
 
     /**
      * Return the Node for a given document-id.
-     *
+     * 
      * @param documentId the document-id of the node that is requested
      * 
-     * @return a <code>SiteTreeNode</code> if there is a node for the given
-     * document-id, null otherwise.
+     * @return a <code>SiteTreeNode</code> if there is a node for the given 
document-id, null
+     *         otherwise.
      */
     SiteTreeNode getNode(String documentId);
 
@@ -208,7 +181,7 @@
      * @return the top nodes in the sitetree, or empty array if there are none
      */
     SiteTreeNode[] getTopNodes();
-    
+
     /**
      * Move up the node amongst its siblings.
      * 
@@ -218,7 +191,7 @@
     void moveUp(String documentid) throws SiteException;
 
     /**
-     * Move down the node amongst its siblings. 
+     * Move down the node amongst its siblings.
      * @param documentid The document id of the node.
      * @throws SiteException if the moving failed.
      */
@@ -229,22 +202,12 @@
      * @param subtreeRoot The root of the subtree to import.
      * @param newParent The node where the subtree shall be inserted.
      * @param newid The new id of the inserted subtreeRoot node (to not 
overwrite
-     * @param refDocumentId The document-id corresponding to the reference 
node, before which 
-     * the subtree should be inserted. If null, the subtree is inserted at the 
end. 
-     * in case there is already a node with the same id in the tree).
+     * @param refDocumentId The document-id corresponding to the reference 
node, before which the
+     *            subtree should be inserted. If null, the subtree is inserted 
at the end. in case
+     *            there is already a node with the same id in the tree).
      * @throws SiteException when an error occurs.
      */
-    void importSubtree(
-        SiteTreeNode subtreeRoot,
-        SiteTreeNode newParent,
-        String newid,
-        String refDocumentId)
-        throws SiteException;
+    void importSubtree(SiteTreeNode subtreeRoot, SiteTreeNode newParent, 
String newid,
+            String refDocumentId) throws SiteException;
 
-    /**
-     * Save the SiteTree.
-     *
-     * @throws SiteException if the saving failed
-     */
-    void save() throws SiteException;
-}
+}
\ No newline at end of file

Added: lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java?view=auto&rev=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java 
(added)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/SiteTreeFactory.java 
Thu Mar 31 05:53:55 2005
@@ -0,0 +1,85 @@
+/*
+ * Copyright  1999-2004 The Apache Software Foundation
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.cms.site.tree;
+
+import java.io.File;
+
+import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceUtil;
+import org.apache.lenya.cms.publication.Publication;
+import org.apache.lenya.cms.publication.PublicationFactory;
+import org.apache.lenya.transaction.IdentityMap;
+import org.apache.lenya.transaction.Transactionable;
+import org.apache.lenya.transaction.TransactionableFactory;
+
+/**
+ * Factory for sitetree objects.
+ * 
+ * @version $Id:$
+ */
+public class SiteTreeFactory extends AbstractLogEnabled implements 
TransactionableFactory {
+
+    protected ServiceManager manager;
+
+    /**
+     * Ctor.
+     * @param manager The service manager.
+     */
+    public SiteTreeFactory(ServiceManager manager) {
+        this.manager = manager;
+    }
+
+    /**
+     * @see 
org.apache.lenya.transaction.TransactionableFactory#build(org.apache.lenya.transaction.IdentityMap,
+     *      java.lang.String)
+     */
+    public Transactionable build(IdentityMap map, String key) throws Exception 
{
+        String[] snippets = key.split(":");
+        String publicationId = snippets[0];
+        String area = snippets[1];
+
+        SourceResolver resolver = null;
+        Source source = null;
+        SiteTree tree;
+        try {
+            resolver = (SourceResolver) 
this.manager.lookup(SourceResolver.ROLE);
+            source = resolver.resolveURI("context://");
+            File servletContext = SourceUtil.getFile(source);
+
+            PublicationFactory factory = 
PublicationFactory.getInstance(getLogger());
+            Publication publication = factory.getPublication(publicationId, 
servletContext
+                    .getAbsolutePath());
+           
+            tree = new DefaultSiteTree(publication.getDirectory(), area);
+            ContainerUtil.enableLogging(tree, getLogger());
+            
+        } finally {
+            if (resolver != null) {
+                if (source != null) {
+                    resolver.release(source);
+                }
+                this.manager.release(resolver);
+            }
+        }
+        return tree;
+    }
+
+}
\ No newline at end of file

Modified: 
lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/cms/site/tree/TreeSiteManager.java 
Thu Mar 31 05:53:55 2005
@@ -21,6 +21,9 @@
 import java.util.List;
 
 import org.apache.avalon.framework.container.ContainerUtil;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentBuildException;
 import org.apache.lenya.cms.publication.DocumentIdentityMap;
@@ -29,13 +32,15 @@
 import org.apache.lenya.cms.site.AbstractSiteManager;
 import org.apache.lenya.cms.site.Label;
 import org.apache.lenya.cms.site.SiteException;
+import org.apache.lenya.transaction.TransactionException;
+import org.apache.lenya.transaction.TransactionableFactory;
 
 /**
  * A tree-based site manager.
  * 
  * @version $Id$
  */
-public class TreeSiteManager extends AbstractSiteManager {
+public class TreeSiteManager extends AbstractSiteManager implements 
Serviceable {
 
     /**
      * Ctor.
@@ -45,8 +50,8 @@
     }
 
     /**
-     * Returns the sitetree for a specific area of this publication. Sitetrees
-     * are created on demand and are cached.
+     * Returns the sitetree for a specific area of this publication. Sitetrees 
are created on demand
+     * and are cached.
      * @param map The document identity map.
      * @param publication The publication.
      * @param area The area.
@@ -55,12 +60,16 @@
      */
     public SiteTree getTree(DocumentIdentityMap map, Publication publication, 
String area)
             throws SiteException {
-        DefaultSiteTree sitetree = (DefaultSiteTree) 
map.getSiteStructure(publication, area);
-        if (sitetree == null) {
-            sitetree = new DefaultSiteTree(publication.getDirectory(), area);
-            ContainerUtil.enableLogging(sitetree, getLogger());
-            map.putSiteStructure(publication, area, sitetree);
+
+        TransactionableFactory factory = 
map.getFactory(SiteTree.TRANSACTIONABLE_TYPE);
+        if (factory == null) {
+            factory = new SiteTreeFactory(this.manager);
+            ContainerUtil.enableLogging(factory, getLogger());
+            map.setFactory(SiteTree.TRANSACTIONABLE_TYPE, factory);
         }
+
+        String key = getKey(publication, area);
+        DefaultSiteTree sitetree = (DefaultSiteTree) 
map.get(SiteTree.TRANSACTIONABLE_TYPE, key);
         return sitetree;
     }
 
@@ -128,10 +137,9 @@
         try {
             for (int i = 0; i < resources.length; i++) {
                 SiteTreeNode descendant = (SiteTreeNode) preOrder.get(i);
-                resources[i] = resource.getIdentityMap()
-                        .get(resource.getPublication(),
-                                resource.getArea(),
-                                descendant.getAbsoluteId());
+                resources[i] = 
resource.getIdentityMap().get(resource.getPublication(),
+                        resource.getArea(),
+                        descendant.getAbsoluteId());
                 if (getLogger().isDebugEnabled()) {
                     getLogger().debug("    Descendant: [" + resources[i] + 
"]");
                 }
@@ -233,7 +241,11 @@
             destinationTree.setLabel(destinationDocument.getId(), label);
         }
 
-        destinationTree.save();
+        try {
+            destinationTree.save();
+        } catch (TransactionException e) {
+            throw new SiteException(e);
+        }
     }
 
     /**
@@ -267,7 +279,11 @@
             tree.removeNode(document.getId());
         }
 
-        tree.save();
+        try {
+            tree.save();
+        } catch (TransactionException e) {
+            throw new SiteException(e);
+        }
     }
 
     /**
@@ -288,7 +304,11 @@
 
         SiteTree tree = getTree(document);
         tree.setLabel(document.getId(), labelObject);
-        tree.save();
+        try {
+            tree.save();
+        } catch (TransactionException e) {
+            throw new SiteException(e);
+        }
     }
 
     /**
@@ -350,11 +370,33 @@
         if (node == null) {
             Label[] labels = { label };
             tree.addNode(document.getId(), labels, null, null, false);
-            tree.save();
+            try {
+                tree.save();
+            } catch (TransactionException e) {
+                throw new SiteException(e);
+            }
         } else {
             tree.addLabel(document.getId(), label);
         }
 
+    }
+
+    /**
+     * @param publication The publication.
+     * @param area The area.
+     * @return The key to store sitetree objects in the identity map.
+     */
+    protected String getKey(Publication publication, String area) {
+        return publication.getId() + ":" + area;
+    }
+
+    protected ServiceManager manager;
+
+    /**
+     * @see 
org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMap.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMap.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMap.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMap.java Thu Mar 
31 05:53:55 2005
@@ -24,20 +24,23 @@
 public interface IdentityMap {
     
     /**
+     * @param type The type of the transactionable.
      * @param key The key for the transactionable.
      * @return A transcationable.
      */
-    Transactionable get(Object key);
+    Transactionable get(String type, String key);
     
     /**
      * Sets the factory.
+     * @param type The transactionable type to use the factory for.
      * @param factory The factory to use.
      */
-    void setFactory(TransactionableFactory factory);
+    void setFactory(String type, TransactionableFactory factory);
     
     /**
+     * @param type The type to return the factory for.
      * @return The factory.
      */
-    TransactionableFactory getFactory();
+    TransactionableFactory getFactory(String type);
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/IdentityMapImpl.java Thu 
Mar 31 05:53:55 2005
@@ -28,38 +28,44 @@
  */
 public class IdentityMapImpl extends AbstractLogEnabled implements IdentityMap 
{
 
-    private Map key2transactionable = new HashMap();
+    private Map maps = new HashMap();
 
     /**
-     * @see org.apache.lenya.transaction.IdentityMap#get(java.lang.Object)
+     * @see org.apache.lenya.transaction.IdentityMap#get(java.lang.String, 
java.lang.String)
      */
-    public Transactionable get(Object key) {
-        Transactionable transactionable = (Transactionable) 
key2transactionable.get(key);
+    public Transactionable get(String type, String key) {
+        Map map = (Map) this.maps.get(type);
+        if (map == null) {
+            map = new HashMap();
+            this.maps.put(type, map);
+        }
+        Transactionable transactionable = (Transactionable) map.get(key);
         if (transactionable == null) {
             try {
-                transactionable = this.factory.build(this, key);
+                transactionable = getFactory(type).build(this, key);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }
-            key2transactionable.put(key, transactionable);
+            map.put(key, transactionable);
         }
         return transactionable;
     }
 
-    private TransactionableFactory factory;
+    private Map factories = new HashMap();
 
     /**
-     * @see 
org.apache.lenya.transaction.IdentityMap#setFactory(org.apache.lenya.transaction.TransactionableFactory)
+     * @see 
org.apache.lenya.transaction.IdentityMap#setFactory(java.lang.String,
+     *      org.apache.lenya.transaction.TransactionableFactory)
      */
-    public void setFactory(TransactionableFactory factory) {
-        this.factory = factory;
+    public void setFactory(String type, TransactionableFactory factory) {
+        this.factories.put(type, factory);
     }
 
     /**
-     * @see org.apache.lenya.transaction.IdentityMap#getFactory()
+     * @see 
org.apache.lenya.transaction.IdentityMap#getFactory(java.lang.String)
      */
-    public TransactionableFactory getFactory() {
-        return this.factory;
+    public TransactionableFactory getFactory(String type) {
+        return (TransactionableFactory) this.factories.get(type);
     }
 
 }

Modified: lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java?view=diff&r1=159586&r2=159587
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java 
(original)
+++ lenya/trunk/src/java/org/apache/lenya/transaction/Transactionable.java Thu 
Mar 31 05:53:55 2005
@@ -65,4 +65,9 @@
      */
     boolean isLocked() throws TransactionException;
     
+    /**
+     * @return The type of the transactionable.
+     */
+    String getTransactionableType();
+    
 }

Modified: 
lenya/trunk/src/java/org/apache/lenya/transaction/TransactionableFactory.java
URL: 
http://svn.apache.org/viewcvs/lenya/trunk/src/java/org/apache/lenya/transaction/TransactionableFactory.java?view=diff&r1=159586&r2=159587
==============================================================================
--- 
lenya/trunk/src/java/org/apache/lenya/transaction/TransactionableFactory.java 
(original)
+++ 
lenya/trunk/src/java/org/apache/lenya/transaction/TransactionableFactory.java 
Thu Mar 31 05:53:55 2005
@@ -30,12 +30,6 @@
      * @return A transactionable.
      * @throws Exception if an error occurs.
      */
-    Transactionable build(IdentityMap map, Object key) throws Exception;
-    
-    /**
-     * @param transactionable The transactionable.
-     * @return The key to use in an identity map.
-     */
-    Object getKey(Transactionable transactionable);
+    Transactionable build(IdentityMap map, String key) throws Exception;
     
 }



Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>