svn commit: r741384 [1/2] - in /lenya/trunk: org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/ org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/ org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms...

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Fri Feb  6 03:16:59 2009
New Revision: 741384

URL: http://svn.apache.org/viewvc?rev=741384&view=rev
Log:
Springify Lenya core components.

Added:
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/resources/
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/resources/META-INF/
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/resources/META-INF/cocoon/
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/resources/META-INF/cocoon/spring/
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/resources/META-INF/cocoon/spring/lenya-module-sourcerepository-components.xml
Modified:
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/NodeSet.java
    lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/SiteUtil.java
    lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java
    lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java
    lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
    lenya/trunk/org.apache.lenya.core.impl/src/main/resources/META-INF/cocoon/spring/lenya-core-impl-components.xml
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ContentSourceWrapper.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/MetaSourceWrapper.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNode.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeFactory.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeHistory.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaData.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRCML.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRcmlFactory.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRevision.java
    lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceWrapper.java
    lenya/trunk/org.apache.lenya.welcome/pom.xml

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/cocoon/source/SourceUtil.java Fri Feb  6 03:16:59 2009
@@ -50,22 +50,20 @@
 
     /**
      * <p>
-     * Copies one Source to another using a source buffer i.e. the source Source
-     * is buffered before it is copied to its final destination.
+     * Copies one Source to another using a source buffer i.e. the source Source is buffered before
+     * it is copied to its final destination.
      * </p>
      * <p>
-     * The optional buffering is sometimes useful, if the source Source somehow
-     * depends on the destination Source. This situation may occur e.g. if
-     * source Source is a Cocoon pipeline.
+     * The optional buffering is sometimes useful, if the source Source somehow depends on the
+     * destination Source. This situation may occur e.g. if source Source is a Cocoon pipeline.
      * </p>
      * <p>
-     * <em>NOTE:</em> o.a.e..s.SourceUtil.copy does not close streams on an
-     * exception!!
+     * <em>NOTE:</em> o.a.e..s.SourceUtil.copy does not close streams on an exception!!
      * </p>
      * @param source
      * @param destination
-     * @param useBuffer If true, the source data will be read into a buffer
-     *        before it is written to the final destination.
+     * @param useBuffer If true, the source data will be read into a buffer before it is written to
+     *            the final destination.
      * @throws IOException If an error occures.
      */
     public static void copy(Source source, ModifiableSource destination, boolean useBuffer)
@@ -99,8 +97,8 @@
      * @param resolver The SourceResolver to use for lookin up Sources.
      * @param sourceUri The source to be copied.
      * @param destUri The URI to copy to.
-     * @param useBuffer If true, the source Source is buffered before copied to
-     *        the final destination.
+     * @param useBuffer If true, the source Source is buffered before copied to the final
+     *            destination.
      * @throws IOException If an error occures.
      * @throws SourceException If the destination is not modifiable.
      * @see #copy(Source, ModifiableSource, boolean)
@@ -238,6 +236,7 @@
      * @throws ServiceException if the source resolver could not be obtained.
      * @throws MalformedURLException if the source URI is not valid.
      * @throws IOException if an error occurs.
+     * @deprecated
      */
     public static void writeDOM(Document document, String sourceUri, ServiceManager manager)
             throws TransformerConfigurationException, TransformerException, ServiceException,
@@ -262,6 +261,32 @@
     }
 
     /**
+     * Writes a DOM to a source.
+     * @param document The document.
+     * @param sourceUri The source URI.
+     * @throws TransformerConfigurationException if an error occurs.
+     * @throws TransformerException if an error occurs.
+     * @throws ServiceException if the source resolver could not be obtained.
+     * @throws MalformedURLException if the source URI is not valid.
+     * @throws IOException if an error occurs.
+     */
+    public static void writeDOM(Document document, String sourceUri, SourceResolver resolver)
+            throws TransformerConfigurationException, TransformerException, ServiceException,
+            MalformedURLException, IOException {
+        ModifiableSource source = null;
+        try {
+            source = (ModifiableSource) resolver.resolveURI(sourceUri);
+
+            OutputStream oStream = source.getOutputStream();
+            writeDOM(document, oStream);
+        } finally {
+            if (source != null) {
+                resolver.release(source);
+            }
+        }
+    }
+
+    /**
      * @param document The XML document.
      * @param oStream The output stream.
      * @throws TransformerConfigurationException if an error occurs.
@@ -288,6 +313,7 @@
      * @throws ServiceException if an error occurs.
      * @throws MalformedURLException if an error occurs.
      * @throws IOException if an error occurs.
+     * @deprecated
      */
     public static void delete(String sourceUri, ServiceManager manager) throws ServiceException,
             MalformedURLException, IOException {
@@ -312,6 +338,31 @@
     }
 
     /**
+     * Deletes a source if it exists.
+     * @param sourceUri The source URI.
+     * @throws ServiceException if an error occurs.
+     * @throws MalformedURLException if an error occurs.
+     * @throws IOException if an error occurs.
+     */
+    public static void delete(String sourceUri, SourceResolver resolver) throws ServiceException,
+            MalformedURLException, IOException {
+        ModifiableTraversableSource source = null;
+        try {
+            source = (ModifiableTraversableSource) resolver.resolveURI(sourceUri);
+            if (source.exists()) {
+                source.delete();
+            }
+
+        } finally {
+            if (resolver != null) {
+                if (source != null) {
+                    resolver.release(source);
+                }
+            }
+        }
+    }
+
+    /**
      * Deletes all empty collections in a subtree.
      * @param sourceUri The root source URI.
      * @param manager The service manager.
@@ -322,25 +373,40 @@
     public static void deleteEmptyCollections(String sourceUri, ServiceManager manager)
             throws ServiceException, MalformedURLException, IOException {
         SourceResolver resolver = null;
-        ModifiableTraversableSource source = null;
         try {
             resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+            deleteEmptyCollections(sourceUri, resolver);
+        } finally {
+            if (resolver != null) {
+                manager.release(resolver);
+            }
+        }
+    }
+
+    /**
+     * Deletes all empty collections in a subtree.
+     * @param sourceUri The root source URI.
+     * @throws ServiceException
+     * @throws MalformedURLException
+     * @throws IOException
+     */
+    public static void deleteEmptyCollections(String sourceUri, SourceResolver resolver)
+            throws ServiceException, MalformedURLException, IOException {
+        ModifiableTraversableSource source = null;
+        try {
             source = (ModifiableTraversableSource) resolver.resolveURI(sourceUri);
             if (source.isCollection()) {
                 for (Iterator i = source.getChildren().iterator(); i.hasNext();) {
                     ModifiableTraversableSource child = (ModifiableTraversableSource) i.next();
-                    deleteEmptyCollections(child.getURI(), manager);
+                    deleteEmptyCollections(child.getURI(), resolver);
                 }
                 if (source.getChildren().size() == 0) {
                     source.delete();
                 }
             }
         } finally {
-            if (resolver != null) {
-                if (source != null) {
-                    resolver.release(source);
-                }
-                manager.release(resolver);
+            if (source != null) {
+                resolver.release(source);
             }
         }
     }
@@ -383,8 +449,8 @@
      * @throws MalformedURLException if an error occurs.
      * @throws IOException if an error occurs.
      */
-    public static boolean exists(String sourceUri, SourceResolver resolver) throws ServiceException,
-            MalformedURLException, IOException {
+    public static boolean exists(String sourceUri, SourceResolver resolver)
+            throws ServiceException, MalformedURLException, IOException {
         Source source = null;
         try {
             source = resolver.resolveURI(sourceUri);
@@ -601,16 +667,15 @@
      * @throws ServiceException
      * @throws MalformedURLException
      * @throws IOException
+     * @deprecated
      */
     public static long getContentLength(String sourceUri, ServiceManager manager)
             throws ServiceException, MalformedURLException, IOException {
         SourceResolver resolver = null;
         Source source = null;
         try {
-
             resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
             source = resolver.resolveURI(sourceUri);
-
             return source.getContentLength();
         } finally {
             if (resolver != null) {
@@ -624,11 +689,52 @@
 
     /**
      * @param sourceUri The source URI.
+     * @return A content length.
+     * @throws ServiceException
+     * @throws MalformedURLException
+     * @throws IOException
+     */
+    public static long getContentLength(String sourceUri, SourceResolver resolver)
+            throws ServiceException, MalformedURLException, IOException {
+        Source source = null;
+        try {
+            source = resolver.resolveURI(sourceUri);
+            return source.getContentLength();
+        } finally {
+            if (source != null) {
+                resolver.release(source);
+            }
+        }
+    }
+
+    /**
+     * @param sourceUri The source URI.
+     * @return A mime type.
+     * @throws ServiceException
+     * @throws IOException
+     * @throws MalformedURLException
+     */
+    public static String getMimeType(String sourceUri, SourceResolver resolver)
+            throws ServiceException, MalformedURLException, IOException {
+        Source source = null;
+        try {
+            source = resolver.resolveURI(sourceUri);
+            return source.getMimeType();
+        } finally {
+            if (source != null) {
+                resolver.release(source);
+            }
+        }
+    }
+
+    /**
+     * @param sourceUri The source URI.
      * @param manager The service manager.
      * @return A mime type.
      * @throws ServiceException
      * @throws IOException
      * @throws MalformedURLException
+     * @deprecated
      */
     public static String getMimeType(String sourceUri, ServiceManager manager)
             throws ServiceException, MalformedURLException, IOException {
@@ -657,7 +763,8 @@
      * @throws MalformedURLException
      * @throws IOException
      */
-    public static void copy(SourceResolver resolver, String sourceUri, OutputStream destOutputStream) throws MalformedURLException, IOException {
+    public static void copy(SourceResolver resolver, String sourceUri, OutputStream destOutputStream)
+            throws MalformedURLException, IOException {
         boolean useBuffer = true;
         InputStream sourceInputStream = null;
         Source source = null;

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/metadata/MetaDataRegistry.java Fri Feb  6 03:16:59 2009
@@ -21,11 +21,6 @@
  * Meta data registry.
  */
 public interface MetaDataRegistry {
-    
-    /**
-     * The Avalon role.
-     */
-    String ROLE = MetaDataRegistry.class.getName();
 
     /**
      * @param namespaceUri The namespace URI of the element set.

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/observation/RepositoryEventFactory.java Fri Feb  6 03:16:59 2009
@@ -17,12 +17,12 @@
  */
 package org.apache.lenya.cms.observation;
 
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.commons.logging.Log;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.DocumentFactory;
-import org.apache.lenya.cms.publication.DocumentUtil;
+import org.apache.lenya.cms.publication.DocumentFactoryBuilder;
 import org.apache.lenya.cms.publication.Publication;
 import org.apache.lenya.cms.repository.Node;
 import org.apache.lenya.cms.repository.Session;
@@ -34,27 +34,23 @@
 
     /**
      * Creates a repository event for a node.
-     * @param manager The service manager.
      * @param session The session.
      * @param logger The logger.
      * @param descriptor The descriptor.
      * @return An event.
      */
-    public static final RepositoryEvent createEvent(ServiceManager manager,
-            Session session, Log logger, Object descriptor) {
-            return new RepositoryEvent(session, descriptor);
+    public static final RepositoryEvent createEvent(Session session, Log logger, Object descriptor) {
+        return new RepositoryEvent(session, descriptor);
     }
 
     /**
      * Creates a repository event for a node.
-     * @param manager The service manager.
      * @param doc The document.
      * @param logger The logger.
      * @param descriptor The descriptor.
      * @return An event.
      */
-    public static final RepositoryEvent createEvent(ServiceManager manager, Document doc,
-            Log logger, Object descriptor) {
+    public static final RepositoryEvent createEvent(Document doc, Log logger, Object descriptor) {
         try {
             Node node = doc.getRepositoryNode();
             RepositoryEvent event = new DocumentEvent(node.getSession(), doc.getPublication()
@@ -80,15 +76,14 @@
      * @param descriptor The descriptor.
      * @return An event.
      */
-    public static final RepositoryEvent createEvent(ServiceManager manager, Node node,
-            Log logger, Object descriptor) {
+    public static final RepositoryEvent createEvent(Node node, Log logger, Object descriptor) {
         RepositoryEvent event;
         Document doc = null;
         if (!node.getSourceURI().endsWith("meta")) {
-            doc = getDocument(manager, node, logger);
+            doc = getDocument(node, logger);
         }
         if (doc != null) {
-            event = createEvent(manager, doc, logger, descriptor);
+            event = createEvent(doc, logger, descriptor);
         } else {
             event = new RepositoryEvent(node.getSession(), descriptor);
             event.setNodeUri(node.getSourceURI());
@@ -97,13 +92,12 @@
     }
 
     /**
-     * @param manager The service manager.
      * @param node The node.
      * @param logger The logger.
-     * @return The document represented by the node or <code>null</code> if
-     *         the node doesn't represent a document.
+     * @return The document represented by the node or <code>null</code> if the node doesn't
+     *         represent a document.
      */
-    protected static final Document getDocument(ServiceManager manager, Node node, Log logger) {
+    protected static final Document getDocument(Node node, Log logger) {
 
         final String sourceUri = node.getSourceURI();
         if (sourceUri.endsWith(".xml")) {
@@ -125,8 +119,10 @@
 
         try {
 
-            DocumentFactory factory = DocumentUtil
-                    .createDocumentFactory(manager, node.getSession());
+            DocumentFactoryBuilder builder = (DocumentFactoryBuilder) WebAppContextUtils
+                    .getCurrentWebApplicationContext().getBean(
+                            DocumentFactoryBuilder.class.getName());
+            DocumentFactory factory = builder.createDocumentFactory(node.getSession());
             Publication pub = factory.getPublication(pubId);
             String docPath = path.substring((pubId + "/content/" + area).length());
 

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/NodeSet.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/NodeSet.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/NodeSet.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/NodeSet.java Fri Feb  6 03:16:59 2009
@@ -24,8 +24,7 @@
 import java.util.List;
 import java.util.Set;
 
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.Document;
 import org.apache.lenya.cms.publication.DocumentException;
 import org.apache.lenya.cms.publication.util.DocumentSet;
@@ -35,23 +34,18 @@
  */
 public class NodeSet {
 
-    private ServiceManager manager;
-
     /**
      * Ctor.
      * @param manager The service manager.
      */
-    public NodeSet(ServiceManager manager) {
-        this.manager = manager;
+    public NodeSet() {
     }
 
     /**
      * Ctor.
-     * @param manager The service manager.
      * @param _nodes The initial nodes.
      */
-    public NodeSet(ServiceManager manager, SiteNode[] _nodes) {
-        this(manager);
+    public NodeSet(SiteNode[] _nodes) {
         for (int i = 0; i < _nodes.length; i++) {
             add(_nodes[i]);
         }
@@ -167,27 +161,15 @@
         if (isEmpty()) {
             return new SiteNode[0];
         }
-        
-        SiteNode[] nodes;
-        ServiceSelector selector = null;
-        SiteManager siteManager = null;
+
         try {
-            selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(getNodes()[0].getStructure()
-                    .getPublication()
-                    .getSiteManagerHint());
-            nodes = siteManager.sortAscending(getNodes());
+            String hint = getNodes()[0].getStructure().getPublication().getSiteManagerHint();
+            SiteManager siteManager = (SiteManager) WebAppContextUtils.getCurrentWebApplicationContext().getBean(
+                    SiteManager.class.getName() + "/" + hint);
+            return siteManager.sortAscending(getNodes());
         } catch (Exception e) {
             throw new RuntimeException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                manager.release(selector);
-            }
         }
-        return nodes;
     }
 
     /**
@@ -195,7 +177,7 @@
      */
     public Document[] getDocuments() {
         List documents = new ArrayList();
-        for (NodeIterator i = iterator(); i.hasNext(); ) {
+        for (NodeIterator i = iterator(); i.hasNext();) {
             SiteNode node = i.next();
             String[] langs = node.getLanguages();
             for (int l = 0; l < langs.length; l++) {

Modified: lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/SiteUtil.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/SiteUtil.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/SiteUtil.java (original)
+++ lenya/trunk/org.apache.lenya.core.api/src/main/java/org/apache/lenya/cms/site/SiteUtil.java Fri Feb  6 03:16:59 2009
@@ -22,6 +22,7 @@
 
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.ServiceSelector;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.lenya.cms.publication.DocumentFactory;
 import org.apache.lenya.cms.publication.DocumentLocator;
 import org.apache.lenya.cms.publication.Publication;
@@ -37,22 +38,20 @@
     }
 
     /**
-     * Returns a sub-site starting with a certain node, which includes the node
-     * itself and all nodes which require this node, in preorder.
+     * Returns a sub-site starting with a certain node, which includes the node itself and all nodes
+     * which require this node, in preorder.
      * 
-     * @param manager The service manager.
      * @param node The top-level document.
      * @return A document set.
      * @throws SiteException if an error occurs.
      */
-    public static NodeSet getSubSite(ServiceManager manager, SiteNode node) throws SiteException {
-        ServiceSelector selector = null;
+    public static NodeSet getSubSite(SiteNode node) throws SiteException {
         SiteManager siteManager = null;
         SiteNode[] subsite;
         try {
-            selector = (ServiceSelector) manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(node.getStructure().getPublication()
-                    .getSiteManagerHint());
+            String hint = node.getStructure().getPublication().getSiteManagerHint();
+            siteManager = (SiteManager) WebAppContextUtils.getCurrentWebApplicationContext().getBean(
+                    SiteManager.class.getName() + "/" + hint);
 
             DocumentFactory map = node.getStructure().getPublication().getFactory();
             Set nodes = new HashSet();
@@ -66,15 +65,8 @@
             subsite = (SiteNode[]) nodes.toArray(new SiteNode[nodes.size()]);
         } catch (Exception e) {
             throw new SiteException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                manager.release(selector);
-            }
         }
-        return new NodeSet(manager, subsite);
+        return new NodeSet(subsite);
     }
 
     /**

Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentFactoryBuilderImpl.java Fri Feb  6 03:16:59 2009
@@ -40,7 +40,7 @@
         return factory;
     }
 
-    protected void setPublicationManager(PublicationManager pubManager) {
+    public void setPublicationManager(PublicationManager pubManager) {
         this.pubManager = pubManager;
     }
 
@@ -48,14 +48,14 @@
         return this.pubManager;
     }
 
-    protected MetaDataCache getMetaDataCache() {
-        return metaDataCache;
-    }
-
     public void setMetaDataCache(MetaDataCache metaDataCache) {
         this.metaDataCache = metaDataCache;
     }
 
+    protected MetaDataCache getMetaDataCache() {
+        return metaDataCache;
+    }
+
     public SourceResolver getSourceResolver() {
         return sourceResolver;
     }

Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentImpl.java Fri Feb  6 03:16:59 2009
@@ -25,7 +25,6 @@
 import java.util.Date;
 import java.util.List;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
@@ -53,6 +52,7 @@
 
     private DocumentIdentifier identifier;
     private DocumentFactory factory;
+    private NodeFactory nodeFactory;
     private int revision = -1;
 
     /**
@@ -95,8 +95,8 @@
      * @param revision The revision number or -1 if the latest revision should be used.
      * @param _logger a logger
      */
-    protected DocumentImpl(DocumentFactory map,
-            DocumentIdentifier identifier, int revision, Log logger) {
+    protected DocumentImpl(DocumentFactory map, DocumentIdentifier identifier, int revision,
+            Log logger) {
 
         if (getLogger().isDebugEnabled()) {
             getLogger().debug(
@@ -107,7 +107,7 @@
         if (identifier.getUUID() == null) {
             throw new IllegalArgumentException("The UUID must not be null!");
         }
-        
+
         this.identifier = identifier;
         this.factory = map;
         this.revision = revision;
@@ -163,7 +163,7 @@
     }
 
     private Publication publication;
-    
+
     /**
      * @see org.apache.lenya.cms.publication.Document#getPublication()
      */
@@ -434,10 +434,10 @@
                 throw new DocumentException(e);
             }
             if (name == null) {
-                throw new DocumentException("No resource type defined for document [" + this
-                        + "]!");
+                throw new DocumentException("No resource type defined for document [" + this + "]!");
             }
-            this.resourceType = (ResourceType) WebAppContextUtils.getCurrentWebApplicationContext().getBean(ResourceType.class.getName() + "/" + name);
+            this.resourceType = (ResourceType) WebAppContextUtils.getCurrentWebApplicationContext()
+                    .getBean(ResourceType.class.getName() + "/" + name);
         }
         return this.resourceType;
     }
@@ -446,10 +446,9 @@
         MetaData meta = getContentHolder().getMetaData(namespaceUri);
         if (getSession().isModifiable()) {
             return meta;
-        }
-        else {
-            String cacheKey = getPublication().getId() + ":" + getArea() + ":"
-                    + getUUID() + ":" + getLanguage();
+        } else {
+            String cacheKey = getPublication().getId() + ":" + getArea() + ":" + getUUID() + ":"
+                    + getLanguage();
             return getMetaDataCache().getMetaData(cacheKey, meta, namespaceUri);
         }
     }
@@ -545,7 +544,7 @@
      */
     public Node getRepositoryNode() {
         if (this.repositoryNode == null) {
-            this.repositoryNode = getRepositoryNode(this.manager, getFactory(), getSourceURI());
+            this.repositoryNode = getRepositoryNode(getNodeFactory(), getFactory(), getSourceURI());
         }
         return this.repositoryNode;
     }
@@ -563,19 +562,13 @@
         }
     }
 
-    protected static Node getRepositoryNode(ServiceManager manager, DocumentFactory docFactory,
+    protected static Node getRepositoryNode(NodeFactory nodeFactory, DocumentFactory docFactory,
             String sourceUri) {
         Session session = docFactory.getSession();
-        NodeFactory factory = null;
         try {
-            factory = (NodeFactory) manager.lookup(NodeFactory.ROLE);
-            return (Node) session.getRepositoryItem(factory, sourceUri);
+            return (Node) session.getRepositoryItem(nodeFactory, sourceUri);
         } catch (Exception e) {
             throw new RuntimeException("Creating repository node failed: ", e);
-        } finally {
-            if (factory != null) {
-                manager.release(factory);
-            }
         }
     }
 
@@ -594,7 +587,7 @@
     public boolean existsVersion(String area, String language) {
         String sourceUri = getSourceURI(getPublication(), area, getUUID(), language);
         try {
-            return SourceUtil.exists(sourceUri, this.manager);
+            return SourceUtil.exists(sourceUri, getSourceResolver());
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -708,4 +701,12 @@
         this.resolver = resolver;
     }
 
+    public NodeFactory getNodeFactory() {
+        return nodeFactory;
+    }
+
+    public void setNodeFactory(NodeFactory nodeFactory) {
+        this.nodeFactory = nodeFactory;
+    }
+
 }
\ No newline at end of file

Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/java/org/apache/lenya/cms/publication/DocumentManagerImpl.java Fri Feb  6 03:16:59 2009
@@ -30,13 +30,7 @@
 import java.util.Map;
 import java.util.Set;
 
-import org.apache.avalon.framework.context.Context;
-import org.apache.avalon.framework.context.ContextException;
-import org.apache.avalon.framework.context.Contextualizable;
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.ServiceSelector;
-import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.io.output.ByteArrayOutputStream;
@@ -47,6 +41,7 @@
 import org.apache.lenya.cms.publication.util.DocumentSet;
 import org.apache.lenya.cms.publication.util.DocumentVisitor;
 import org.apache.lenya.cms.repository.Node;
+import org.apache.lenya.cms.repository.NodeFactory;
 import org.apache.lenya.cms.repository.RepositoryException;
 import org.apache.lenya.cms.repository.UUIDGenerator;
 import org.apache.lenya.cms.site.Link;
@@ -64,13 +59,16 @@
  * 
  * @version $Id$
  */
-public class DocumentManagerImpl extends AbstractLogEnabled implements DocumentManager,
-        Serviceable, Contextualizable {
+public class DocumentManagerImpl extends AbstractLogEnabled implements DocumentManager {
+
+    private SourceResolver sourceResolver;
+    private UUIDGenerator uuidGenerator;
+    private NodeFactory nodeFactory;
 
     /**
      * @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.Document,
-     *      java.lang.String, java.lang.String, java.lang.String,
-     *      java.lang.String, java.lang.String, boolean)
+     *      java.lang.String, java.lang.String, java.lang.String, java.lang.String,
+     *      java.lang.String, boolean)
      */
     public Document add(Document sourceDocument, String area, String path, String language,
             String extension, String navigationTitle, boolean visibleInNav)
@@ -85,9 +83,8 @@
     }
 
     /**
-     * Copies meta data from one document to another. If the destination
-     * document is a different area version, the meta data are duplicated (i.e.,
-     * onCopy = delete is neglected).
+     * Copies meta data from one document to another. If the destination document is a different
+     * area version, the meta data are duplicated (i.e., onCopy = delete is neglected).
      * @param source
      * @param destination
      * @throws PublicationException
@@ -115,9 +112,8 @@
     /**
      * @see org.apache.lenya.cms.publication.DocumentManager#add(org.apache.lenya.cms.publication.DocumentFactory,
      *      org.apache.lenya.cms.publication.ResourceType, java.lang.String,
-     *      org.apache.lenya.cms.publication.Publication, java.lang.String,
-     *      java.lang.String, java.lang.String, java.lang.String,
-     *      java.lang.String, boolean)
+     *      org.apache.lenya.cms.publication.Publication, java.lang.String, java.lang.String,
+     *      java.lang.String, java.lang.String, java.lang.String, boolean)
      */
     public Document add(DocumentFactory factory, ResourceType documentType,
             String initialContentsURI, Publication pub, String area, String path, String language,
@@ -140,8 +136,8 @@
 
     protected Document add(DocumentFactory factory, ResourceType documentType,
             InputStream initialContentsStream, Publication pub, String area, String path,
-            String language, String extension, String navigationTitle, boolean visibleInNav, String mimeType)
-            throws DocumentBuildException, DocumentException, PublicationException {
+            String language, String extension, String navigationTitle, boolean visibleInNav,
+            String mimeType) throws DocumentBuildException, DocumentException, PublicationException {
 
         Area areaObj = pub.getArea(area);
         SiteStructure site = areaObj.getSite();
@@ -162,22 +158,17 @@
             String extension) throws DocumentBuildException, DocumentException,
             PublicationException {
 
-        String uuid = generateUUID();
-        SourceResolver resolver = null;
+        String uuid = getUuidGenerator().nextUUID();
         Source source = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            source = resolver.resolveURI(initialContentsURI);
+            source = getSourceResolver().resolveURI(initialContentsURI);
             return add(factory, documentType, uuid, source.getInputStream(), pub, area, language,
                     extension, getMimeType(source));
         } catch (Exception e) {
             throw new PublicationException(e);
         } finally {
-            if (resolver != null) {
-                if (source != null) {
-                    resolver.release(source);
-                }
-                this.manager.release(resolver);
+            if (source != null) {
+                getSourceResolver().release(source);
             }
         }
     }
@@ -195,14 +186,14 @@
             String extension, String mimeType) throws DocumentBuildException, DocumentException,
             PublicationException {
 
-        String uuid = generateUUID();
+        String uuid = getUuidGenerator().nextUUID();
         return add(factory, documentType, uuid, initialContentsStream, pub, area, language,
                 extension, mimeType);
     }
 
     protected Document add(DocumentFactory factory, ResourceType documentType, String uuid,
-            InputStream stream, Publication pub, String area, String language, String extension, String mimeType)
-            throws DocumentBuildException {
+            InputStream stream, Publication pub, String area, String language, String extension,
+            String mimeType) throws DocumentBuildException {
         try {
 
             if (exists(factory, pub, area, uuid, language)) {
@@ -234,24 +225,6 @@
         }
     }
 
-    protected String generateUUID() throws DocumentBuildException {
-        String uuid;
-        UUIDGenerator generator = null;
-        try {
-
-            generator = (UUIDGenerator) this.manager.lookup(UUIDGenerator.ROLE);
-            uuid = generator.nextUUID();
-
-        } catch (Exception e) {
-            throw new DocumentBuildException("call to creator for new document failed", e);
-        } finally {
-            if (generator != null) {
-                this.manager.release(generator);
-            }
-        }
-        return uuid;
-    }
-
     protected void create(InputStream stream, Document document) throws Exception {
 
         // Read initial contents as DOM
@@ -260,15 +233,7 @@
                     "DefaultCreator::create(), ready to read initial contents from URI [" + stream
                             + "]");
 
-        SourceResolver resolver = null;
-        try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            copy(resolver, stream, document);
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
-        }
+        copy(getSourceResolver(), stream, document);
     }
 
     protected void copy(SourceResolver resolver, InputStream sourceInputStream, Document destination)
@@ -315,9 +280,8 @@
     }
 
     /**
-     * Template method to copy a document. Override
-     * {@link #copyDocumentSource(Document, Document)} to implement access to a
-     * custom repository.
+     * Template method to copy a document. Override {@link #copyDocumentSource(Document, Document)}
+     * to implement access to a custom repository.
      * @see org.apache.lenya.cms.publication.DocumentManager#copy(org.apache.lenya.cms.publication.Document,
      *      org.apache.lenya.cms.publication.DocumentLocator)
      */
@@ -480,31 +444,6 @@
         }
     }
 
-    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;
-    }
-
-    private Context context;
-
-    /**
-     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
-     */
-    public void contextualize(Context _context) throws ContextException {
-        this.context = _context;
-    }
-
-    /**
-     * @return The Avalon context.
-     */
-    protected Context getContext() {
-        return this.context;
-    }
-
     public void moveAll(Area sourceArea, String sourcePath, Area targetArea, String targetPath)
             throws PublicationException {
         SiteStructure site = sourceArea.getSite();
@@ -525,15 +464,15 @@
                     + subPath);
         }
     }
-    
+
     protected List preOrder(SiteNode node) {
-    	List list = new ArrayList();
-    	list.add(node);
-    	SiteNode[] children = node.getChildren();
-    	for (int i = 0; i < children.length; i++) {
-    		list.addAll(preOrder(children[i]));
-    	}
-    	return list;
+        List list = new ArrayList();
+        list.add(node);
+        SiteNode[] children = node.getChildren();
+        for (int i = 0; i < children.length; i++) {
+            list.addAll(preOrder(children[i]));
+        }
+        return list;
     }
 
     public void moveAllLanguageVersions(Area sourceArea, String sourcePath, Area targetArea,
@@ -564,7 +503,8 @@
         targetNode.setVisible(sourceNode.isVisible());
     }
 
-    protected void copyRevisions(Document sourceDoc, Document targetDoc) throws PublicationException {
+    protected void copyRevisions(Document sourceDoc, Document targetDoc)
+            throws PublicationException {
         try {
             Node targetNode = targetDoc.getRepositoryNode();
             targetNode.copyRevisionsFrom(sourceDoc.getRepositoryNode());
@@ -578,9 +518,9 @@
 
         SiteStructure site = sourceArea.getSite();
         SiteNode root = site.getNode(sourcePath);
-        
+
         List preOrder = preOrder(root);
-        for (Iterator i = preOrder.iterator(); i.hasNext(); ) {
+        for (Iterator i = preOrder.iterator(); i.hasNext();) {
             SiteNode node = (SiteNode) i.next();
             String nodeSourcePath = node.getPath();
             String nodeTargetPath = targetPath + nodeSourcePath.substring(sourcePath.length());
@@ -659,8 +599,7 @@
     }
 
     /**
-     * Abstract base class for document visitors which operate on a source and
-     * target document.
+     * Abstract base class for document visitors which operate on a source and target document.
      */
     public static abstract class SourceTargetVisitor implements DocumentVisitor {
 
@@ -702,8 +641,7 @@
         }
 
         /**
-         * Returns the target corresponding to a source relatively to the root
-         * target document.
+         * Returns the target corresponding to a source relatively to the root target document.
          * @param source The source.
          * @return A document.
          * @throws DocumentBuildException if the target could not be built.
@@ -724,31 +662,13 @@
      * @see org.apache.lenya.cms.publication.DocumentManager#deleteAll(org.apache.lenya.cms.publication.Document)
      */
     public void deleteAll(Document document) throws PublicationException {
-
-        SiteManager siteManager = null;
-        ServiceSelector selector = null;
-        try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            siteManager = (SiteManager) selector.select(document.getPublication()
-                    .getSiteManagerHint());
-
-            NodeSet subsite = SiteUtil.getSubSite(this.manager, document.getLink().getNode());
-            for (NodeIterator i = subsite.descending(); i.hasNext();) {
-                SiteNode node = i.next();
-                String[] languages = node.getLanguages();
-                for (int l = 0; l < languages.length; l++) {
-                    Document doc = node.getLink(languages[l]).getDocument();
-                    delete(doc);
-                }
-            }
-        } catch (ServiceException e) {
-            throw new PublicationException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
+        NodeSet subsite = SiteUtil.getSubSite(document.getLink().getNode());
+        for (NodeIterator i = subsite.descending(); i.hasNext();) {
+            SiteNode node = i.next();
+            String[] languages = node.getLanguages();
+            for (int l = 0; l < languages.length; l++) {
+                Document doc = node.getLink(languages[l]).getDocument();
+                delete(doc);
             }
         }
     }
@@ -802,29 +722,12 @@
             return;
         }
 
-        SiteManager siteManager = null;
-        ServiceSelector selector = null;
-        try {
-            selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-            Publication pub = documents.getDocuments()[0].getPublication();
-            siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
-
-            DocumentSet set = new DocumentSet(documents.getDocuments());
-            sortAscending(set);
-            set.reverse();
-
-            DocumentVisitor visitor = new DeleteVisitor(this);
-            set.visit(visitor);
-        } catch (ServiceException e) {
-            throw new PublicationException(e);
-        } finally {
-            if (selector != null) {
-                if (siteManager != null) {
-                    selector.release(siteManager);
-                }
-                this.manager.release(selector);
-            }
-        }
+        DocumentSet set = new DocumentSet(documents.getDocuments());
+        sortAscending(set);
+        set.reverse();
+
+        DocumentVisitor visitor = new DeleteVisitor(this);
+        set.visit(visitor);
 
     }
 
@@ -839,20 +742,17 @@
          * Document[] sourceDocs = sources.getDocuments(); Document[] targetDocs =
          * destinations.getDocuments();
          * 
-         * if (sourceDocs.length != targetDocs.length) { throw new
-         * PublicationException( "The number of source and destination documents
-         * must be equal!"); }
+         * if (sourceDocs.length != targetDocs.length) { throw new PublicationException( "The number
+         * of source and destination documents must be equal!"); }
          * 
-         * Map source2target = new HashMap(); for (int i = 0; i <
-         * sourceDocs.length; i++) { source2target.put(sourceDocs[i],
-         * targetDocs[i]); }
+         * Map source2target = new HashMap(); for (int i = 0; i < sourceDocs.length; i++) {
+         * source2target.put(sourceDocs[i], targetDocs[i]); }
          * 
          * DocumentSet sortedSources = new DocumentSet(sourceDocs);
-         * SiteUtil.sortAscending(this.manager, sortedSources); Document[]
-         * sortedSourceDocs = sortedSources.getDocuments();
+         * SiteUtil.sortAscending(this.manager, sortedSources); Document[] sortedSourceDocs =
+         * sortedSources.getDocuments();
          * 
-         * for (int i = 0; i < sortedSourceDocs.length; i++) {
-         * move(sortedSourceDocs[i], (Document)
+         * for (int i = 0; i < sortedSourceDocs.length; i++) { move(sortedSourceDocs[i], (Document)
          * source2target.get(sortedSourceDocs[i])); }
          */
     }
@@ -893,43 +793,30 @@
             int n = docs.length;
 
             Publication pub = docs[0].getPublication();
-            SiteManager siteManager = null;
-            ServiceSelector selector = null;
-            try {
-                selector = (ServiceSelector) this.manager.lookup(SiteManager.ROLE + "Selector");
-                siteManager = (SiteManager) selector.select(pub.getSiteManagerHint());
+            SiteManager siteManager = (SiteManager) WebAppContextUtils.getCurrentWebApplicationContext()
+                .getBean(SiteManager.class.getName() + "/" + pub.getSiteManagerHint());
 
-                Set nodes = new HashSet();
-                for (int i = 0; i < docs.length; i++) {
-                    nodes.add(docs[i].getLink().getNode());
-                }
-
-                SiteNode[] ascending = siteManager.sortAscending((SiteNode[]) nodes
-                        .toArray(new SiteNode[nodes.size()]));
-
-                set.clear();
-                for (int i = 0; i < ascending.length; i++) {
-                    for (int d = 0; d < docs.length; d++) {
-                        if (docs[d].getPath().equals(ascending[i].getPath())) {
-                            set.add(docs[d]);
-                        }
+            Set nodes = new HashSet();
+            for (int i = 0; i < docs.length; i++) {
+                nodes.add(docs[i].getLink().getNode());
+            }
+
+            SiteNode[] ascending = siteManager.sortAscending((SiteNode[]) nodes
+                    .toArray(new SiteNode[nodes.size()]));
+
+            set.clear();
+            for (int i = 0; i < ascending.length; i++) {
+                for (int d = 0; d < docs.length; d++) {
+                    if (docs[d].getPath().equals(ascending[i].getPath())) {
+                        set.add(docs[d]);
                     }
                 }
+            }
 
-                if (set.getDocuments().length != n) {
-                    throw new IllegalStateException("Number of documents has changed!");
-                }
-
-            } catch (final ServiceException e) {
-                throw new PublicationException(e);
-            } finally {
-                if (selector != null) {
-                    if (siteManager != null) {
-                        selector.release(siteManager);
-                    }
-                    this.manager.release(selector);
-                }
+            if (set.getDocuments().length != n) {
+                throw new IllegalStateException("Number of documents has changed!");
             }
+
         }
     }
 
@@ -951,7 +838,7 @@
         Document document = add(sourceDocument.getFactory(), sourceDocument.getResourceType(),
                 sourceDocument.getUUID(), sourceDocument.getInputStream(), sourceDocument
                         .getPublication(), area, language, sourceDocument.getSourceExtension(),
-                        sourceDocument.getMimeType());
+                sourceDocument.getMimeType());
         copyMetaData(sourceDocument, document);
 
         return document;
@@ -961,11 +848,35 @@
             String language) throws PublicationException {
         String sourceUri = DocumentImpl.getSourceURI(pub, area, uuid, language);
         try {
-            Node node = DocumentImpl.getRepositoryNode(this.manager, factory, sourceUri);
+            Node node = DocumentImpl.getRepositoryNode(getNodeFactory(), factory, sourceUri);
             return node.exists();
         } catch (RepositoryException e) {
             throw new PublicationException(e);
         }
     }
 
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
+    public UUIDGenerator getUuidGenerator() {
+        return uuidGenerator;
+    }
+
+    public void setUuidGenerator(UUIDGenerator uuidGenerator) {
+        this.uuidGenerator = uuidGenerator;
+    }
+
+    public NodeFactory getNodeFactory() {
+        return nodeFactory;
+    }
+
+    public void setNodeFactory(NodeFactory nodeFactory) {
+        this.nodeFactory = nodeFactory;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.core.impl/src/main/resources/META-INF/cocoon/spring/lenya-core-impl-components.xml
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.core.impl/src/main/resources/META-INF/cocoon/spring/lenya-core-impl-components.xml?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.core.impl/src/main/resources/META-INF/cocoon/spring/lenya-core-impl-components.xml (original)
+++ lenya/trunk/org.apache.lenya.core.impl/src/main/resources/META-INF/cocoon/spring/lenya-core-impl-components.xml Fri Feb  6 03:16:59 2009
@@ -35,6 +35,12 @@
     <property name="metaDataCache" ref="org.apache.lenya.cms.metadata.MetaDataCache"/>
     <property name="sourceResolver" ref="org.apache.excalibur.source.SourceResolver"/>
   </bean>
+  <bean name="org.apache.lenya.cms.publication.DocumentManager"
+    class="org.apache.lenya.cms.publication.DocumentManagerImpl">
+    <property name="sourceResolver" ref="org.apache.excalibur.source.SourceResolver"/>
+    <property name="nodeFactory" ref="org.apache.lenya.cms.repository.NodeFactory"/>
+    <property name="uuidGenerator" ref="org.apache.lenya.cms.repository.UUIDGenerator"/>
+  </bean>
   <bean name="org.apache.lenya.cms.module.ModuleManager"
     class="org.apache.lenya.cms.module.ModuleManagerImpl"/>
   <bean name="org.apache.lenya.cms.repository.SharedItemStore"

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ContentSourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ContentSourceWrapper.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ContentSourceWrapper.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ContentSourceWrapper.java Fri Feb  6 03:16:59 2009
@@ -17,8 +17,8 @@
  */
 package org.apache.lenya.cms.repository;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.commons.logging.Log;
+import org.apache.excalibur.source.SourceResolver;
 
 /**
  * Content source wrapper.
@@ -29,11 +29,11 @@
      * Ctor.
      * @param node
      * @param sourceURI
-     * @param manager
+     * @param resolver 
      * @param logger
      */
-    public ContentSourceWrapper(SourceNode node, String sourceURI, ServiceManager manager, Log logger) {
-        super(node, sourceURI, manager, logger);
+    public ContentSourceWrapper(SourceNode node, String sourceURI, SourceResolver resolver, Log logger) {
+        super(node, sourceURI, resolver, logger);
     }
 
 }

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/MetaSourceWrapper.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/MetaSourceWrapper.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/MetaSourceWrapper.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/MetaSourceWrapper.java Fri Feb  6 03:16:59 2009
@@ -17,8 +17,8 @@
  */
 package org.apache.lenya.cms.repository;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.commons.logging.Log;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.metadata.MetaData;
 import org.apache.lenya.cms.metadata.MetaDataException;
 import org.apache.lenya.cms.metadata.MetaDataOwner;
@@ -34,13 +34,13 @@
      * Ctor.
      * @param node
      * @param sourceURI
-     * @param manager
+     * @param resolver
      * @param logger
      */
-    public MetaSourceWrapper(SourceNode node, String sourceURI, ServiceManager manager,
+    public MetaSourceWrapper(SourceNode node, String sourceURI, SourceResolver resolver,
             Log logger) {
-        super(node, sourceURI + "." + LENYA_META_SUFFIX, manager, logger);
-        this.handler = new ModifiableMetaDataHandler(manager, this);
+        super(node, sourceURI + "." + LENYA_META_SUFFIX, resolver, logger);
+        this.handler = new ModifiableMetaDataHandler(this, resolver);
     }
     
     private ModifiableMetaDataHandler handler;

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/ModifiableMetaDataHandler.java Fri Feb  6 03:16:59 2009
@@ -23,7 +23,7 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.metadata.MetaDataException;
 import org.apache.lenya.xml.DocumentHelper;
 import org.apache.lenya.xml.NamespaceHelper;
@@ -41,8 +41,8 @@
      * @param manager The service manager.
      * @param sourceWrapper The source wrapper.
      */
-    public ModifiableMetaDataHandler(ServiceManager manager, MetaSourceWrapper sourceWrapper) {
-        super(manager, sourceWrapper.getRealSourceUri(), sourceWrapper.getNode());
+    public ModifiableMetaDataHandler(MetaSourceWrapper sourceWrapper, SourceResolver resolver) {
+        super(sourceWrapper.getRealSourceUri(), sourceWrapper.getNode(), resolver);
         this.sourceWrapper = sourceWrapper;
         try {
             this.sourceWrapper.getNode().setPersistable(this);

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNode.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNode.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNode.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNode.java Fri Feb  6 03:16:59 2009
@@ -21,8 +21,6 @@
 import java.io.OutputStream;
 import java.util.Collection;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
 import org.apache.excalibur.source.SourceResolver;
@@ -35,7 +33,6 @@
 import org.apache.lenya.cms.observation.RepositoryEvent;
 import org.apache.lenya.cms.observation.RepositoryEventFactory;
 import org.apache.lenya.cms.rc.CheckInEntry;
-import org.apache.lenya.cms.rc.CheckOutEntry;
 import org.apache.lenya.cms.rc.RCML;
 import org.apache.lenya.cms.rc.RCMLEntry;
 import org.apache.lenya.cms.rc.RevisionControlException;
@@ -50,25 +47,23 @@
  */
 public class SourceNode extends AbstractLogEnabled implements Node, Transactionable {
 
-    protected ServiceManager manager;
-
     private ContentSourceWrapper contentSource;
     private MetaSourceWrapper metaSource;
+    private NodeFactory nodeFactory;
+    private SourceResolver sourceResolver;
 
     /**
      * Ctor.
      * 
      * @param session
      * @param sourceUri
-     * @param manager
      * @param logger
      */
-    public SourceNode(Session session, String sourceUri, ServiceManager manager, Log logger) {
-        this.manager = manager;
+    public SourceNode(Session session, String sourceUri, SourceResolver resolver, Log logger) {
         this.session = session;
 
-        this.contentSource = new ContentSourceWrapper(this, sourceUri, manager, logger);
-        this.metaSource = new MetaSourceWrapper(this, sourceUri, manager, logger);
+        this.contentSource = new ContentSourceWrapper(this, sourceUri, resolver, logger);
+        this.metaSource = new MetaSourceWrapper(this, sourceUri, resolver, logger);
     }
 
     protected ContentSourceWrapper getContentSource() {
@@ -211,21 +206,13 @@
      * @throws ServiceException
      * @throws RepositoryException
      */
-    protected Node getDocumentNode() throws ServiceException, RepositoryException {
+    protected Node getDocumentNode() throws RepositoryException {
         Node node;
         String sourceUri = getSourceURI();
         if (sourceUri.endsWith(".meta")) {
             String documentSourceUri = sourceUri
                     .substring(0, sourceUri.length() - ".meta".length());
-            NodeFactory factory = null;
-            try {
-                factory = (NodeFactory) this.manager.lookup(NodeFactory.ROLE);
-                node = (Node) factory.buildItem(getSession(), documentSourceUri);
-            } finally {
-                if (factory != null) {
-                    this.manager.release(factory);
-                }
-            }
+            node = (Node) getNodeFactory().buildItem(getSession(), documentSourceUri);
         } else {
             node = this;
         }
@@ -298,18 +285,17 @@
      * 
      */
     public Collection getChildren() throws RepositoryException {
-        SourceResolver resolver = null;
         TraversableSource source = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
+            source = (TraversableSource) getSourceResolver().resolveURI(
+                    this.contentSource.getRealSourceUri());
             Collection children = source.getChildren();
             java.util.Iterator iterator = children.iterator();
             java.util.Vector newChildren = new java.util.Vector();
             while (iterator.hasNext()) {
                 TraversableSource child = (TraversableSource) iterator.next();
                 newChildren.add(new SourceNode(getSession(),
-                        getSourceURI() + "/" + child.getName(), this.manager, getLogger()));
+                        getSourceURI() + "/" + child.getName(), getSourceResolver(), getLogger()));
             }
             return newChildren;
         } catch (Exception e) {
@@ -321,11 +307,10 @@
      * 
      */
     public boolean isCollection() throws RepositoryException {
-        SourceResolver resolver = null;
         TraversableSource source = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            source = (TraversableSource) resolver.resolveURI(this.contentSource.getRealSourceUri());
+            source = (TraversableSource) getSourceResolver().resolveURI(
+                    this.contentSource.getRealSourceUri());
             return source.isCollection();
         } catch (Exception e) {
             throw new RepositoryException(e);
@@ -360,7 +345,7 @@
     }
 
     protected void enqueueEvent(Object descriptor) {
-        RepositoryEvent event = RepositoryEventFactory.createEvent(this.manager, this, getLogger(),
+        RepositoryEvent event = RepositoryEventFactory.createEvent(this, getLogger(),
                 descriptor);
         getSession().enqueueEvent(event);
     }
@@ -380,13 +365,13 @@
     protected synchronized RCML getRcml() {
         if (this.rcml == null) {
             SourceNodeRcmlFactory factory = SourceNodeRcmlFactory.getInstance();
-            this.rcml = factory.getRcml(this, this.manager);
+            this.rcml = factory.getRcml(this);
         }
         return this.rcml;
     }
 
     public History getHistory() {
-        return new SourceNodeHistory(this, this.manager, getLogger());
+        return new SourceNodeHistory(this, getSourceResolver(), getLogger());
     }
 
     public MetaData getMetaData(String namespaceUri) throws MetaDataException {
@@ -431,8 +416,7 @@
             CheckInEntry entry = getRcml().getLatestCheckInEntry();
             if (entry != null) {
                 return entry.getTime();
-            }
-            else {
+            } else {
                 throw new RepositoryException("The node [" + this + "] hasn't been checked in yet.");
             }
         } catch (RepositoryException e) {
@@ -523,4 +507,20 @@
         return getSourceURI();
     }
 
+    protected NodeFactory getNodeFactory() {
+        return nodeFactory;
+    }
+
+    protected void setNodeFactory(NodeFactory nodeFactory) {
+        this.nodeFactory = nodeFactory;
+    }
+
+    protected SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    protected void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+
 }

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeFactory.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeFactory.java Fri Feb  6 03:16:59 2009
@@ -17,21 +17,17 @@
  */
 package org.apache.lenya.cms.repository;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
-import org.apache.avalon.framework.service.Serviceable;
-import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.excalibur.source.SourceResolver;
 
 /**
  * Factory to create source nodes.
  * 
  * @version $Id$
  */
-public class SourceNodeFactory extends AbstractLogEnabled implements NodeFactory, Serviceable,
-        ThreadSafe {
-
-    private ServiceManager manager;
+public class SourceNodeFactory extends AbstractLogEnabled implements NodeFactory {
+    
+    private SourceResolver sourceResolver;
 
     /**
      * Ctor.
@@ -40,18 +36,19 @@
     }
 
     public RepositoryItem buildItem(Session session, String key) throws RepositoryException {
-        return new SourceNode(session, key, this.manager, getLogger());
+        return new SourceNode(session, key, getSourceResolver(), getLogger());
     }
 
     public String getItemType() {
         return Node.IDENTIFIABLE_TYPE;
     }
 
-    /**
-     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
-    public void service(ServiceManager manager) throws ServiceException {
-        this.manager = manager;
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
     }
 
 }

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeHistory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeHistory.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeHistory.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeHistory.java Fri Feb  6 03:16:59 2009
@@ -19,10 +19,9 @@
 
 import java.util.Vector;
 
-import org.apache.avalon.framework.container.ContainerUtil;
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.commons.logging.Log;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.rc.CheckInEntry;
 import org.apache.lenya.cms.rc.RCML;
 
@@ -32,17 +31,17 @@
 public class SourceNodeHistory extends AbstractLogEnabled implements History {
 
     private SourceNode node;
-    private ServiceManager manager;
+    private SourceResolver sourceResolver;
 
     /**
      * Ctor.
      * @param node The node which the history belongs to.
-     * @param manager The service manager.
      * @param logger The logger.
      */
-    public SourceNodeHistory(SourceNode node, ServiceManager manager, Log logger) {
+    public SourceNodeHistory(SourceNode node, SourceResolver resolver, Log logger) {
         this.node = node;
-        this.manager = manager;
+        this.sourceResolver = resolver;
+        setLogger(logger);
     }
 
     public Revision getLatestRevision() {
@@ -60,7 +59,7 @@
     }
 
     public Revision getRevision(int number) throws RepositoryException {
-        return new SourceNodeRevision(this.node, number, this.manager, getLogger());
+        return new SourceNodeRevision(this.node, number, this.sourceResolver, getLogger());
     }
 
     public int[] getRevisionNumbers() {

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaData.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaData.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaData.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaData.java Fri Feb  6 03:16:59 2009
@@ -21,7 +21,6 @@
 import java.util.HashSet;
 import java.util.Set;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.lenya.cms.metadata.Element;
 import org.apache.lenya.cms.metadata.ElementSet;
@@ -35,20 +34,19 @@
 public class SourceNodeMetaData extends AbstractLogEnabled implements MetaData {
 
     private String namespaceUri;
-    private ServiceManager manager;
     private SourceNodeMetaDataHandler handler;
+    private MetaDataRegistry registry;
 
     /**
      * Ctor.
      * @param namespaceUri The namespace URI.
      * @param handler The meta data handler.
-     * @param manager The service manager.
      */
     public SourceNodeMetaData(String namespaceUri, SourceNodeMetaDataHandler handler,
-            ServiceManager manager) {
+            MetaDataRegistry registry) {
         this.namespaceUri = namespaceUri;
         this.handler = handler;
-        this.manager = manager;
+        this.registry = registry;
     }
 
     protected String getNamespaceUri() {
@@ -64,9 +62,7 @@
     public ElementSet getElementSet() {
         if (this.elementSet == null) {
             try {
-                MetaDataRegistry registry = (MetaDataRegistry) this.manager
-                        .lookup(MetaDataRegistry.ROLE);
-                this.elementSet = registry.getElementSet(this.namespaceUri);
+                this.elementSet = this.registry.getElementSet(this.namespaceUri);
             } catch (Exception e) {
                 throw new RuntimeException(e);
             }

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeMetaDataHandler.java Fri Feb  6 03:16:59 2009
@@ -22,8 +22,8 @@
 import java.util.List;
 import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceException;
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.metadata.ElementSet;
 import org.apache.lenya.cms.metadata.MetaData;
@@ -42,19 +42,19 @@
  */
 public class SourceNodeMetaDataHandler implements MetaDataOwner {
 
-    private ServiceManager manager;
     private ContentHolder content;
     private String sourceUri;
+    private SourceResolver sourceResolver;
 
     /**
-     * @param manager The service manager.
      * @param sourceUri The source URI.
      * @param content The content these meta data apply for.
      */
-    public SourceNodeMetaDataHandler(ServiceManager manager, String sourceUri, ContentHolder content) {
-        this.manager = manager;
+    public SourceNodeMetaDataHandler(String sourceUri, ContentHolder content,
+            SourceResolver resolver) {
         this.sourceUri = sourceUri;
         this.content = content;
+        this.sourceResolver = resolver;
     }
 
     private Map namespace2metadata = new HashMap();
@@ -63,24 +63,15 @@
 
         MetaData meta = (MetaData) this.namespace2metadata.get(namespaceUri);
         if (meta == null) {
-            
-            MetaDataRegistry registry = null;
-            try {
-                registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
-                if (!registry.isRegistered(namespaceUri)) {
-                    throw new MetaDataException("The namespace [" + namespaceUri
-                            + "] is not registered!");
-                }
-            } catch (ServiceException e) {
-                throw new MetaDataException(e);
-            } finally {
-                if (registry != null) {
-                    this.manager.release(registry);
-                }
+
+            MetaDataRegistry registry = getMetaDataRegistry();
+            if (!registry.isRegistered(namespaceUri)) {
+                throw new MetaDataException("The namespace [" + namespaceUri
+                        + "] is not registered!");
             }
-            
+
             synchronized (this) {
-                meta = new SourceNodeMetaData(namespaceUri, this, this.manager);
+                meta = new SourceNodeMetaData(namespaceUri, this, registry);
                 this.namespace2metadata.put(namespaceUri, meta);
             }
         }
@@ -117,8 +108,8 @@
 
         try {
             this.namespace2metamap = new HashMap();
-            if (SourceUtil.exists(this.sourceUri, this.manager)) {
-                Document xml = SourceUtil.readDOM(this.sourceUri, this.manager);
+            if (SourceUtil.exists(this.sourceUri, this.sourceResolver)) {
+                Document xml = SourceUtil.readDOM(this.sourceUri, this.sourceResolver);
                 if (!xml.getDocumentElement().getNamespaceURI().equals(META_DATA_NAMESPACE)) {
                     loadLegacyMetaData(xml);
                 } else {
@@ -176,9 +167,8 @@
         Element dcElement = helper.getFirstChild(metaElement, "dc");
 
         if (dcElement != null) {
-            MetaDataRegistry registry = null;
+            MetaDataRegistry registry = getMetaDataRegistry();
             try {
-                registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
                 ElementSet dcElementSet = registry.getElementSet(DublinCore.DC_NAMESPACE);
                 ElementSet dcTermSet = registry.getElementSet(DublinCore.DCTERMS_NAMESPACE);
 
@@ -203,15 +193,21 @@
                 throw e;
             } catch (Exception e) {
                 throw new MetaDataException(e);
-            } finally {
-                if (registry != null) {
-                    this.manager.release(registry);
-                }
             }
         }
 
     }
 
+    private MetaDataRegistry registry;
+
+    protected MetaDataRegistry getMetaDataRegistry() {
+        if (this.registry == null) {
+            this.registry = (MetaDataRegistry) WebAppContextUtils.getCurrentWebApplicationContext()
+                    .getBean(MetaDataRegistry.class.getName());
+        }
+        return this.registry;
+    }
+
     protected String[] getValues(String namespaceUri, String key, int revisionNumber)
             throws MetaDataException {
         List values = getValueList(namespaceUri, key);
@@ -248,17 +244,7 @@
     }
 
     public String[] getMetaDataNamespaceUris() throws MetaDataException {
-        MetaDataRegistry registry = null;
-        try {
-            registry = (MetaDataRegistry) this.manager.lookup(MetaDataRegistry.ROLE);
-            return registry.getNamespaceUris();
-        } catch (ServiceException e) {
-            throw new MetaDataException(e);
-        } finally {
-            if (registry != null) {
-                this.manager.release(registry);
-            }
-        }
+        return getMetaDataRegistry().getNamespaceUris();
     }
 
     protected long getLastModified() throws RepositoryException {

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRCML.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRCML.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRCML.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRCML.java Fri Feb  6 03:16:59 2009
@@ -29,7 +29,6 @@
 import java.util.Map;
 import java.util.Vector;
 
-import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.lenya.cms.rc.CheckInEntry;
@@ -54,11 +53,11 @@
     private int maximalNumberOfEntries = 5;
     private Vector entries;
 
-    private ServiceManager manager;
-
     private String contentSourceUri;
     private String metaSourceUri;
 
+    private SourceResolver sourceResolver;
+
     private static Map ELEMENTS = new HashMap();
     protected static final String ELEMENT_CHECKIN = "CheckIn";
     protected static final String ELEMENT_CHECKOUT = "CheckOut";
@@ -85,12 +84,12 @@
      * @param metaSourceUri The meta source URI.
      * @param manager The service manager.
      */
-    public SourceNodeRCML(String contentSourceUri, String metaSourceUri, ServiceManager manager) {
+    public SourceNodeRCML(String contentSourceUri, String metaSourceUri, SourceResolver resolver) {
         this.maximalNumberOfEntries = 200;
         this.maximalNumberOfEntries = (2 * this.maximalNumberOfEntries) + 1;
-        this.manager = manager;
         this.contentSourceUri = contentSourceUri;
         this.metaSourceUri = metaSourceUri;
+        this.sourceResolver = resolver;
     }
 
     protected static final String RCML_EXTENSION = ".rcml";
@@ -121,7 +120,7 @@
         NamespaceHelper helper = saveToXml();
         Assert.notNull("XML document", helper);
         try {
-            SourceUtil.writeDOM(helper.getDocument(), getRcmlSourceUri(), this.manager);
+            SourceUtil.writeDOM(helper.getDocument(), getRcmlSourceUri(), getSourceResolver());
         } catch (Exception e) {
             throw new RevisionControlException(e);
         }
@@ -350,8 +349,8 @@
             this.entries = new Vector();
             String uri = getRcmlSourceUri();
             try {
-                if (SourceUtil.exists(uri, this.manager)) {
-                    Document xml = SourceUtil.readDOM(uri, this.manager);
+                if (SourceUtil.exists(uri, getSourceResolver())) {
+                    Document xml = SourceUtil.readDOM(uri, getSourceResolver());
                     NamespaceHelper helper = new NamespaceHelper(NAMESPACE, "", xml);
                     Element parent = xml.getDocumentElement();
                     Element[] elements = helper.getChildren(parent);
@@ -393,8 +392,8 @@
             throws RevisionControlException {
         String backupSourceUri = getBackupSourceUri(sourceUri, time);
         try {
-            if (SourceUtil.exists(sourceUri, manager)) {
-                SourceUtil.copy(this.manager, sourceUri, backupSourceUri);
+            if (SourceUtil.exists(sourceUri, getSourceResolver())) {
+                SourceUtil.copy(getSourceResolver(), sourceUri, backupSourceUri);
             }
         } catch (Exception e) {
             throw new RevisionControlException(e);
@@ -410,16 +409,10 @@
     protected synchronized void restoreBackup(SourceWrapper wrapper, long time)
             throws RevisionControlException {
         String backupSourceUri = getBackupSourceUri(wrapper, time);
-        SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
-            SourceUtil.copy(resolver, backupSourceUri, wrapper.getOutputStream());
+            SourceUtil.copy(getSourceResolver(), backupSourceUri, wrapper.getOutputStream());
         } catch (Exception e) {
             throw new RevisionControlException(e);
-        } finally {
-            if (resolver != null) {
-                this.manager.release(resolver);
-            }
         }
     }
 
@@ -458,8 +451,8 @@
             throws RevisionControlException {
         String uri = getBackupSourceUri(sourceUri, time);
         try {
-            SourceUtil.delete(uri, this.manager);
-            SourceUtil.deleteEmptyCollections(uri, this.manager);
+            SourceUtil.delete(uri, getSourceResolver());
+            SourceUtil.deleteEmptyCollections(uri, getSourceResolver());
         } catch (Exception e) {
             throw new RevisionControlException(e);
         }
@@ -513,8 +506,8 @@
     public synchronized boolean delete() {
         try {
             deleteRevisions();
-            SourceUtil.delete(getRcmlSourceUri(), this.manager);
-            SourceUtil.deleteEmptyCollections(getRcmlSourceUri(), this.manager);
+            SourceUtil.delete(getRcmlSourceUri(), getSourceResolver());
+            SourceUtil.deleteEmptyCollections(getRcmlSourceUri(), getSourceResolver());
         } catch (Exception e) {
             throw new RuntimeException(e);
         }
@@ -555,12 +548,12 @@
                         .getContentSource(), time);
                 String thisContentUri = this
                         .getBackupSourceUri(sourceNode.getContentSource(), time);
-                SourceUtil.copy(this.manager, otherContentUri, thisContentUri);
+                SourceUtil.copy(getSourceResolver(), otherContentUri, thisContentUri);
 
                 String otherMetaUri = otherRcml.getBackupSourceUri(otherSourceNode.getMetaSource(),
                         time);
                 String thisMetaUri = this.getBackupSourceUri(sourceNode.getMetaSource(), time);
-                SourceUtil.copy(this.manager, otherMetaUri, thisMetaUri);
+                SourceUtil.copy(getSourceResolver(), otherMetaUri, thisMetaUri);
             }
 
             this.entries = new Vector();
@@ -636,5 +629,9 @@
         }
         return false;
     }
+
+    protected SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
     
 }

Modified: lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRcmlFactory.java
URL: http://svn.apache.org/viewvc/lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRcmlFactory.java?rev=741384&r1=741383&r2=741384&view=diff
==============================================================================
--- lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRcmlFactory.java (original)
+++ lenya/trunk/org.apache.lenya.module.sourcerepository/src/main/java/org/apache/lenya/cms/repository/SourceNodeRcmlFactory.java Fri Feb  6 03:16:59 2009
@@ -20,7 +20,7 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.excalibur.source.SourceResolver;
 import org.apache.lenya.cms.rc.RCML;
 
 /**
@@ -29,6 +29,7 @@
 public class SourceNodeRcmlFactory {
 
     private static SourceNodeRcmlFactory instance = new SourceNodeRcmlFactory();
+    private SourceResolver sourceResolver;
 
     /**
      * @return The singleton instance.
@@ -39,22 +40,29 @@
 
     private Map uri2rcml = new HashMap();
 
-    private SourceNodeRcmlFactory() {
-    }
-
     /**
      * @param node The node.
      * @param manager The service manager.
      * @return An RCML object.
      */
-    public synchronized RCML getRcml(SourceNode node, ServiceManager manager) {
+    public synchronized RCML getRcml(SourceNode node) {
         String uri = node.getSourceURI();
         RCML rcml = (RCML) this.uri2rcml.get(uri);
         if (rcml == null) {
             rcml = new SourceNodeRCML(node.getContentSource().getRealSourceUri(), node
-                    .getMetaSource().getRealSourceUri(), manager);
+                    .getMetaSource().getRealSourceUri(), getSourceResolver());
             this.uri2rcml.put(uri, rcml);
         }
         return rcml;
     }
+
+    public SourceResolver getSourceResolver() {
+        return sourceResolver;
+    }
+
+    public void setSourceResolver(SourceResolver sourceResolver) {
+        this.sourceResolver = sourceResolver;
+    }
+    
+    
 }
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.