KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > jboss > ejb > JBossTagsHandler


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.jboss.ejb;
6
7 import java.io.File JavaDoc;
8 import java.util.Collection JavaDoc;
9 import java.util.Iterator JavaDoc;
10 import java.util.Properties JavaDoc;
11 import xjavadoc.*;
12 import xdoclet.XDocletException;
13 import xdoclet.tagshandler.ClassTagsHandler;
14
15 /**
16  * @author Dmitri Colebatch (dim@bigpond.net.au)
17  * @author Julien Viet (julien_viet@yahoo.fr)
18  * @created October 18, 2001
19  * @xdoclet.taghandler namespace="JBoss"
20  * @version $Revision: 1.12 $
21  */

22 public class JBossTagsHandler extends ClassTagsHandler
23 {
24     /**
25      * Evaluates the body if at least one of the classes has an jboss:dvc tag, otherwise not.
26      *
27      * @param template The body of the block tag
28      * @exception XDocletException Description of Exception
29      */

30     public void ifHasDVC(String JavaDoc template) throws XDocletException
31     {
32         boolean hasDVC = false;
33         Collection JavaDoc classes = getXJavaDoc().getSourceClasses();
34
35         for (Iterator JavaDoc i = classes.iterator(); i.hasNext(); ) {
36             XClass clazz = (XClass) i.next();
37             XTag dvc = clazz.getDoc().getTag("jboss:dvc");
38
39             if (dvc != null) {
40                 hasDVC = true;
41                 break;
42             }
43         }
44
45         // Looks for a jbosscmp-jdbc-dvc.xml merge file
46
if (!hasDVC) {
47             File JavaDoc mergeFile = new File JavaDoc(getDocletContext().getActiveSubTask().getMergeDir(), "jbosscmp-jdbc-dvc.xml");
48
49             if (mergeFile.exists())
50                 hasDVC = true;
51         }
52
53         if (hasDVC) {
54             generate(template);
55         }
56     }
57
58     public void ifMethodTagMatchesClassTag(String JavaDoc template, Properties JavaDoc attributes) throws XDocletException
59     {
60         String JavaDoc paramName = attributes.getProperty("paramName");
61         String JavaDoc classLoadGroup = getCurrentClassTag().getAttributeValue(paramName);
62         String JavaDoc methodLoadGroup = getCurrentMethodTag().getAttributeValue(paramName);
63
64         if (classLoadGroup.equals(methodLoadGroup)) {
65             generate(template);
66         }
67     }
68
69 }
70
Popular Tags