[jboss-svn-commits] JBL Code SVN: r5013 - in labs/shotoku/trunk: shotoku-base/src/java/org/jboss/shotoku/tools shotoku-feeds shotoku-feeds/src/java/org/jboss/shotoku/feeds shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity shotoku-file-access/src/web/WEB-INF
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 11 15:45:38 EDT 2006
Author: adamw
Date: 2006-07-11 15:45:14 -0400 (Tue, 11 Jul 2006)
New Revision: 5013
Added:
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpander.java
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java
Modified:
labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java
labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java
labs/shotoku/trunk/shotoku-file-access/src/web/WEB-INF/jboss-app.xml
Log:
http://jira.jboss.org/jira/browse/JBSHOTOKU-86
Modified: labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java
===================================================================
--- labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-base/src/java/org/jboss/shotoku/tools/Tools.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -235,6 +235,13 @@
}
/**
+ * Checks if the given string is empty (null or "").
+ */
+ public static boolean isEmpty(String s) {
+ return (s == null) || ("".equals(s));
+ }
+
+ /**
* Transferes all bytes from the given input stream to the given output
* stream.
*
Modified: labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/shotoku-feeds.iml 2006-07-11 19:45:14 UTC (rev 5013)
@@ -13,6 +13,8 @@
<orderEntry type="module" module-name="shotoku-aop" />
<orderEntry type="library" name="feeds" level="application" />
<orderEntry type="library" name="jboss" level="application" />
+ <orderEntry type="library" name="velocity" level="application" />
+ <orderEntry type="module" module-name="shotoku-tags" />
<orderEntryProperties />
</component>
</module>
Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -38,6 +38,7 @@
import org.jboss.shotoku.feeds.tag.FeedTagHandler;
import org.jboss.shotoku.feeds.tag.FeedTagHandlerManager;
import org.jboss.shotoku.feeds.tools.Constants;
+import org.jboss.shotoku.feeds.velocity.VelocityContextExpanderManager;
import org.jboss.shotoku.tools.Pair;
import org.jboss.shotoku.tools.Tools;
import org.jboss.shotoku.aop.CacheItem;
@@ -77,6 +78,7 @@
private Map<String, Map<String, SpecialFeed>> specialFeeds;
private VariableResolverManager vrm;
+ private VelocityContextExpanderManager vcem;
/**
* Feed tag handlers (not yet generated): feed name -> (feed type -> feed
@@ -110,6 +112,7 @@
);
vrm = new VariableResolverManager(id, props);
+ vcem = new VelocityContextExpanderManager(id, props);
feedTagHandlers = new HashMap<String, Map<String, FeedTagHandler>>();
// Creating the maps that will hold the feeds.
@@ -283,6 +286,10 @@
return vrm;
}
+ public VelocityContextExpanderManager getVelocityContextExpanderManager() {
+ return vcem;
+ }
+
/**
* Releases all feeds - deletes temporary files which contain them.
*/
Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -5,6 +5,7 @@
import org.jboss.shotoku.feeds.FeedsDescriptor;
import org.jboss.shotoku.feeds.tools.Constants;
import org.jboss.shotoku.feeds.FeedFactory;
+import org.jboss.shotoku.feeds.velocity.VelocityContextExpander;
import org.jboss.shotoku.feeds.data.SpecialFeed;
import org.jboss.shotoku.feeds.tools.FeedsTools;
import org.jboss.shotoku.feeds.variables.Substitution;
@@ -36,6 +37,11 @@
VelocityContext vc = new VelocityContext(attributes);
FeedsTools.prepareVelocityContext(attributes, fd, vc);
+ for (VelocityContextExpander vce : fd.getVelocityContextExpanderManager().
+ getExpandersForTagFeeds()) {
+ vce.expandContext(vc);
+ }
+
String feedName = getFeedName();
String feedType = getFeedType();
Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -61,6 +61,12 @@
*/
public final static String TYPE_VARIABLE = "${type}";
+ /**
+ * Property name suffix, under which information about tag
+ * feeds velocity context expandrs can be found.
+ */
+ public static final String VC_EXP_TAGS = ".vcexp.tags";
+
/*
* Xml node attributes denoting a feed name and display name.
*/
Added: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpander.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpander.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpander.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -0,0 +1,10 @@
+package org.jboss.shotoku.feeds.velocity;
+
+import org.apache.velocity.VelocityContext;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public interface VelocityContextExpander {
+ public void expandContext(VelocityContext vc);
+}
Added: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java 2006-07-11 19:45:14 UTC (rev 5013)
@@ -0,0 +1,34 @@
+package org.jboss.shotoku.feeds.velocity;
+
+import org.jboss.shotoku.feeds.tools.Constants;
+import org.jboss.shotoku.feeds.FeedsDescriptor;
+import org.apache.log4j.Logger;
+
+import java.util.List;
+import java.util.Properties;
+
+/**
+ * @author Adam Warski (adamw at aster.pl)
+ */
+public class VelocityContextExpanderManager {
+ private static final Logger log = Logger.getLogger(FeedsDescriptor.class);
+
+ List<VelocityContextExpander> tagsExps;
+
+ public VelocityContextExpanderManager(String id, Properties props) {
+ for (String expander : props.getProperty(id + Constants.VC_EXP_TAGS,
+ "").split("[,]")) {
+ try {
+ tagsExps.add((VelocityContextExpander)
+ Class.forName(expander).newInstance());
+ } catch (Exception e) {
+ log.error("Velocity context expander class " + expander +
+ " could not be found.", e);
+ }
+ }
+ }
+
+ public List<VelocityContextExpander> getExpandersForTagFeeds() {
+ return tagsExps;
+ }
+}
Modified: labs/shotoku/trunk/shotoku-file-access/src/web/WEB-INF/jboss-app.xml
===================================================================
--- labs/shotoku/trunk/shotoku-file-access/src/web/WEB-INF/jboss-app.xml 2006-07-11 19:43:33 UTC (rev 5012)
+++ labs/shotoku/trunk/shotoku-file-access/src/web/WEB-INF/jboss-app.xml 2006-07-11 19:45:14 UTC (rev 5013)
@@ -1,3 +1,3 @@
<jboss-app>
- <app-name>shotokue-file-access</app-name>
+ <app-name>shotoku-file-access</app-name>
</jboss-app>
More information about the jboss-svn-commits
mailing list