1 5 package xdoclet.modules.wsee; 6 7 import java.io.File ; 8 9 import java.text.MessageFormat ; 10 import org.apache.commons.logging.Log; 11 12 import xjavadoc.XClass; 13 import xjavadoc.XPackage; 14 15 import xdoclet.ConfigParamIntrospector; 16 import xdoclet.XDocletException; 17 import xdoclet.XmlSubTask; 18 import xdoclet.tagshandler.PackageTagsHandler; 19 import xdoclet.util.LogUtil; 20 import xdoclet.util.Translator; 21 22 31 public class WsdlSubTask extends XmlSubTask 32 { 33 public final static String DEFAULT_WSDL_FILE_PATTERN = "wsdl/{0}.wsdl"; 34 37 private static String DEFAULT_TEMPLATE_FILE = "resources/wsdl.xdt"; 38 39 private boolean prefixWithPackageStructure = false; 40 41 44 public WsdlSubTask() 45 { 46 setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE_FILE)); 47 } 48 49 54 public boolean isPrefixWithPackageStructure() 55 { 56 return prefixWithPackageStructure; 57 } 58 59 65 public void setPrefixWithPackageStructure(boolean prefixWithPackageStructure) 66 { 67 this.prefixWithPackageStructure = prefixWithPackageStructure; 68 } 69 70 75 public void execute() throws XDocletException 76 { 77 validateOptions(); 78 startProcess(); 79 } 80 81 85 public void validateOptions() throws XDocletException 86 { 87 Object wsdlFile = getContext().getConfigParam("wsdlFile"); 88 89 if (wsdlFile == ConfigParamIntrospector.NULL || "".equals(wsdlFile)) { 90 wsdlFile = DEFAULT_WSDL_FILE_PATTERN; 91 } 92 setDestinationFile((String ) wsdlFile); 93 super.validateOptions(); 94 } 95 96 103 protected String getGeneratedFileName(XClass clazz) throws XDocletException 104 { 105 Log log = LogUtil.getLog(WsdlSubTask.class, "getGeneratedFileName"); 106 107 XPackage pak = clazz.getContainingPackage(); 108 String package_structure = null; 109 110 if (isPrefixWithPackageStructure() == true) 111 package_structure = PackageTagsHandler.packageNameAsPathFor(pak); 113 else 114 package_structure = null; 115 116 String packageName = isPackageSubstitutionInheritanceSupported() == true ? package_structure : null; 117 118 String serviceName = getCurrentClass().getDoc().getTagAttributeValue(WseeTagsHandler.PORT_COMPONENT, "name"); 119 String file = new File (packageName, serviceName).toString(); 120 121 String destinationFile = MessageFormat.format(getDestinationFile(), new Object []{file}); 122 123 if (log.isDebugEnabled()) { 124 log.debug("clazz.getName()=" + clazz.getName()); 125 log.debug("clazz.getQualifiedName()=" + clazz.getQualifiedName()); 126 log.debug("pak=" + pak); 127 log.debug("packageName=" + packageName); 128 log.debug("serviceName=" + serviceName); 129 log.debug("destinationFile=" + destinationFile); 130 } 131 return destinationFile; 132 } 133 134 139 protected void engineStarted() throws XDocletException 140 { 141 System.out.println( 142 Translator.getString( 143 XDocletModulesMessages.class, 144 XDocletModulesMessages.GENERATING_WSDL_DESCRIPTOR, 145 new String []{getDestinationFile()})); 146 } 147 148 155 protected boolean matchesGenerationRules(XClass clazz) throws XDocletException 156 { 157 Log log = LogUtil.getLog(WsdlSubTask.class, "matchesGenerationRules"); 158 159 if (super.matchesGenerationRules(clazz) == false) { 160 log.debug("Skip bean " + clazz.getQualifiedName() + " because super.matchesGenerationRules() returned false."); 161 return false; 162 } 163 164 boolean isPortComponent = getCurrentClass().getDoc().hasTag(WseeTagsHandler.PORT_COMPONENT, false); 166 167 return isPortComponent; 168 } 169 170 } 171 | Popular Tags |