1 26 27 package org.objectweb.jonas.ant.jonasbase.wsdl; 28 29 import java.util.ArrayList ; 30 import java.util.Iterator ; 31 import java.util.List ; 32 import java.util.Properties ; 33 34 import org.objectweb.jonas.ant.JOnASBaseTask; 35 import org.objectweb.jonas.ant.jonasbase.BaseTaskItf; 36 import org.objectweb.jonas.ant.jonasbase.JReplace; 37 import org.objectweb.jonas.ant.jonasbase.JTask; 38 39 43 public class WsdlPublish extends JTask implements BaseTaskItf { 44 45 48 private static final String INFO = "[WSDL-Publish] "; 49 50 53 private static final String WSDL_HANDLER_PROPERTY = "jonas.service.ws.wsdlhandlers"; 54 55 58 private static final String TOKEN_WSDLHANDLER = WSDL_HANDLER_PROPERTY + " file1"; 59 60 63 private List files = new ArrayList (); 64 65 68 private List uddis = new ArrayList (); 69 70 74 public void addConfiguredFile(File file) { 75 files.add(file); 76 } 77 78 82 public void addConfiguredUddi(Uddi uddi) { 83 uddis.add(uddi); 84 } 85 86 90 public void setFiles(List files) { 91 this.files = files; 92 } 93 94 98 public void setUddis(List uddis) { 99 this.uddis = uddis; 100 } 101 102 105 public void execute() { 106 107 String fileNameList = ""; 108 109 java.io.File jonasBaseConfDir = new java.io.File (getDestDir().getPath() + java.io.File.separator + "conf"); 110 111 for (Iterator it = files.iterator(); it.hasNext();) { 113 File f = (File) it.next(); 114 115 String dir = f.getDir(); 116 String encoding = f.getEncoding(); 117 String name = f.getName(); 118 119 if (fileNameList.length() == 0) { 121 fileNameList = name; 122 } else { 123 fileNameList += "," + name; 124 } 125 126 String fileName = name + ".properties"; 127 128 Properties props = new Properties (); 130 props.put("jonas.service.wsdl.class", File.FILEWSDLHANDLER_CLASS); 131 props.put("jonas.service.publish.file.directory", dir); 132 props.put("jonas.service.publish.file.encoding", encoding); 133 java.io.File writeFile = new java.io.File (jonasBaseConfDir, fileName); 134 log(INFO + "Generating a WSDL publish file with name '" + name + "', dir '" + dir + "' and encoding '" 135 + encoding + "' in file '" + writeFile + "'..."); 136 writePropsToFile(INFO, props, writeFile); 137 } 138 139 for (Iterator it = uddis.iterator(); it.hasNext();) { 141 Uddi uddi = (Uddi) it.next(); 142 143 String name = uddi.getName(); 144 String username = uddi.getUserName(); 145 String password = uddi.getPassword(); 146 String orgName = uddi.getOrgName(); 147 String orgDesc = uddi.getOrgDesc(); 148 String orgPersonName = uddi.getOrgPersonName(); 149 String lifecyclemanagerURL = uddi.getLifecyclemanagerURL(); 150 String queryManagerURL = uddi.getQueryManagerURL(); 151 152 if (fileNameList.length() == 0) { 154 fileNameList = name; 155 } else { 156 fileNameList += "," + name; 157 } 158 159 String fileName = name + ".properties"; 160 161 Properties props = new Properties (); 163 props.put("jonas.service.wsdl.class", Uddi.REGISTRYWSDLHANDLER_CLASS); 164 props.put("jonas.service.publish.uddi.username", username); 165 props.put("jonas.service.publish.uddi.password", password); 166 props.put("jonas.service.publish.uddi.organization.name", orgName); 167 props.put("jonas.service.publish.uddi.organization.desc", orgDesc); 168 props.put("jonas.service.publish.uddi.organization.person_name", orgPersonName); 169 props.put("javax.xml.registry.lifeCycleManagerURL", lifecyclemanagerURL); 170 props.put("javax.xml.registry.queryManagerURL", queryManagerURL); 171 java.io.File writeFile = new java.io.File (jonasBaseConfDir, fileName); 172 log(INFO + "Generating a WSDL publish UDDI with name '" + name + "' in file '" + writeFile + "'..."); 173 writePropsToFile(INFO, props, writeFile); 174 } 175 176 JReplace propertyReplace = new JReplace(); 178 propertyReplace.setProject(getProject()); 179 propertyReplace.setConfigurationFile(JOnASBaseTask.JONAS_CONF_FILE); 180 propertyReplace.setDestDir(new java.io.File (getDestDir().getPath())); 181 propertyReplace.setToken(TOKEN_WSDLHANDLER); 182 propertyReplace.setValue(WSDL_HANDLER_PROPERTY + SEPARATORS + fileNameList); 183 log(INFO + "Adding WSDL handlers '" + fileNameList + "' in " + JOnASBaseTask.JONAS_CONF_FILE + " file."); 184 propertyReplace.execute(); 185 186 } 187 } | Popular Tags |