Update of /cvsroot/xdoclet/xdoclet/modules/wsee/src/xdoclet/modules/wsee In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19079/modules/wsee/src/xdoclet/modules/wsee
Modified Files: WsdlSubTask.java WseeTagsHandler.java Log Message: Addresses XDT-1323 and XDT-1114 Index: WsdlSubTask.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/wsee/src/xdoclet/modules/wsee/WsdlSubTask.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** WsdlSubTask.java 6 Aug 2004 12:59:06 -0000 1.1 --- WsdlSubTask.java 4 Apr 2005 16:12:05 -0000 1.2 *************** *** 5,10 **** --- 5,21 ---- package xdoclet.modules.wsee; + import java.io.File; + + import java.text.MessageFormat; + import org.apache.commons.logging.Log; + + import xjavadoc.XClass; + import xjavadoc.XPackage; + + import xdoclet.ConfigParamIntrospector; import xdoclet.XDocletException; import xdoclet.XmlSubTask; + import xdoclet.tagshandler.PackageTagsHandler; + import xdoclet.util.LogUtil; import xdoclet.util.Translator; *************** *** 13,16 **** --- 24,28 ---- * * @author Christoph G. Jung ([EMAIL PROTECTED]) + * @author Jason Essington ([EMAIL PROTECTED]) * @created 23.12.03 * @ant.element display-name="service.wsdl" name="wsdl" parent="xdoclet.modules.wsee.WseeDocletTask" *************** *** 19,22 **** --- 31,35 ---- public class WsdlSubTask extends XmlSubTask { + public final static String DEFAULT_WSDL_FILE_PATTERN = "wsdl/{0}.wsdl"; /** * constants *************** *** 24,27 **** --- 37,42 ---- private static String DEFAULT_TEMPLATE_FILE = "resources/wsdl.xdt"; + private boolean prefixWithPackageStructure = false; + /** * sets template *************** *** 33,36 **** --- 48,72 ---- /** + * Gets the PrefixWithPackageStructure attribute of the TemplateSubTask object + * + * @return The PrefixWithPackageStructure value + */ + public boolean isPrefixWithPackageStructure() + { + return prefixWithPackageStructure; + } + + /** + * Indicates whether or not to prefix with package structure. + * + * @param prefixWithPackageStructure The new PrefixWithPackageStructure value + * @ant.not-required No, default is "true" + */ + public void setPrefixWithPackageStructure(boolean prefixWithPackageStructure) + { + this.prefixWithPackageStructure = prefixWithPackageStructure; + } + + /** * run subtask * *************** *** 49,57 **** public void validateOptions() throws XDocletException { ! setDestinationFile((String) getContext().getConfigParam("WsdlFile")); super.validateOptions(); } /** * notify start of task * --- 85,136 ---- public void validateOptions() throws XDocletException { ! Object wsdlFile = getContext().getConfigParam("wsdlFile"); ! ! if (wsdlFile == ConfigParamIntrospector.NULL || "".equals(wsdlFile)) { ! wsdlFile = DEFAULT_WSDL_FILE_PATTERN; ! } ! setDestinationFile((String) wsdlFile); super.validateOptions(); } /** + * Returns class name for the generated file. {0} substituted by wsee.port-component name. + * + * @param clazz Description of Parameter + * @return The GeneratedClassName value + * @exception XDocletException Description of Exception + */ + protected String getGeneratedFileName(XClass clazz) throws XDocletException + { + Log log = LogUtil.getLog(WsdlSubTask.class, "getGeneratedFileName"); + + XPackage pak = clazz.getContainingPackage(); + String package_structure = null; + + if (isPrefixWithPackageStructure() == true) + // This will do package substitution too + package_structure = PackageTagsHandler.packageNameAsPathFor(pak); + else + package_structure = null; + + String packageName = isPackageSubstitutionInheritanceSupported() == true ? package_structure : null; + + String serviceName = getCurrentClass().getDoc().getTagAttributeValue(WseeTagsHandler.PORT_COMPONENT, "name"); + String file = new File(packageName, serviceName).toString(); + + String destinationFile = MessageFormat.format(getDestinationFile(), new Object[]{file}); + + if (log.isDebugEnabled()) { + log.debug("clazz.getName()=" + clazz.getName()); + log.debug("clazz.getQualifiedName()=" + clazz.getQualifiedName()); + log.debug("pak=" + pak); + log.debug("packageName=" + packageName); + log.debug("serviceName=" + serviceName); + log.debug("destinationFile=" + destinationFile); + } + return destinationFile; + } + + /** * notify start of task * *************** *** 67,69 **** --- 146,170 ---- } + /** + * Describe what the method does + * + * @param clazz Describe what the parameter does + * @return Describe the return value + * @exception XDocletException + */ + protected boolean matchesGenerationRules(XClass clazz) throws XDocletException + { + Log log = LogUtil.getLog(WsdlSubTask.class, "matchesGenerationRules"); + + if (super.matchesGenerationRules(clazz) == false) { + log.debug("Skip bean " + clazz.getQualifiedName() + " because super.matchesGenerationRules() returned false."); + return false; + } + + // TODO improve this check to make sure that our class is also a service-endpoint (SLSB or servlet) + boolean isPortComponent = getCurrentClass().getDoc().hasTag(WseeTagsHandler.PORT_COMPONENT, false); + + return isPortComponent; + } + } Index: WseeTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/wsee/src/xdoclet/modules/wsee/WseeTagsHandler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** WseeTagsHandler.java 11 Oct 2004 11:20:48 -0000 1.3 --- WseeTagsHandler.java 4 Apr 2005 16:12:17 -0000 1.4 *************** *** 5,8 **** --- 5,10 ---- package xdoclet.modules.wsee; + import java.io.File; + import java.text.MessageFormat; import java.util.Collection; import java.util.Iterator; *************** *** 15,18 **** --- 17,21 ---- import xjavadoc.XTag; + import xdoclet.ConfigParamIntrospector; import xdoclet.DocletContext; import xdoclet.DocletSupport; *************** *** 20,23 **** --- 23,27 ---- import xdoclet.XDocletTagSupport; + import xdoclet.tagshandler.PackageTagsHandler; /** *************** *** 25,28 **** --- 29,33 ---- * * @author Christoph G. Jung ([EMAIL PROTECTED]) + * @author Jason Essington ([EMAIL PROTECTED]) * @created 23.12.03 * @version $Revision$ *************** *** 173,194 **** { XClass clazz = getCurrentClass(); ! XTag ejbTag = clazz.getDoc().getTag("ejb.interface"); ! ! if (ejbTag == null) { ! ejbTag = clazz.getDoc().getTag("web.servlet"); ! if (ejbTag == null) { ! return null; } } ! String spec = ejbTag.getAttributeValue("service-endpoint-class"); ! ! if (spec == null || "".equals(spec)) { ! spec = clazz.getQualifiedName(); ! if (spec.endsWith("Bean")) { ! spec = spec.substring(0, spec.length() - 4); } - spec += "Service"; } return spec; } --- 178,209 ---- { XClass clazz = getCurrentClass(); ! String pkg = PackageTagsHandler.getPackageNameFor(clazz.getContainingPackage(), true); ! XTag ejbTag = null; ! String spec = null; ! ! if (clazz.getDoc().hasTag("ejb.bean")) { ! ejbTag = clazz.getDoc().getTag("ejb.interface"); ! if (ejbTag != null) { ! spec = ejbTag.getAttributeValue("service-endpoint-class"); ! } ! // if we haven't explicitly defined a service interface name, try to build the default name. ! if (spec == null || "".equals(spec)) { ! spec = pkg + "." + clazz.getName(); ! if (spec.endsWith("Bean")) ! spec = spec.substring(0, spec.length() - 4); } } + else { ! ejbTag = clazz.getDoc().getTag("web.servlet"); ! if (ejbTag != null) { ! spec = ejbTag.getAttributeValue("service-endpoint-class"); ! } ! if (spec == null || "".equals(spec)) { ! spec = pkg + "." + clazz.getName(); ! spec += "Service"; } } + return spec; } *************** *** 228,237 **** throws XDocletException { if (getCurrentClass() != null) { ! return getNamespaceURI(getCurrentClass()); } else { ! return getNamespaceForPackage(getCurrentPackage()); } } --- 243,265 ---- throws XDocletException { + String ns = ""; + if (getCurrentClass() != null) { ! ns = getNamespaceURI(getCurrentClass()); ! } ! else if (getCurrentPackage() != null) { ! ns = getNamespaceForPackage(getCurrentPackage()); } else { ! // we don't have a current package or class, so just get the first namespace. ! List nsmappings = getPackageNamespaceMappings(); ! ! if (!nsmappings.isEmpty()) { ! WseeDocletTask.PackageNamespaceMapping ps = (WseeDocletTask.PackageNamespaceMapping) nsmappings.get(0); ! ! ns = ps.getNamespace(); ! } } + return ns; } *************** *** 253,256 **** --- 281,285 ---- generate(template); } + } *************** *** 282,284 **** --- 311,477 ---- } + /** + * conditional to handle per class wsdl + * + * @param template + * @param props + * @throws XDocletException + */ + public void ifWsdlPerClass(String template, Properties props) throws XDocletException + { + if (isWsdlPerClass()) + generate(template); + } + + /** + * conditional to handle single wsdl generation + * + * @param template + * @param props + * @throws XDocletException + */ + public void ifNotWsdlPerClass(String template, Properties props) throws XDocletException + { + if (!isWsdlPerClass()) + generate(template); + } + + /** + * Constructs a guestimated filename for the wsdl file. It also attemts to decide if the file should be in META-INF + * or WEB-INF. This should yeild a filename that will be correct for use within the webservices.xml file. + * + * @param props If prefixWithPackageStructure is specified for the wsdl sub task, the property + * prefixWithPackage="true" will need to be specified. + * @return + */ + public String wsdlFilename(Properties props) + { + XClass clazz = getCurrentClass(); + String wsdlPattern = getWsdlFilePattern(); + + String packageName = null; + String file = null; + + if (isWsdlPerClass()) { + + boolean prefixWithPackage = false; + String hasPrefix = props.getProperty("prefixWithPackage"); + + if (hasPrefix != null && !"".equals(hasPrefix)) { + prefixWithPackage = Boolean.getBoolean(hasPrefix); + } + + if (prefixWithPackage) { + packageName = PackageTagsHandler.packageNameAsPathWithoutSubstitutionFor(clazz.getContainingPackage()); + } + + String serviceName = getCurrentClass().getDoc().getTagAttributeValue(WseeTagsHandler.PORT_COMPONENT, "name"); + + file = new File(packageName, serviceName).toString(); + } + + // assume our wsdl files will start in WEB-INF/ unless the current class has an ejb.bean tag + String prefix = "WEB-INF/"; + + if (clazz != null && clazz.getDoc().hasTag("ejb.bean")) { + prefix = "META-INF/"; + } + return prefix + MessageFormat.format(wsdlPattern, new Object[]{file}); + } + + /** + * Constructs a guestimated filename for the jaxrpc file + * + * @param props If prefixWithPackageStructur is specified for the wsdl sub task, the property + * prefixWithPackage="true" will need to be specified. + * @return + */ + public String jaxrpcMappingFilename(Properties props) + { + XClass clazz = getCurrentClass(); + String jaxrpcPattern = getJaxrpcFilePattern(); + + String packageName = null; + String file = null; + + if (isJaxrpcPerClass()) { + + boolean prefixWithPackage = true; + String hasPrefix = props.getProperty("prefixWithPackage"); + + if (hasPrefix != null && !"".equals(hasPrefix)) { + prefixWithPackage = Boolean.getBoolean(hasPrefix); + } + + if (prefixWithPackage) { + packageName = PackageTagsHandler.packageNameAsPathWithoutSubstitutionFor(clazz.getContainingPackage()); + } + + file = new File(packageName, getCurrentClass().getName()).toString(); + } + + + // assume our wsdl files will start in WEB-INF/ unless the current class has an ejb.bean tag + String prefix = "WEB-INF/"; + + if (clazz != null && clazz.getDoc().hasTag("ejb.bean")) { + prefix = "META-INF/"; + } + return prefix + MessageFormat.format(jaxrpcPattern, new Object[]{file}); + } + + /** + * Is wsdl generation by class or as a single file? + * + * @return true if by class + */ + protected boolean isWsdlPerClass() + { + return getWsdlFilePattern().indexOf("{0}") != -1; + } + + /** + * Is jaxrpc generation by class or as a single file? + * + * @return true if by class + */ + protected boolean isJaxrpcPerClass() + { + return getJaxrpcFilePattern().indexOf("{0}") != -1; + } + + /** + * Get the value of the wsdl file pattern + * + * @return + */ + protected String getWsdlFilePattern() + { + String pattern = null; + Object wsdlFile = DocletContext.getInstance().getConfigParam("wsdlFile"); + + if (wsdlFile == ConfigParamIntrospector.NULL || "".equals(wsdlFile)) { + pattern = WsdlSubTask.DEFAULT_WSDL_FILE_PATTERN; + } + else { + pattern = (String) wsdlFile; + } + return pattern; + } + + /** + * Get the value of the wsdl file pattern + * + * @return + */ + protected String getJaxrpcFilePattern() + { + String pattern = ""; + Object jaxrpcFile = DocletContext.getInstance().getConfigParam("jaxrpcMappingFile"); + + if (jaxrpcFile != ConfigParamIntrospector.NULL) { + pattern = (String) jaxrpcFile; + } + return pattern; + } } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel