velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r956390 - in /velocity/sandbox/maven-reorg/site/tools: velocity-site-doxia-renderer/ velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/ velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/ple...
Date Sun, 20 Jun 2010 19:37:55 GMT
Author: apetrelli
Date: Sun Jun 20 19:37:54 2010
New Revision: 956390

URL: http://svn.apache.org/viewvc?rev=956390&view=rev
Log:
VELOCITYSB-3
Fixed links, updated plugins, removed useless pages, generated project infos.

Modified:
    velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/pom.xml
    velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/AbstractVelocityRenderer.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityAptSiteModule.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityXdocSiteModule.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/plexus/PlexusKludgeUtils.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/pom.xml
    velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/NewsBlockGenerator.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/macro/VelocityNewsMacro.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/NewsFeedGenerator.java
    velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/VelocityNewsReport.java

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/pom.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/pom.xml?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/pom.xml (original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/pom.xml Sun Jun 20
19:37:54 2010
@@ -65,12 +65,12 @@
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-core</artifactId>
-      <version>1.0-alpha-8</version>
+      <version>1.1.3</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-sink-api</artifactId>
-        <version>1.0-alpha-8</version>
+        <version>1.1.3</version>
     </dependency>
     <dependency>
       <groupId>commons-collections</groupId>
@@ -82,11 +82,11 @@
       <artifactId>commons-lang</artifactId>
       <version>2.1</version>
     </dependency>
-    <dependency>
+<!--     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-container-default</artifactId>
-      <version>1.0-alpha-9-stable-1</version>
-    </dependency>
+      <version>1.0.0</version>
+    </dependency> -->
     <dependency>
       <groupId>org.apache.velocity</groupId>
       <artifactId>velocity</artifactId>
@@ -95,12 +95,17 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-      <version>2.0.6</version>
+      <version>2.2.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-      <version>2.0.6</version>
+      <version>2.2.1</version>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.maven.doxia</groupId>
+    	<artifactId>doxia-module-apt</artifactId>
+    	<version>1.1.3</version>
     </dependency>
   </dependencies>
 

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/AbstractVelocityRenderer.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/AbstractVelocityRenderer.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/AbstractVelocityRenderer.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/AbstractVelocityRenderer.java
Sun Jun 20 19:37:54 2010
@@ -21,17 +21,15 @@ package org.apache.velocity.site.doxia.r
 
 import java.io.Reader;
 import java.io.StringReader;
-import java.lang.reflect.Method;
 
 import org.apache.maven.doxia.parser.AbstractParser;
 import org.apache.maven.doxia.parser.ParseException;
 import org.apache.maven.doxia.parser.Parser;
 import org.apache.maven.doxia.sink.Sink;
+import org.apache.velocity.VelocityContext;
 import org.apache.velocity.site.doxia.plugin.DoxiaVelocityRendererPlugin;
-import org.apache.velocity.site.doxia.runner.DefaultVelocityRunner;
 import org.apache.velocity.site.doxia.runner.VelocityRunner;
-import org.apache.velocity.site.plexus.PlexusKludgeException;
-import org.apache.velocity.site.plexus.PlexusKludgeUtils;
+import org.apache.velocity.site.doxia.velocity.DoxiaVelocityContextFactory;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -107,9 +105,8 @@ public abstract class AbstractVelocityRe
     {
         try
         {
-            Object runner = getVelocityRunner();
-            Method parseVelocity = runner.getClass().getMethod(VelocityRunner.PARSE_METHOD,
VelocityRunner.PARSE_METHOD_SIGNATURE);
-            String result = (String) parseVelocity.invoke(runner, new Object[] { reader });
+            VelocityRunner runner = getVelocityRunner();
+            String result = runner.parseVelocity(reader);
 
             StringReader strReader = new StringReader(result);
 
@@ -118,10 +115,8 @@ public abstract class AbstractVelocityRe
         catch (RuntimeException re)
         {
             throw re;
-        }
-        catch (Exception e)
-        {
-            throw new ParseException(e);
+        } catch (Exception e) {
+            throw new RuntimeException(e);
         }
     }
 
@@ -134,17 +129,8 @@ public abstract class AbstractVelocityRe
      * @return A {@link DoxiaVelocityContextFactory} instance that generates
      *         {@link VelocityContext} objects for the render process.
      */
-    private Object getVelocityRunner() throws ComponentLookupException
+    private VelocityRunner getVelocityRunner() throws ComponentLookupException
     {
-        try
-        {
-            PlexusContainer velocityContainer = PlexusKludgeUtils.lookupContainer(container,
-                    DoxiaVelocityRendererPlugin.CONTAINER_LOOKUP_NAME);
-            return velocityContainer.lookup(DefaultVelocityRunner.ROLE);
-        }
-        catch (PlexusKludgeException pke)
-        {
-            throw new ComponentLookupException("While retrieving Velocity runner: ", pke);
-        }
+        return (VelocityRunner) container.lookup(DoxiaVelocityRendererPlugin.CONTAINER_LOOKUP_NAME);
     }
 }

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityAptSiteModule.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityAptSiteModule.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityAptSiteModule.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityAptSiteModule.java
Sun Jun 20 19:37:54 2010
@@ -19,7 +19,7 @@ package org.apache.velocity.site.doxia.r
  * under the License.
  */
 
-import org.apache.maven.doxia.site.module.SiteModule;
+import org.apache.maven.doxia.module.site.SiteModule;
 
 /**
  * This module connects the renderer with the Doxia core. It defines the

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityXdocSiteModule.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityXdocSiteModule.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityXdocSiteModule.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/doxia/renderer/VelocityXdocSiteModule.java
Sun Jun 20 19:37:54 2010
@@ -19,7 +19,7 @@ package org.apache.velocity.site.doxia.r
  * under the License.
  */
 
-import org.apache.maven.doxia.site.module.SiteModule;
+import org.apache.maven.doxia.module.site.SiteModule;
 
 /**
  * This module connects the renderer with the Doxia core. It defines the

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/plexus/PlexusKludgeUtils.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/plexus/PlexusKludgeUtils.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/plexus/PlexusKludgeUtils.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-doxia-renderer/src/main/java/org/apache/velocity/site/plexus/PlexusKludgeUtils.java
Sun Jun 20 19:37:54 2010
@@ -21,9 +21,9 @@ package org.apache.velocity.site.plexus;
 
 import java.lang.reflect.Field;
 
-import org.codehaus.classworlds.ClassRealm;
-import org.codehaus.classworlds.NoSuchRealmException;
 import org.codehaus.plexus.PlexusContainer;
+import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.codehaus.plexus.classworlds.realm.NoSuchRealmException;
 
 public abstract class PlexusKludgeUtils
 {

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/pom.xml
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/pom.xml?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/pom.xml (original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/pom.xml Sun Jun 20 19:37:54
2010
@@ -104,22 +104,22 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-project</artifactId>
-        <version>2.0.6</version>
+        <version>2.2.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-plugin-api</artifactId>
-        <version>2.0.6</version>
+        <version>2.2.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-api</artifactId>
-        <version>2.0.6</version>
+        <version>2.2.1</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.reporting</groupId>
       <artifactId>maven-reporting-impl</artifactId>
-        <version>2.0.4</version>
+        <version>2.1</version>
     </dependency>
     <dependency>
         <groupId>org.codehaus.plexus</groupId>
@@ -127,19 +127,19 @@
         <version>1.5.5</version>
     </dependency>
     <dependency>
-      <groupId>org.codehaus.plexus</groupId>
-      <artifactId>plexus-container-default</artifactId>
-      <version>1.0-alpha-9-stable-1</version>
-    </dependency>
-    <dependency>
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-sink-api</artifactId>
-        <version>1.0-alpha-8</version>
+        <version>1.1.3</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven.doxia</groupId>
       <artifactId>doxia-core</artifactId>
-        <version>1.0-alpha-8</version>
+        <version>1.1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.doxia</groupId>
+      <artifactId>doxia-module-xhtml</artifactId>
+        <version>1.1.3</version>
     </dependency>
     <dependency>
       <groupId>rome</groupId>
@@ -151,6 +151,16 @@
       <artifactId>commons-io</artifactId>
         <version>1.2</version>
     </dependency>
+    <dependency>
+    	<groupId>org.apache.maven.doxia</groupId>
+    	<artifactId>doxia-site-renderer</artifactId>
+    	<version>1.1.3</version>
+    </dependency>
+    <dependency>
+    	<groupId>org.apache.maven.doxia</groupId>
+    	<artifactId>doxia-module-apt</artifactId>
+    	<version>1.1.3</version>
+    </dependency>
   </dependencies>
 
   <distributionManagement>

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/NewsBlockGenerator.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/NewsBlockGenerator.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/NewsBlockGenerator.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/NewsBlockGenerator.java
Sun Jun 20 19:37:54 2010
@@ -79,7 +79,7 @@ public class NewsBlockGenerator
 
         // The first sentence is our teaser...
         String[] textFields = StringUtils.splitByWholeSeparator(text, ". ");
-        String aptText = " " + textFields[0] + ". [{{{" + newsReport.getOutputName() + ".html#"
+ itemId + "}Read more...}}]";
+        String aptText = " " + textFields[0] + ". [{{{./" + newsReport.getOutputName() +
".html#" + itemId + "}Read more...}}]";
         try
         {
             // Leading space makes sure this gets interpreted as text.

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/macro/VelocityNewsMacro.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/macro/VelocityNewsMacro.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/macro/VelocityNewsMacro.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/macro/VelocityNewsMacro.java
Sun Jun 20 19:37:54 2010
@@ -20,7 +20,6 @@ package org.apache.velocity.site.news.ma
  */
 
 import java.io.File;
-import java.lang.reflect.Method;
 import java.util.ListIterator;
 import java.util.Locale;
 import java.util.ResourceBundle;
@@ -37,9 +36,6 @@ import org.apache.velocity.site.news.Vel
 import org.apache.velocity.site.news.model.Item;
 import org.apache.velocity.site.news.model.NewsManager;
 import org.apache.velocity.site.news.model.NewsModel;
-import org.apache.velocity.site.news.plugin.VelocityNewsPlugin;
-import org.apache.velocity.site.plexus.PlexusKludgeException;
-import org.apache.velocity.site.plexus.PlexusKludgeUtils;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
@@ -54,6 +50,9 @@ import org.codehaus.plexus.personality.p
  */
 public class VelocityNewsMacro extends AbstractMacro implements Contextualizable
 {
+    private static final String DEFAULT_SITE_DIRECTORY = "src/site";
+
+    private static final String DEFAULT_NEWS_FILENAME = "news";
 
     private PlexusContainer container = null;
 
@@ -68,7 +67,7 @@ public class VelocityNewsMacro extends A
         try
         {
             int count = Integer.parseInt(getParameter(request, "count", "5"));
-            generateNewsBlock(sink, count);
+            generateNewsBlock(sink, count, request);
 
         }
         catch (VelocityNewsException vne)
@@ -83,20 +82,24 @@ public class VelocityNewsMacro extends A
         return value != null ? value : defaultValue;
     }
 
-    protected void generateNewsBlock(final Sink sink, final int maxCount) throws VelocityNewsException
+    protected void generateNewsBlock(final Sink sink, final int maxCount, MacroRequest request)
throws VelocityNewsException
     {
 
         try
         {
 
-            Object newsManagerRef = getNewsManager();
-
-            Method newsFileNameMethod = newsManagerRef.getClass().getMethod(NewsManager.NEWS_FILE_NAME_METHOD,
new Class[] {});
-            String newsFileName = (String) newsFileNameMethod.invoke(newsManagerRef, new
Object[] {});
+            String newsFileName = (String) request.getParameter("fileName");
+            if (newsFileName == null)
+            {
+                newsFileName = DEFAULT_NEWS_FILENAME;
+            }
 
-            Method newsSiteDirectoryMethod = newsManagerRef.getClass().getMethod(NewsManager.NEWS_SITE_DIRECTORY_METHOD,
-                    new Class[] {});
-            File siteDirectory = (File) newsSiteDirectoryMethod.invoke(newsManagerRef, new
Object[] {});
+            String siteDirectoryString = (String) request.getParameter("siteDirectory");
+            if (siteDirectoryString == null)
+            {
+                siteDirectoryString = DEFAULT_SITE_DIRECTORY;
+            }
+            File siteDirectory = new File(request.getBasedir(), siteDirectoryString);
 
             final NewsManager newsManager = new NewsManager();
             newsManager.load(siteDirectory, newsFileName);
@@ -169,28 +172,4 @@ public class VelocityNewsMacro extends A
             throw new IllegalStateException("Could not retrieve page name from model!");
         }
     }
-
-    /**
-     * Returns the News Manager from the Plugin.
-     *
-     * @return A {@link DoxiaVelocityContextFactory} instance that generates
-     *         {@link VelocityContext} objects for the render process.
-     */
-    private Object getNewsManager() throws VelocityNewsException
-    {
-        try
-        {
-            PlexusContainer velocityContainer = PlexusKludgeUtils.lookupContainer(container,
-                    VelocityNewsPlugin.CONTAINER_LOOKUP_NAME);
-            return velocityContainer.lookup(NewsManager.ROLE);
-        }
-        catch (PlexusKludgeException pke)
-        {
-            throw new VelocityNewsException("While retrieving News Manager: ", pke);
-        }
-        catch (ComponentLookupException cle)
-        {
-            throw new VelocityNewsException("While retrieving News Manager: ", cle);
-        }
-    }
 }

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/NewsFeedGenerator.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/NewsFeedGenerator.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/NewsFeedGenerator.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/NewsFeedGenerator.java
Sun Jun 20 19:37:54 2010
@@ -28,16 +28,15 @@ import java.io.StringReader;
 import java.io.StringWriter;
 import java.io.Writer;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.doxia.module.xhtml.XhtmlSink;
