KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > mx4j > Mx4jDescriptionAdapterSubTask


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

5 package xdoclet.modules.mx4j;
6
7 import xdoclet.TemplateSubTask;
8 import xdoclet.XDocletException;
9 import xdoclet.XDocletMessages;
10 import xdoclet.modules.jmx.XDocletModulesJmxMessages;
11 import xdoclet.util.Translator;
12
13 /**
14  * Generates MBeanDescriptionAdaptor subclass for Mx4j.
15  *
16  * @author Dmitri Colebatch (dim@bigpond.net.au)
17  * @created January 31, 2002
18  * @ant.element display-name="Mx4j Description" name="mx4jdescription" parent="xdoclet.modules.jmx.JMXDocletTask"
19  * @version $Revision: 1.7 $
20  */

21 public class Mx4jDescriptionAdapterSubTask extends TemplateSubTask
22 {
23     protected static String JavaDoc mbeanDescriptionClassPattern;
24
25     private static String JavaDoc DEFAULT_TEMPLATE_FILE = "resources/mx4j-mbean-description.xdt";
26
27     private static String JavaDoc GENERATED_FILE_NAME = "{0}MBeanDescription.java";
28
29     /**
30      * Describe what the Mx4jDescriptionAdapterSubTask constructor does
31      */

32     public Mx4jDescriptionAdapterSubTask()
33     {
34         setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE));
35         setDestinationFile(GENERATED_FILE_NAME);
36         setHavingClassTag("jmx:mbean");
37
38         mbeanDescriptionClassPattern = "{0}MBeanDescription";
39     }
40
41     /**
42      * Gets the MbeanDescriptionClassPattern attribute of the Mx4jDescriptionAdapterSubTask class
43      *
44      * @return The MbeanDescriptionClassPattern value
45      */

46     public static String JavaDoc getMbeanDescriptionClassPattern()
47     {
48         return mbeanDescriptionClassPattern;
49     }
50
51     /**
52      * Sets the Pattern attribute of the Mx4jDescriptionAdapterSubTask object
53      *
54      * @param new_pattern The new Pattern value
55      */

56     public void setPattern(String JavaDoc new_pattern)
57     {
58         mbeanDescriptionClassPattern = new_pattern;
59     }
60
61     /**
62      * Called to validate configuration parameters.
63      *
64      * @exception XDocletException Description of Exception
65      */

66     public void validateOptions() throws XDocletException
67     {
68         super.validateOptions();
69
70         if (getMbeanDescriptionClassPattern() == null || getMbeanDescriptionClassPattern().trim().equals("")) {
71             throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String JavaDoc[]{"pattern"}));
72         }
73
74         if (getMbeanDescriptionClassPattern().indexOf("{0}") == -1) {
75             throw new XDocletException(Translator.getString(XDocletModulesJmxMessages.class, XDocletModulesJmxMessages.PATTERN_HAS_NO_PLACEHOLDER));
76         }
77     }
78 }
79
Popular Tags