cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vgritse...@apache.org
Subject svn commit: r585663 - in /cocoon/trunk/blocks: cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/ cocoon-repository/cocoon-r...
Date Wed, 17 Oct 2007 20:12:43 GMT
Author: vgritsenko
Date: Wed Oct 17 13:12:41 2007
New Revision: 585663

URL: http://svn.apache.org/viewvc?rev=585663&view=rev
Log:
AbstractLogEnabled, etc.

Modified:
    cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ProfilerImpl.java
    cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/Debugger.java
    cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/RemoteDebuggingSitemapExecutor.java
    cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/SimpleSitemapExecutor.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/RepositoryManager.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/SourceRepositoryImpl.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractImageSourceInspector.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySource.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySourceFactory.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/SourceDescriptorManager.java
    cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java

Modified: cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ProfilerImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ProfilerImpl.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ProfilerImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/components/profiler/ProfilerImpl.java
Wed Oct 17 13:12:41 2007
@@ -16,15 +16,16 @@
  */
 package org.apache.cocoon.components.profiler;
 
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
+import org.apache.cocoon.util.AbstractLogEnabled;
 
 /**
  * Profiler component implementation. Stores profiler data for
@@ -33,7 +34,7 @@
  * @version $Id$
  */
 public class ProfilerImpl extends AbstractLogEnabled
