1 5 package xdoclet.modules.ejb.dd; 6 7 import xdoclet.XDocletException; 8 import xdoclet.XDocletMessages; 9 import xdoclet.modules.ejb.EjbDocletTask; 10 import xdoclet.modules.ejb.EjbTagsHandler; 11 import xdoclet.modules.ejb.XDocletModulesEjbMessages; 12 13 import xdoclet.modules.ejb.dd.AbstractEjbDeploymentDescriptorSubTask; 14 import xdoclet.util.Translator; 15 16 61 public class EjbDotXmlSubTask extends AbstractEjbDeploymentDescriptorSubTask 62 { 63 private final static String DEFAULT_TEMPLATE_FILE = "resources/ejb-jar_xml.xdt"; 64 65 private final static String DD_FILE_NAME = "ejb-jar.xml"; 66 67 private final static String DD_PUBLICID_11 = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN"; 68 69 private final static String DD_SYSTEMID_11 = "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd"; 70 71 private final static String DTD_FILE_NAME_11 = "resources/ejb11-jar.dtd"; 72 73 private final static String DD_PUBLICID_20 = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN"; 74 75 private final static String DD_SYSTEMID_20 = "http://java.sun.com/dtd/ejb-jar_2_0.dtd"; 76 77 private final static String DTD_FILE_NAME_20 = "resources/ejb20-jar.dtd"; 78 79 private final static String XSD_LOCATION_21 = "http://java.sun.com/xml/ns/j2ee/ejb-jar_2_1.xsd"; 80 81 private final static String XSD_FILE_NAME_21 = "resources/ejb-jar_2_1.xsd"; 82 83 protected String description; 84 85 protected String displayname; 86 87 protected String smallicon = ""; 88 89 protected String largeicon = ""; 90 91 protected String clientjar = "false"; 92 93 public EjbDotXmlSubTask() 94 { 95 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 96 setDestinationFile(DD_FILE_NAME); 97 setDescription(Translator.getString(XDocletMessages.class, XDocletMessages.NO_DESCRIPTION)); 98 setDisplayname(Translator.getString(XDocletMessages.class, XDocletMessages.GENERATED_BY_XDOCLET)); 99 } 100 101 106 public String getSmallicon() 107 { 108 return smallicon; 109 } 110 111 116 public String getLargeicon() 117 { 118 return largeicon; 119 } 120 121 122 127 public String getDisplayname() 128 { 129 return displayname; 130 } 131 132 137 public String getDescription() 138 { 139 return description; 140 } 141 142 147 public String getClientjar() 148 { 149 return clientjar; 150 } 151 152 157 public void setSmallicon(String smallicon) 158 { 159 this.smallicon = smallicon; 160 } 161 162 167 public void setLargeicon(String largeicon) 168 { 169 this.largeicon = largeicon; 170 } 171 172 177 public void setDisplayname(String displayname) 178 { 179 this.displayname = displayname; 180 } 181 182 187 public void setDescription(String description) 188 { 189 this.description = description; 190 } 191 192 197 public void setClientjar(String clientjar) 198 { 199 this.clientjar = clientjar; 200 } 201 202 207 public void validateOptions() throws XDocletException 208 { 209 super.validateOptions(); 210 211 if (getDestinationFile() == null || getDestinationFile().trim().equals("")) { 212 throw new XDocletException(Translator.getString(XDocletMessages.class, XDocletMessages.PARAMETER_MISSING_OR_EMPTY, new String []{"destinationFile"})); 213 } 214 } 215 216 221 public void execute() throws XDocletException 222 { 223 String ejbSpec = EjbTagsHandler.getEjbSpec(); 224 225 if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_1_1)) { 226 setPublicId(DD_PUBLICID_11); 227 setSystemId(DD_SYSTEMID_11); 228 setDtdURL(getClass().getResource(DTD_FILE_NAME_11)); 229 } 230 else if (ejbSpec.equals(EjbDocletTask.EjbSpecVersion.EJB_2_1)) { 231 setSchema(XSD_LOCATION_21); 232 setSchemaURL(getClass().getResource(XSD_FILE_NAME_21)); 233 } 234 else { 235 setPublicId(DD_PUBLICID_20); 236 setSystemId(DD_SYSTEMID_20); 237 setDtdURL(getClass().getResource(DTD_FILE_NAME_20)); 238 } 239 240 startProcess(); 241 } 242 243 248 protected void engineStarted() throws XDocletException 249 { 250 System.out.println(Translator.getString(XDocletModulesEjbMessages.class, XDocletModulesEjbMessages.GENERATING_DD, new String []{getDestinationFile()})); 251 } 252 } 253 | Popular Tags |