[jboss-svn-commits] JBL Code SVN: r5020 - in labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds: . tag tools
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jul 11 17:36:19 EDT 2006
Author: adamw
Date: 2006-07-11 17:36:04 -0400 (Tue, 11 Jul 2006)
New Revision: 5020
Removed:
labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/
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/tag/ShotokuFeedTagHandler.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-feeds/src/java/org/jboss/shotoku/feeds/tools/FeedsTools.java
Log:
http://jira.jboss.org/jira/browse/JBSHOTOKU-36
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 21:22:02 UTC (rev 5019)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/FeedsDescriptor.java 2006-07-11 21:36:04 UTC (rev 5020)
@@ -38,7 +38,6 @@
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;
@@ -78,7 +77,6 @@
private Map<String, Map<String, SpecialFeed>> specialFeeds;
private VariableResolverManager vrm;
- private VelocityContextExpanderManager vcem;
/**
* Feed tag handlers (not yet generated): feed name -> (feed type -> feed
@@ -112,7 +110,6 @@
);
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.
@@ -286,10 +283,6 @@
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/ShotokuFeedTagHandler.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-07-11 21:22:02 UTC (rev 5019)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/ShotokuFeedTagHandler.java 2006-07-11 21:36:04 UTC (rev 5020)
@@ -123,7 +123,10 @@
// Creating a velocity context with parts that won't change in all
// generated feeds.
- VelocityContext vc = new VelocityContext(attributes);
+ Map<String, Object> velocityAttributes =
+ FeedsTools.generateVelocityAttributes(attributes);
+
+ VelocityContext vc = new VelocityContext(velocityAttributes);
FeedsTools.prepareVelocityContext(attributes, fd, vc);
NodeList feedNodeChildren = definition.getChildNodes();
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 21:22:02 UTC (rev 5019)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java 2006-07-11 21:36:04 UTC (rev 5020)
@@ -5,7 +5,6 @@
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;
@@ -33,33 +32,14 @@
Map<String, String> attributes = Tools.getMapFromNodeAttributes(definition);
s.make(attributes);
- Map<String, Object> velocityAttributes = new HashMap<String, Object>();
- for (String key : attributes.keySet()) {
- if (key.startsWith(Constants.CLASS_ATTR_PREFIX)) {
- try {
- System.out.println("PUTTING WITH KEY: " + key.substring(Constants.CLASS_ATTR_PREFIX.length()));
- velocityAttributes.put(
- key.substring(Constants.CLASS_ATTR_PREFIX.length()),
- Class.forName(attributes.get(key)).newInstance());
- } catch (Exception e) {
- log.error("Exception while loading a class to the " +
- "velocity context: " + key, e);
- }
- } else {
- velocityAttributes.put(key, attributes.get(key));
- }
- }
+ Map<String, Object> velocityAttributes =
+ FeedsTools.generateVelocityAttributes(attributes);
// Creating a velocity context with parts that won't change in all
// generated feeds.
VelocityContext vc = new VelocityContext(velocityAttributes);
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 21:22:02 UTC (rev 5019)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java 2006-07-11 21:36:04 UTC (rev 5020)
@@ -61,12 +61,6 @@
*/
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.
*/
Modified: labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/FeedsTools.java
===================================================================
--- labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/FeedsTools.java 2006-07-11 21:22:02 UTC (rev 5019)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/FeedsTools.java 2006-07-11 21:36:04 UTC (rev 5020)
@@ -1,16 +1,41 @@
package org.jboss.shotoku.feeds.tools;
import org.apache.velocity.VelocityContext;
+import org.apache.log4j.Logger;
import org.jboss.shotoku.feeds.FeedsDescriptor;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Map;
+import java.util.HashMap;
/**
* @author Adam Warski (adamw at aster.pl)
*/
public class FeedsTools {
+ private static final Logger log = Logger.getLogger(FeedsDescriptor.class);
+
+ public static Map<String, Object> generateVelocityAttributes(
+ Map<String, String> attributes) {
+ Map<String, Object> velocityAttributes = new HashMap<String, Object>();
+ for (String key : attributes.keySet()) {
+ if (key.startsWith(Constants.CLASS_ATTR_PREFIX)) {
+ try {
+ velocityAttributes.put(
+ key.substring(Constants.CLASS_ATTR_PREFIX.length()),
+ Class.forName(attributes.get(key)).newInstance());
+ } catch (Exception e) {
+ log.error("Exception while loading a class to the " +
+ "velocity context: " + key, e);
+ }
+ } else {
+ velocityAttributes.put(key, attributes.get(key));
+ }
+ }
+
+ return velocityAttributes;
+ }
+
public static void prepareVelocityContext(Map<String, String> attributes,
FeedsDescriptor fd, VelocityContext vc) {
String dateFormat = attributes.get("dateFormat");
More information about the jboss-svn-commits
mailing list