[jboss-svn-commits] JBL Code SVN: r5017 - in labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds: tag tools velocity

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Jul 11 17:02:36 EDT 2006


Author: adamw
Date: 2006-07-11 17:02:35 -0400 (Tue, 11 Jul 2006)
New Revision: 5017

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/tools/Constants.java
   labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java
Log:
http://jira.jboss.org/jira/browse/JBLAB-711


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 20:34:59 UTC (rev 5016)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tag/TagFeedTagHandler.java	2006-07-11 21:02:35 UTC (rev 5017)
@@ -18,7 +18,7 @@
  * @author Adam Warski (adamw at aster.pl)
  */
 public class TagFeedTagHandler extends FeedTagHandler {
-    //private static final Logger log = Logger.getLogger(FeedsDescriptor.class);
+    private static final Logger log = Logger.getLogger(FeedsDescriptor.class);
 
     public TagFeedTagHandler(String feedName, String group, Node definition, Substitution s) {
         super(feedName, group, definition, s);
@@ -37,6 +37,18 @@
         VelocityContext vc = new VelocityContext(attributes);
         FeedsTools.prepareVelocityContext(attributes, fd, vc);
 
+        for (String key : attributes.keySet()) {
+            if (key.startsWith(Constants.CLASS_ATTR_PREFIX)) {
+                try {
+                    vc.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);
+                }
+            }
+        }
+
         for (VelocityContextExpander vce : fd.getVelocityContextExpanderManager().
                 getExpandersForTagFeeds()) {
             vce.expandContext(vc);

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 20:34:59 UTC (rev 5016)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/tools/Constants.java	2006-07-11 21:02:35 UTC (rev 5017)
@@ -72,4 +72,11 @@
      */
     public static final String NAME_ATTR    = "name";
     public static final String DISP_NAME_ATTR   = "display-name";
+
+    /**
+     * Xml node attribute prefix denoting an attribute for which
+     * an instance of the "attribute-value" class should be loaded
+     * and placed in the velocity context.
+     */
+    public static final String CLASS_ATTR_PREFIX = "class-";
 }

Modified: 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 20:34:59 UTC (rev 5016)
+++ labs/shotoku/trunk/shotoku-feeds/src/java/org/jboss/shotoku/feeds/velocity/VelocityContextExpanderManager.java	2006-07-11 21:02:35 UTC (rev 5017)
@@ -21,7 +21,6 @@
 
         for (String expander : props.getProperty(id + Constants.VC_EXP_TAGS,
                 "").split("[,]")) {
-            System.out.println("TRYING TO LOAD VCEC: " + expander);
             try {
                 tagsExps.add((VelocityContextExpander)
                         Class.forName(expander).newInstance());




More information about the jboss-svn-commits mailing list