1 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 21 public class Mx4jDescriptionAdapterSubTask extends TemplateSubTask 22 { 23 protected static String mbeanDescriptionClassPattern; 24 25 private static String DEFAULT_TEMPLATE_FILE = "resources/mx4j-mbean-description.xdt"; 26 27 private static String GENERATED_FILE_NAME = "{0}MBeanDescription.java"; 28 29 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 46 public static String getMbeanDescriptionClassPattern() 47 { 48 return mbeanDescriptionClassPattern; 49 } 50 51 56 public void setPattern(String new_pattern) 57 { 58 mbeanDescriptionClassPattern = new_pattern; 59 } 60 61 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 []{"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 |