velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henn...@apache.org
Subject svn commit: r522309 - /velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/
Date Sun, 25 Mar 2007 17:35:20 GMT
Author: henning
Date: Sun Mar 25 10:35:19 2007
New Revision: 522309

URL: http://svn.apache.org/viewvc?view=rev&rev=522309
Log:
Move Velocity stuff into its own package.


Added:
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/AbstractDoxiaResourceLoader.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/AbstractDoxiaResourceLoader.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaLibraryLoader.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaLibraryLoader.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
  (with props)
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaVelocityContextFactory.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaVelocityContextFactory.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaLibraryLoader.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaLibraryLoader.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaResourceLoader.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaVelocityContextFactory.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaVelocityContextFactory.java
    velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/PlexusLogger.java
      - copied, changed from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/PlexusLogger.java

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/AbstractDoxiaResourceLoader.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/AbstractDoxiaResourceLoader.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/AbstractDoxiaResourceLoader.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/AbstractDoxiaResourceLoader.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/AbstractDoxiaResourceLoader.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/AbstractDoxiaResourceLoader.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/AbstractDoxiaResourceLoader.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaLibraryLoader.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaLibraryLoader.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaLibraryLoader.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaLibraryLoader.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaLibraryLoader.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaLibraryLoader.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaLibraryLoader.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -40,7 +40,7 @@
  * This is a plexus-managed component which gets configured by the {@link
  * org.apache.velocity.site.doxia.plugin.DoxiaVelocityRendererPlugin} during the post-site
phase.
  *
- * @plexus.component  role="org.apache.velocity.site.doxia.util.DoxiaLibraryLoader"
+ * @plexus.component  role="org.apache.velocity.site.doxia.velocity.DoxiaLibraryLoader"
  *
  * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
  * @version  $Revision$

Added: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java?view=auto&rev=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
(added)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
Sun Mar 25 10:35:19 2007
@@ -0,0 +1,140 @@
+package org.apache.velocity.site.doxia.velocity;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.Reader;
+import java.io.UnsupportedEncodingException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.velocity.exception.ResourceNotFoundException;
+import org.codehaus.plexus.logging.LogEnabled;
+import org.codehaus.plexus.logging.Logger;
+
+
+/**
+ * This loader reads the current template from a passed in {@link Reader} object and
+ * returns the template as an {@link InputStream} for Velocity to use.
+ *
+ * @plexus.component  role="org.apache.velocity.site.doxia.velocity.DoxiaResourceLoader"
+ *
+ * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version  $Revision$
+ */
+public class DefaultDoxiaResourceLoader
+    extends AbstractDoxiaResourceLoader
+        implements DoxiaResourceLoader, LogEnabled
+{
+
+    /** Plexus logging */
+    private Logger logger = null;
+
+    /** The current reader to load the template from. */
+    private Reader templateReader = null;
+
+    /**
+     * @see LogEnabled#enableLogging(Logger)
+     */
+    public void enableLogging(final Logger logger)
+    {
+        this.logger = logger;
+    }
+
+    /**
+     * Set the {@link Reader} object for the loader to use.
+     *
+     * @param  templateReader  A {@link Reader} object. Must not be null.
+     */
+    public void setTemplateReader(final Reader templateReader)
+    {
+        this.templateReader = templateReader;
+    }
+
+    /**
+     * Returns the template available from the {@link Reader} that has been set using {@link
#setTemplateReader(Reader)}
+     * when the requested template name is the empty string. This allows Velocity to pull
the current template out of
+     * the reader and process as a template.
+     *
+     * TODO: Teach Velocity to know about InputReaders. This method is a kludge at best.
+     *
+     * @param  templateName  The template to retrieve. This loader only reacts on the empty
(&quot;&quot;) template name.
+     *
+     * @return  An {@link InputStream} representing the Template available from the Reader
or null.
+     *
+
+     * @throws ResourceNotFoundException When this {@link org.apache.velocity.runtime.resource.loader.ResourceLoader}
+     *                                   should have been able to supply the template but
encountered an error.
+     */
+    public InputStream getResourceStream(final String templateName)
+        throws ResourceNotFoundException
+    {
+        if ((templateReader == null) || StringUtils.isNotEmpty(templateName))
+        {
+            return null;
+        }
+
+        BufferedReader bufReader = new BufferedReader(templateReader);
+
+        StringBuffer template = new StringBuffer();
+
+        String buf = null;
+
+        try
+        {
+            while ((buf = bufReader.readLine()) != null)
+            {
+                template.append(buf).append("\n");
+            }
+        }
+        catch (IOException ioe)
+        {
+            throw new ResourceNotFoundException("While reading Template: ", ioe);
+        }
+        finally
+        {
+            if (bufReader != null)
+            {
+                try
+                {
+                    bufReader.close();
+                }
+                catch (IOException ioe2)
+                {
+                    logger.error("While closing Input Stream: ", ioe2);
+                }
+            }
+        }
+
+        try
+        {
+            // must match the input.encoding setting in the properties file!
+            byte[] templateBytes = template.toString().getBytes("UTF-8");
+
+            return new ByteArrayInputStream(templateBytes);
+        }
+        catch (UnsupportedEncodingException uee)
+        {
+            throw new ResourceNotFoundException("While encoding Template: ", uee);
+        }
+    }
+}

Propchange: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaResourceLoader.java
------------------------------------------------------------------------------
    svn:keywords = Id Author Date Revision

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaVelocityContextFactory.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaVelocityContextFactory.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaVelocityContextFactory.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaVelocityContextFactory.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaVelocityContextFactory.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DefaultDoxiaVelocityContextFactory.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DefaultDoxiaVelocityContextFactory.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -26,6 +26,7 @@
 import org.apache.commons.collections.iterators.ArrayIterator;
 import org.apache.commons.lang.StringUtils;
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.site.doxia.util.VelocityTool;
 
 
 /**
@@ -36,7 +37,7 @@
  *
  * The various Velocity renderer then instantiate the configured Factory through Plexus in
the actual site phase.
  *
- * @plexus.component  role="org.apache.velocity.site.doxia.util.DoxiaVelocityContextFactory"
+ * @plexus.component  role="org.apache.velocity.site.doxia.velocity.DoxiaVelocityContextFactory"
  *
  * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
  * @version  $Revision$

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaLibraryLoader.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaLibraryLoader.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaLibraryLoader.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaLibraryLoader.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaLibraryLoader.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaLibraryLoader.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaLibraryLoader.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one

Added: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaResourceLoader.java
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaResourceLoader.java?view=auto&rev=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaResourceLoader.java
(added)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaResourceLoader.java
Sun Mar 25 10:35:19 2007
@@ -0,0 +1,44 @@
+package org.apache.velocity.site.doxia.velocity;
+
+import java.io.Reader;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * This loader reads the current template from a passed in {@link Reader} object and
+ * returns the template as an {@link InputStream} for Velocity to use.
+ *
+ * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
+ * @version  $Revision$
+ */
+public interface DoxiaResourceLoader
+{
+    /** Plexus Role Definition */
+    String ROLE = DoxiaResourceLoader.class.getName();
+
+    /**
+     * Set the {@link Reader} object for the loader to use.
+     *
+     * @param  templateReader  A {@link Reader} object. Must not be null.
+     */
+    void setTemplateReader(final Reader templateReader);
+}
+
+

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaVelocityContextFactory.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaVelocityContextFactory.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaVelocityContextFactory.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaVelocityContextFactory.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaVelocityContextFactory.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/DoxiaVelocityContextFactory.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/DoxiaVelocityContextFactory.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -20,6 +20,7 @@
  */
 
 import org.apache.velocity.VelocityContext;
+import org.apache.velocity.site.doxia.util.VelocityTool;
 
 
 /**

Copied: velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/PlexusLogger.java
(from r519691, velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/PlexusLogger.java)
URL: http://svn.apache.org/viewvc/velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/PlexusLogger.java?view=diff&rev=522309&p1=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/PlexusLogger.java&r1=519691&p2=velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/PlexusLogger.java&r2=522309
==============================================================================
--- velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/util/PlexusLogger.java
(original)
+++ velocity/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/loader/PlexusLogger.java
Sun Mar 25 10:35:19 2007
@@ -1,4 +1,4 @@
-package org.apache.velocity.site.doxia.util;
+package org.apache.velocity.site.doxia.velocity;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -21,29 +21,35 @@
 
 import org.apache.velocity.runtime.RuntimeServices;
 import org.apache.velocity.runtime.log.LogChute;
+import org.codehaus.plexus.logging.LogEnabled;
 import org.codehaus.plexus.logging.Logger;
 
 /**
  * An implementation of a {@link LogChute} to use with Velocity that logs into
  * Plexus logging.
  *
+ * @plexus.component role="org.apache.velocity.site.doxia.velocity.PlexusLogger"
+
  * @author  <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
  * @version  $Revision$
  */
 public class PlexusLogger
-    implements LogChute
+    implements LogChute, LogEnabled
 {
+    public static final String ROLE = PlexusLogger.class.getName();
 
     /** Plexus Logger Object */
-    private final Logger logger;
+    private Logger logger = null;
 
     /**
      * Creates a new PlexusLogger object.
-     *
-     * @param  logger  The Plexus {@link Logger} object to use.
      */
-    public PlexusLogger(Logger logger)
+    public PlexusLogger()
     {
+    }
+
+
+    public void enableLogging(final Logger logger) {
         this.logger = logger;
     }
 



Mime
View raw message