-    implements Profiler, ThreadSafe, Configurable {
+                          implements Profiler, ThreadSafe, Configurable {
 
     // Maximal count of entries, which should be stored.
     private int results_count = 10;
@@ -94,7 +95,7 @@
      * @return Result of the profiling
      */
     public ProfilerResult getResult(Object key) {
-        return (ProfilerResult)results.get(key);
+        return (ProfilerResult) results.get(key);
     }
 
     /** 
@@ -105,11 +106,12 @@
      */
     public void addResult(String uri, ProfilerData data) {
         Long key = new Long(data.getKey(uri));
-        ProfilerResult result = (ProfilerResult)results.get(key);
-        if(result == null){
-            synchronized(results){
-                if((result = (ProfilerResult)results.get(key)) == null)
+        ProfilerResult result = (ProfilerResult) results.get(key);
+        if (result == null) {
+            synchronized (results) {
+                if ((result = (ProfilerResult) results.get(key)) == null) {
                     results.put(key, result = new ProfilerResult(uri, results_count));
+                }
             }
         }
 

Modified: cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/Debugger.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/Debugger.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/Debugger.java
(original)
+++ cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/Debugger.java
Wed Oct 17 13:12:41 2007
@@ -27,28 +27,30 @@
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.Map.Entry;
 import java.util.Set;
 import java.util.Stack;
-import java.util.Map.Entry;
 
 import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.activity.Initializable;
 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.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.excalibur.xml.dom.DOMParser;
+import org.apache.excalibur.xml.xpath.XPathProcessor;
+
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.components.ContextHelper;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.wrapper.AbstractRequestWrapper;
+import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.cocoon.xml.dom.DOMUtil;
-import org.apache.excalibur.xml.dom.DOMParser;
-import org.apache.excalibur.xml.xpath.XPathProcessor;
+
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
 
@@ -57,9 +59,8 @@
  * @since 2.2
  * @version $Id$
  */
-public class Debugger
-    extends AbstractLogEnabled
-    implements Serviceable, Disposable, Initializable, Contextualizable {
+public class Debugger extends AbstractLogEnabled
+                      implements Serviceable, Disposable, Initializable, Contextualizable
{
 
     protected static final String DEBUGGER_KEY = Debugger.class.getName();
     protected static final String SITEMAP_COUNTER_KEY = DEBUGGER_KEY + "/sitemap-counter";
@@ -100,11 +101,13 @@
         int pos = this.debugInfo.indexOf(':');
         
         String host = this.debugInfo.substring(0, pos);
-        int   port = new Integer(this.debugInfo.substring(pos+1)).intValue();
-        this.getLogger().info("Trying to open connection to: " + host + " using port " +
port);
+        int port = Integer.parseInt(this.debugInfo.substring(pos + 1));
+
+        getLogger().info("Trying to open connection to: " + host + " using port " + port);
         this.socket = new Socket(host, port);
         this.socket.setKeepAlive(true);
         this.socket.setSoTimeout(60);
+
         this.writer = new PrintWriter(socket.getOutputStream());
         this.reader = new BufferedReader(new InputStreamReader(socket.getInputStream()));
         this.finished = false;
@@ -179,7 +182,7 @@
             }
         } while (read > 0);
         
-        Document doc = null;
+        Document doc;
         try {
             InputSource is = new InputSource();
             is.setCharacterStream(new StringReader(response.toString()));
@@ -200,7 +203,7 @@
         } catch (ProcessingException any) {
             this.getLogger().warn("Exception during parsing of status - stop debugging.");
             // if an exception during parsing occurs, we simply stop debugging
-            this.close();
+            close();
             return;
         }
         /*

Modified: cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/RemoteDebuggingSitemapExecutor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/RemoteDebuggingSitemapExecutor.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/RemoteDebuggingSitemapExecutor.java
(original)
+++ cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/RemoteDebuggingSitemapExecutor.java
Wed Oct 17 13:12:41 2007
@@ -26,12 +26,13 @@
 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.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 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.excalibur.source.Source;
+
 import org.apache.cocoon.acting.Action;
 import org.apache.cocoon.components.profiler.Profiler;
 import org.apache.cocoon.components.profiler.ProfilerResult;
@@ -47,9 +48,9 @@
 import org.apache.cocoon.sitemap.ExecutionContext;
 import org.apache.cocoon.sitemap.PatternException;
 import org.apache.cocoon.sitemap.SitemapExecutor;
+import org.apache.cocoon.util.AbstractLogEnabled;
 import org.apache.cocoon.xml.XMLUtils;
 import org.apache.cocoon.xml.dom.DOMBuilder;
-import org.apache.excalibur.source.Source;
 
 /**
  * Sample sitemap executor that prints out everything to a logger
@@ -57,9 +58,9 @@
  * @since 2.2
  * @version $Id$
  */
-public class RemoteDebuggingSitemapExecutor 
-    extends AbstractLogEnabled
-    implements ThreadSafe, SitemapExecutor, Serviceable, Contextualizable {
+public class RemoteDebuggingSitemapExecutor extends AbstractLogEnabled
+                                            implements ThreadSafe, SitemapExecutor, Serviceable,
+                                                       Contextualizable {
 
     protected ServiceManager manager;
     protected Context        context;
@@ -225,7 +226,6 @@
                     debugger = new Debugger();
                     try {
                         debugger.setDebugInfo(value);
-                        ContainerUtil.enableLogging(debugger, getLogger());
                         ContainerUtil.contextualize(debugger, this.context);
                         ContainerUtil.service(debugger, this.manager);
                         ContainerUtil.initialize(debugger);
@@ -247,7 +247,7 @@
             org.apache.excalibur.source.SourceResolver resolver = null;
             Source src = null;
             try {
-                resolver = (org.apache.excalibur.source.SourceResolver)this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
+                resolver = (org.apache.excalibur.source.SourceResolver) this.manager.lookup(org.apache.excalibur.source.SourceResolver.ROLE);
                 src = resolver.resolveURI(source);
                 ByteArrayOutputStream baos = new ByteArrayOutputStream();
                 InputStream inputStream = src.getInputStream();
@@ -260,13 +260,13 @@
                 baos.close();
                 StringBuffer buf = new StringBuffer("<sitemap src=\"");
                 buf.append(source).append("\">\n");
-                buf.append(new String(baos.toString("utf-8")));
+                buf.append(baos.toString("utf-8"));
                 buf.append("\n</sitemap>\n");
                 debugger.send(buf.toString());
             } catch (Exception ignore ) {
                 // we ignore this for now
             } finally {
-                if ( source != null ) {
+                if (source != null) {
                     resolver.release(src);
                 }
                 this.manager.release(resolver);

Modified: cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/SimpleSitemapExecutor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/SimpleSitemapExecutor.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/SimpleSitemapExecutor.java
(original)
+++ cocoon/trunk/blocks/cocoon-profiler/cocoon-profiler-impl/src/main/java/org/apache/cocoon/profiler/debugging/SimpleSitemapExecutor.java
Wed Oct 17 13:12:41 2007
@@ -19,9 +19,9 @@
 import java.util.Iterator;
 import java.util.Map;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.thread.ThreadSafe;
+
 import org.apache.cocoon.acting.Action;
 import org.apache.cocoon.environment.Redirector;
 import org.apache.cocoon.environment.SourceResolver;
@@ -32,6 +32,7 @@
 import org.apache.cocoon.sitemap.ExecutionContext;
 import org.apache.cocoon.sitemap.PatternException;
 import org.apache.cocoon.sitemap.SitemapExecutor;
+import org.apache.cocoon.util.AbstractLogEnabled;
 
 /**
  * Sample sitemap executor that prints out everything to a logger
@@ -39,12 +40,11 @@
  * @since 2.2
  * @version $Id$
  */
-public class SimpleSitemapExecutor 
-    extends AbstractLogEnabled
-    implements ThreadSafe, SitemapExecutor {
+public class SimpleSitemapExecutor extends AbstractLogEnabled
+                                   implements ThreadSafe, SitemapExecutor {
 
     /**
-     * @see org.apache.cocoon.sitemap.SitemapExecutor#invokeAction(org.apache.cocoon.sitemap.ExecutionContext,
java.util.Map, org.apache.cocoon.acting.Action, org.apache.cocoon.environment.Redirector,
org.apache.cocoon.environment.SourceResolver, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
+     * @see SitemapExecutor#invokeAction(ExecutionContext, Map, Action, org.apache.cocoon.environment.Redirector,
org.apache.cocoon.environment.SourceResolver, java.lang.String, Parameters)
      */
     public Map invokeAction(final ExecutionContext context,
                             final Map              objectModel, 
@@ -236,4 +236,3 @@
     }
 
 }
-

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/RepositoryManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/RepositoryManager.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/RepositoryManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/RepositoryManager.java
Wed Oct 17 13:12:41 2007
@@ -23,21 +23,23 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 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.ProcessingException;
 import org.apache.cocoon.components.LifecycleHelper;
 import org.apache.cocoon.components.repository.helpers.CredentialsToken;
+import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.cocoon.util.avalon.CLLoggerWrapper;
 
 
 /**
  * A factory component to create instances of repositories.
  */
 public class RepositoryManager extends AbstractLogEnabled
-implements Serviceable, Disposable, Configurable, ThreadSafe {
+                               implements Serviceable, Disposable, Configurable, ThreadSafe
{
 
     /** The Avalon role name */
     public static final String ROLE = RepositoryManager.class.getName();
@@ -90,14 +92,13 @@
      */
     public Repository getRepository(String hint, CredentialsToken credentials) throws ProcessingException
{
 
-        if (this.getLogger().isDebugEnabled()) {
-            this.getLogger().debug("get repository for: " + hint);
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("get repository for: " + hint);
         }
-        
+
         String className = null;
 
         try {
-    
             Configuration repoConfiguration = (Configuration)this.repos.get(hint);
             className = repoConfiguration.getAttribute("class");
             Class repoClass = Class.forName(className);
@@ -105,10 +106,10 @@
             if (this.getLogger().isDebugEnabled()) {
                 this.getLogger().debug("loading class" + className);
             }
-    
-            Repository repo = (Repository)repoClass.newInstance();
+
+            Repository repo = (Repository) repoClass.newInstance();
             LifecycleHelper.setupComponent(repo,
-                                           this.getLogger(),
+                                           new CLLoggerWrapper(getLogger()),
                                            null,
                                            this.manager,
                                            repoConfiguration,
@@ -117,16 +118,16 @@
             repo.setCredentials(credentials);
             return repo;
 
-        } catch (ConfigurationException ce) {
-            throw new ProcessingException("Could not get configuration for " + hint, ce);
-        } catch (ClassNotFoundException cnfe) {
-            throw new ProcessingException("Could not load class " + className, cnfe);
-        } catch (InstantiationException ie) {
-            throw new ProcessingException("Could not instantiate class " + className, ie);
-        } catch (IllegalAccessException iae) {
-             throw new ProcessingException("Could not instantiate class " + className, iae);
+        } catch (ConfigurationException e) {
+            throw new ProcessingException("Could not get configuration for " + hint, e);
+        } catch (ClassNotFoundException e) {
+            throw new ProcessingException("Could not load class " + className, e);
+        } catch (InstantiationException e) {
+            throw new ProcessingException("Could not instantiate class " + className, e);
+        } catch (IllegalAccessException e) {
+            throw new ProcessingException("Could not instantiate class " + className, e);
         } catch (Exception e) {
-             throw new ProcessingException("Could not setup component " + className, e);
+            throw new ProcessingException("Could not setup component " + className, e);
         }
     }
     

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/SourceRepositoryImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/SourceRepositoryImpl.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/SourceRepositoryImpl.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/repository/SourceRepositoryImpl.java
Wed Oct 17 13:12:41 2007
@@ -19,7 +19,6 @@
 import java.io.IOException;
 import java.util.Iterator;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
@@ -32,13 +31,15 @@
 import org.apache.excalibur.source.SourceUtil;
 import org.apache.excalibur.source.TraversableSource;
 
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 /**
  * SourceRepository implementation.
  * 
  * @version $Id$
  */
-public class SourceRepositoryImpl extends AbstractLogEnabled 
-implements Serviceable, ThreadSafe, SourceRepository {
+public class SourceRepositoryImpl extends AbstractLogEnabled
+                                  implements Serviceable, ThreadSafe, SourceRepository {
     
     private RepositoryInterceptor m_interceptor = new RepositoryInterceptorBase(){};
     private SourceResolver m_resolver;
@@ -59,7 +60,7 @@
     
     // ---------------------------------------------------- repository operations
     
-    public int save(String in, String out) throws IOException, SourceException {
+    public int save(String in, String out) throws IOException {
         
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("save: "+in+"/"+out);
@@ -126,7 +127,7 @@
         
     }
     
-    public int makeCollection(String location) throws IOException, SourceException {
+    public int makeCollection(String location) throws IOException {
         
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("makeCollection: " + location);
@@ -184,7 +185,7 @@
      * @return  a http status code describing the exit status.
      * @throws IOException
      */
-    public int remove(String location) throws IOException, SourceException {
+    public int remove(String location) throws IOException {
         
         Source source = null;
         try {
@@ -216,40 +217,31 @@
         }
         
         if (!(source instanceof ModifiableSource)) {
-            final String message = 
-                "Conflict in remove(): source is not modifiable";
-            getLogger().warn(message);
+            getLogger().warn("Conflict in remove(): source is not modifiable");
             return STATUS_CONFLICT;         
         }
         
         if (source instanceof TraversableSource) {
             if (((TraversableSource) source).isCollection()) {
-                int status = STATUS_OK;
-                final Iterator iter = ((TraversableSource) source).getChildren().iterator();
-                while (iter.hasNext()) {
-                    Source child = null;
-                    try {
-                        status = remove((Source) iter.next());
-                        if (status != STATUS_OK) {
-                            return status;
-                        }
-                    }
-                    finally {
-                        if (child != null) {
-                            m_resolver.release(child);
-                        }
+                final Iterator i = ((TraversableSource) source).getChildren().iterator();
+                while (i.hasNext()) {
+                    int status = remove((Source) i.next());
+                    if (status != STATUS_OK) {
+                        return status;
                     }
                 }
             }
         }
+
         m_interceptor.preRemoveSource(source);
         ((ModifiableSource) source).delete();
         m_interceptor.postRemoveSource(source);
+
         return STATUS_OK;
     }
     
     public int move(String from, String to, boolean recurse, boolean overwrite) 
-    throws IOException, SourceException {
+    throws IOException {
         
         int status = doCopy(from,to,recurse,overwrite);
         if (status == STATUS_CREATED || status == STATUS_NO_CONTENT) {
@@ -261,18 +253,17 @@
     }
     
     public int copy(String from, String to, boolean recurse, boolean overwrite) 
-    throws IOException, SourceException {
-        
+    throws IOException {
+
         return doCopy(from,to,recurse,overwrite);
-        
     }
     
     private int doCopy(String from, String to, boolean recurse, boolean overwrite) 
     throws IOException {
         
         if (getLogger().isDebugEnabled()) {
-            getLogger().debug("copy: " + from + " -> " + to 
-                + " (recurse=" + recurse + ", overwrite=" + overwrite + ")");
+            getLogger().debug("copy: " + from + " -> " + to +
+                              " (recurse=" + recurse + ", overwrite=" + overwrite + ")");
         }
         
         if (from != null && from.equals(to)) {
@@ -352,7 +343,7 @@
         
         if (source instanceof TraversableSource) {
             final TraversableSource origin = (TraversableSource) source;
-            ModifiableTraversableSource target = null;
+            ModifiableTraversableSource target;
             if (origin.isCollection()) {
                 if (!(destination instanceof ModifiableTraversableSource)) {
                     final String message = "copy() is forbidden: " +

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractConfigurableSourceInspector.java
Wed Oct 17 13:12:41 2007
@@ -23,12 +23,13 @@
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.cocoon.components.source.SourceInspector;
-import org.apache.cocoon.components.source.helpers.SourceProperty;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 
+import org.apache.cocoon.components.source.SourceInspector;
+import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 /**
  * Abstract base class for SourceInspectors that want to 
  * configure the set of properties they handle beforehand.
@@ -37,10 +38,11 @@
  * Knowing which properties an inspector handles beforehand
  * greatly improves property management performance.
  * </p>
- * 
+ *
+ * @version $Id$
  */
-public abstract class AbstractConfigurableSourceInspector extends AbstractLogEnabled 
-implements SourceInspector, Configurable {
+public abstract class AbstractConfigurableSourceInspector extends AbstractLogEnabled
+                                                          implements SourceInspector, Configurable
{
 
     // the set of properties this inspector is configured to handle
     private Set m_properties;

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractImageSourceInspector.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractImageSourceInspector.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractImageSourceInspector.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/AbstractImageSourceInspector.java
Wed Oct 17 13:12:41 2007
@@ -16,22 +16,23 @@
  */
 package org.apache.cocoon.components.source.impl;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.cocoon.components.source.SourceInspector;
-import org.apache.cocoon.components.source.helpers.SourceProperty;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.source.impl.validity.NOPValidity;
 
+import org.apache.cocoon.components.source.SourceInspector;
+import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 /**
  * Abstract base class for inspectors that can calculate 
  * the size of an image of a particular type.
- * 
+ *
+ * @version $Id$
  */
-public abstract class AbstractImageSourceInspector
-    extends AbstractLogEnabled
-    implements SourceInspector {
+public abstract class AbstractImageSourceInspector extends AbstractLogEnabled
+                                                   implements SourceInspector {
 
     /** 
      * The namespace uri of the properties exposed by this SourceInspector.

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySource.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySource.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySource.java
Wed Oct 17 13:12:41 2007
@@ -25,18 +25,17 @@
 import java.util.Iterator;
 import java.util.List;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.avalon.framework.logger.Logger;
-import org.apache.cocoon.components.source.InspectableSource;
-import org.apache.cocoon.components.source.SourceDescriptor;
-import org.apache.cocoon.components.source.helpers.SourceProperty;
 import org.apache.excalibur.source.ModifiableTraversableSource;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
-import org.apache.excalibur.source.SourceNotFoundException;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.source.impl.validity.AggregatedValidity;
 
+import org.apache.cocoon.components.source.InspectableSource;
+import org.apache.cocoon.components.source.SourceDescriptor;
+import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 /**
  * Source wrapper that enhances the wrapped sources with additional capabilities.
  * 
@@ -49,8 +48,8 @@
  * Wrapped sources must implement ModifiableTraversableSource.
  * </p>
  */
-public class RepositorySource extends AbstractLogEnabled 
-implements Source, ModifiableTraversableSource, InspectableSource {
+public class RepositorySource extends AbstractLogEnabled
+                              implements Source, ModifiableTraversableSource, InspectableSource
{
 
     // the original source prefix
     final String m_prefix;
@@ -60,16 +59,13 @@
     
     // ---------------------------------------------------- Lifecycle
     
-    public RepositorySource(
-        final String prefix,
-        final ModifiableTraversableSource delegate, 
-        final SourceDescriptor descriptor,
-        final Logger logger) throws SourceException {
+    public RepositorySource(final String prefix,
+                            final ModifiableTraversableSource delegate,
+                            final SourceDescriptor descriptor) throws SourceException {
         
         m_prefix = prefix;
         m_delegate = delegate;
         m_descriptor = descriptor;
-        enableLogging(logger);
     }
     
     // ---------------------------------------------------- InspectableSource implementation
@@ -147,8 +143,7 @@
         return m_delegate.getContentLength();
     }
     
-    public InputStream getInputStream()
-        throws IOException, SourceNotFoundException {
+    public InputStream getInputStream() throws IOException {
         return m_delegate.getInputStream();
     }
     
@@ -201,34 +196,30 @@
     // ---------------------------------------------------- ModifiableTraversableSource
     
     public Source getChild(String name) throws SourceException {
-        if (!m_delegate.isCollection()) return null;
+        if (!m_delegate.isCollection()) {
+            return null;
+        }
+
         ModifiableTraversableSource child = (ModifiableTraversableSource) m_delegate.getChild(name);
-        if (child == null) return null;
+        if (child == null) {
+            return null;
+        }
         
-        return new RepositorySource(
-            m_prefix,
-            child,
-            m_descriptor,
-            getLogger()
-        );
+        return new RepositorySource(m_prefix, child, m_descriptor);
     }
 
     public Collection getChildren() throws SourceException {
-        if (!m_delegate.isCollection()) return null;
-    	Collection result = new ArrayList();
-		Iterator iter = m_delegate.getChildren().iterator();
-    	while(iter.hasNext()) {
-            ModifiableTraversableSource child = (ModifiableTraversableSource) iter.next();
-            
-    		result.add(
-                new RepositorySource(
-                    m_prefix,
-                    child,
-                    m_descriptor,
-    		        getLogger()
-                )
-            );
+        if (!m_delegate.isCollection()) {
+            return null;
+        }
+
+        Collection result = new ArrayList();
+		Iterator i = m_delegate.getChildren().iterator();
+    	while(i.hasNext()) {
+            ModifiableTraversableSource child = (ModifiableTraversableSource) i.next();
+    		result.add(new RepositorySource(m_prefix, child, m_descriptor));
     	}
+        
         return result;
     }
 
@@ -237,12 +228,9 @@
     }
 
     public Source getParent() throws SourceException {
-        return new RepositorySource(
-            m_prefix,
-            (ModifiableTraversableSource) m_delegate.getParent(),
-        	m_descriptor, 
-            getLogger()
-        );
+        return new RepositorySource(m_prefix,
+                                    (ModifiableTraversableSource) m_delegate.getParent(),
+                                    m_descriptor);
     }
 
     public boolean isCollection() {

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySourceFactory.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySourceFactory.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/RepositorySourceFactory.java
Wed Oct 17 13:12:41 2007
@@ -17,68 +17,64 @@
 package org.apache.cocoon.components.source.impl;
 
 import java.io.IOException;
-import java.net.MalformedURLException;
 import java.util.Map;
 
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 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.components.source.SourceDescriptor;
 import org.apache.excalibur.source.ModifiableTraversableSource;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceFactory;
 import org.apache.excalibur.source.SourceResolver;
 
+import org.apache.cocoon.components.source.SourceDescriptor;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 /**
  * Creates RepositorySources.
  */
 public class RepositorySourceFactory extends AbstractLogEnabled
-implements SourceFactory, Serviceable, Configurable, ThreadSafe {
+                                     implements SourceFactory, Serviceable, Configurable,
ThreadSafe {
     
     private ServiceManager m_manager;
     private SourceResolver m_resolver;
     private SourceDescriptor m_descriptor;
     private String m_name;
     private boolean m_isInitialized;
-    
+
+
     public RepositorySourceFactory() {
     }
     
     private synchronized void lazyInitialize() throws IOException {
-        if (m_isInitialized) {
-            return;
-        }
-        if (m_resolver == null) {
-            try {
-                m_resolver = (SourceResolver) m_manager.lookup(SourceResolver.ROLE);
-            }
-            catch (ServiceException e) {
-                throw new IOException("Resolver service is not available: " + e.toString());
-            }
-        }
-        if (m_manager.hasService(SourceDescriptor.ROLE)) {
-            try {
-                m_descriptor = (SourceDescriptor) m_manager.lookup(SourceDescriptor.ROLE);
-            }
-            catch (ServiceException e) {
-                // impossible
+        if (!m_isInitialized) {
+            if (m_resolver == null) {
+                try {
+                    m_resolver = (SourceResolver) m_manager.lookup(SourceResolver.ROLE);
+                } catch (ServiceException e) {
+                    throw new IOException("Resolver service is not available: " + e.toString());
+                }
             }
-        }
-        else {
-            m_descriptor = null;
-            if (getLogger().isInfoEnabled()) {
-                final String message =
-                    "SourceDescriptor is not available. " +
-                    "RepositorySource will not support " +
-                    "source properties.";
-                getLogger().info(message);
+            if (m_manager.hasService(SourceDescriptor.ROLE)) {
+                try {
+                    m_descriptor = (SourceDescriptor) m_manager.lookup(SourceDescriptor.ROLE);
+                } catch (ServiceException e) {
+                    // impossible
+                }
+            } else {
+                m_descriptor = null;
+                if (getLogger().isInfoEnabled()) {
+                    getLogger().info("SourceDescriptor is not available. " +
+                                     "RepositorySource will not support source properties.");
+                }
             }
+
+            m_isInitialized = true;
         }
     }
     
@@ -96,8 +92,7 @@
         m_manager = manager;
     }
     
-    public Source getSource(String location, Map parameters)
-        throws IOException, MalformedURLException {
+    public Source getSource(String location, Map parameters) throws IOException {
         
         if (getLogger().isDebugEnabled()) {
             getLogger().debug("Creating RepositorySource for " + location);
@@ -107,27 +102,23 @@
         if (!m_isInitialized) {
             lazyInitialize();
         }
-        
+
         // assert location.startsWith(m_name)
-        location = location.substring(m_name.length()+1);
+        location = location.substring(m_name.length() + 1);
         Source source = m_resolver.resolveURI(location);
         if (!(source instanceof ModifiableTraversableSource)) {
             final String message = "Delegate should be a ModifiableTraversableSource";
             throw new SourceException(message);
         }
-        
-        return new RepositorySource(
-            m_name,
-            (ModifiableTraversableSource) source, 
-            m_descriptor,
-            getLogger()
-        );
+
+        return new RepositorySource(m_name,
+                                    (ModifiableTraversableSource) source,
+                                    m_descriptor);
     }
-    
+
     public void release(final Source source) {
         if (source instanceof RepositorySource) {
             m_resolver.release(((RepositorySource) source).m_delegate);
         }
     }
-
 }

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/SourceDescriptorManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/SourceDescriptorManager.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/SourceDescriptorManager.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/SourceDescriptorManager.java
Wed Oct 17 13:12:41 2007
@@ -30,27 +30,29 @@
 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.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 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.components.source.SourceDescriptor;
-import org.apache.cocoon.components.source.SourceInspector;
-import org.apache.cocoon.components.source.helpers.SourceProperty;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.source.impl.validity.AggregatedValidity;
 
+import org.apache.cocoon.components.source.SourceDescriptor;
+import org.apache.cocoon.components.source.SourceInspector;
+import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.util.AbstractLogEnabled;
+import org.apache.cocoon.util.avalon.CLLoggerWrapper;
+
 /**
  * This source descriptor acts as container for a set of source inspectors/descriptors.
  * 
  * @version $Id$
  */
-public final class SourceDescriptorManager extends AbstractLogEnabled 
-implements SourceDescriptor, Contextualizable, Serviceable, 
-Configurable, Initializable, Disposable, ThreadSafe {
+public final class SourceDescriptorManager extends AbstractLogEnabled
+                                           implements SourceDescriptor, Contextualizable,
Serviceable,
+                                                      Configurable, Initializable, Disposable,
ThreadSafe {
     
     // the registered inspectors
     private Set m_inspectors;
@@ -98,16 +100,16 @@
                  throw new ConfigurationException(
                     "Could not load class "+className, iae);
             }
-            ContainerUtil.enableLogging(inspector,getLogger());
-            ContainerUtil.contextualize(inspector,m_context);
-            ContainerUtil.service(inspector,m_manager);
-            ContainerUtil.configure(inspector,children[i]);
-            ContainerUtil.parameterize(inspector,
-                Parameters.fromConfiguration(children[i]));
+            ContainerUtil.enableLogging(inspector, new CLLoggerWrapper(getLogger()));
+            ContainerUtil.contextualize(inspector, m_context);
+            ContainerUtil.service(inspector, m_manager);
+            ContainerUtil.configure(inspector, children[i]);
+            ContainerUtil.parameterize(inspector, Parameters.fromConfiguration(children[i]));
             ContainerUtil.initialize(inspector);
-            
+
             m_inspectors.add(inspector);
         }
+
         // done with these
         m_configuration = null;
         m_context = null;
@@ -115,10 +117,11 @@
     }
     
     public void dispose() {
-        Iterator iter = m_inspectors.iterator();
-        while(iter.hasNext()) {
-            ContainerUtil.dispose(iter.next());
+        Iterator i = m_inspectors.iterator();
+        while (i.hasNext()) {
+            ContainerUtil.dispose(i.next());
         }
+
         m_inspectors = null;
     }
     
@@ -222,4 +225,3 @@
         return validity;
     }
 }
-

Modified: cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java?rev=585663&r1=585662&r2=585663&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
(original)
+++ cocoon/trunk/blocks/cocoon-repository/cocoon-repository-impl/src/main/java/org/apache/cocoon/components/source/impl/XPathSourceInspector.java
Wed Oct 17 13:12:41 2007
@@ -18,7 +18,6 @@
 
 import java.io.IOException;
 
-import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.parameters.Parameterizable;
 import org.apache.avalon.framework.parameters.Parameters;
@@ -26,14 +25,17 @@
 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.components.source.SourceInspector;
-import org.apache.cocoon.components.source.helpers.SourceProperty;
 import org.apache.excalibur.source.Source;
 import org.apache.excalibur.source.SourceException;
 import org.apache.excalibur.source.SourceValidity;
 import org.apache.excalibur.source.impl.validity.NOPValidity;
 import org.apache.excalibur.xml.dom.DOMParser;
 import org.apache.excalibur.xml.xpath.XPathProcessor;
+
+import org.apache.cocoon.components.source.SourceInspector;
+import org.apache.cocoon.components.source.helpers.SourceProperty;
+import org.apache.cocoon.util.AbstractLogEnabled;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.NodeList;
 import org.xml.sax.InputSource;
@@ -149,5 +151,4 @@
     public SourceValidity getValidity(Source source) {
         return NOPValidity.SHARED_INSTANCE;
     }
-
 }



Mime
View raw message