-import org.apache.maven.doxia.module.xhtml.decoration.render.RenderingContext;
 import org.apache.maven.doxia.parser.ParseException;
 import org.apache.maven.doxia.sink.Sink;
+import org.apache.maven.doxia.sink.render.RenderingContext;
 import org.apache.velocity.site.news.VelocityNewsException;
 import org.apache.velocity.site.news.VelocityNewsUtils;
 import org.apache.velocity.site.news.model.Item;
@@ -235,12 +234,12 @@ public class NewsFeedGenerator
     {
         private NewsItemSink(final Writer writer, final RenderingContext renderingContext)
         {
-            super(writer, renderingContext, Collections.EMPTY_MAP);
+            super(writer);
         }
 
         public void head()
         {
-            resetState();
+            init();
             setHeadFlag(true);
         }
 

Modified: velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/VelocityNewsReport.java
URL: http://svn.apache.org/viewvc/velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/VelocityNewsReport.java?rev=956390&r1=956389&r2=956390&view=diff
==============================================================================
--- velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/VelocityNewsReport.java
(original)
+++ velocity/sandbox/maven-reorg/site/tools/velocity-site-news-plugin/src/main/java/org/apache/velocity/site/news/plugin/VelocityNewsReport.java
Sun Jun 20 19:37:54 2010
@@ -20,7 +20,6 @@ package org.apache.velocity.site.news.pl
  */
 
 import java.io.File;
-import java.lang.reflect.Method;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
@@ -38,11 +37,8 @@ import org.apache.velocity.site.news.Vel
 import org.apache.velocity.site.news.model.Item;
 import org.apache.velocity.site.news.model.NewsManager;
 import org.apache.velocity.site.news.model.NewsModel;
-import org.apache.velocity.site.plexus.PlexusKludgeException;
-import org.apache.velocity.site.plexus.PlexusKludgeUtils;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
-import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
@@ -53,6 +49,7 @@ import org.codehaus.plexus.personality.p
  * @author <a href="mailto:henning@apache.org">Henning P. Schmiedehausen</a>
  * @version $Revision$
  *
+ * @phase site
  * @goal news
  */
 public class VelocityNewsReport extends AbstractMavenReport implements MavenReport, NewsReport,
NewsFeed, Contextualizable
@@ -90,6 +87,13 @@ public class VelocityNewsReport extends 
     private MavenProject project;
 
     /**
+     * The component which keeps all the news information for us.
+     *
+     * @component role="org.apache.velocity.site.news.model.NewsManager"
+     */
+    private NewsManager newsManager;
+
+    /**
      * Configuration of the base URL of the feed
      *
      * @parameter expression="${baseUrl}"
@@ -133,20 +137,7 @@ public class VelocityNewsReport extends 
      */
     public String getOutputName()
     {
-        try
-        {
-            Object newsManager = getNewsManager();
-            Method newsFileNameMethod = newsManager.getClass().getMethod(NewsManager.NEWS_FILE_NAME_METHOD,
new Class[] {});
-            return (String) newsFileNameMethod.invoke(newsManager, new Object[] {});
-        }
-        catch (RuntimeException re)
-        {
-            throw re;
-        }
-        catch (Exception e)
-        {
-            throw new IllegalStateException("Could not retrieve page name from model!");
-        }
+        return newsManager.getNewsFileName();
     }
 
     public ResourceBundle getBundle(final Locale locale)
@@ -185,10 +176,7 @@ public class VelocityNewsReport extends 
 
         try
         {
-
-            Object newsManager = getNewsManager();
-            Method newsModelMethod = newsManager.getClass().getMethod(NewsManager.NEWS_MODEL_METHOD,
new Class[] {});
-            NewsModel newsModel = (NewsModel) newsModelMethod.invoke(newsManager, new Object[]
{});
+            NewsModel newsModel = newsManager.getNewsModel();
 
             if (newsModel != null)
             {
@@ -250,25 +238,4 @@ public class VelocityNewsReport extends 
         newsFeedGenerator.publishFeed();
     }
 
-    /**
-     * Returns the News Manager.
-     *
-     * It must be injected into an instance of this component.
-     *
-     * @return A {@link DoxiaVelocityContextFactory} instance that generates
-     *         {@link VelocityContext} objects for the render process.
-     */
-    private Object getNewsManager() throws ComponentLookupException
-    {
-        try
-        {
-            PlexusContainer velocityContainer = PlexusKludgeUtils.lookupContainer(container,
-                    VelocityNewsPlugin.CONTAINER_LOOKUP_NAME);
-            return velocityContainer.lookup(NewsManager.ROLE);
-        }
-        catch (PlexusKludgeException pke)
-        {
-            throw new ComponentLookupException("While retrieving News Manager: ", pke);
-        }
-    }
 }



Mime
View raw message