@Test public void testGenerateStoreServiceCompositeJustService() { SwitchyardJavaGenerator gen=new SwitchyardJavaGenerator(); try { java.net.URL url=ClassLoader.getSystemClassLoader().getResource(STORE_WSDL_LOCATION); gen.createServiceComposite(new Role("Store"), new java.util.Vector<Role>(), url.getFile(), new java.util.Vector<String>(), SRC_PATH, SRC_PATH); compare("expected/Store.switchyard.xml", SRC_PATH+"/switchyard.xml"); } catch(Exception e) { e.printStackTrace(); fail("Failed to generate Store switchyard descriptor: "+e); } }
public void createServiceComposite(Role role, java.util.List<Role> refRoles, String wsdlPath, java.util.List<String> refWsdlPaths, String resourceFolder, String srcFolder) throws Exception { javax.wsdl.Definition defn=getWSDLReader().readWSDL(wsdlPath); if (defn != null) { java.io.File wsdlFile=new java.io.File(wsdlPath); if (!wsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(wsdlPath); wsdlFile = new java.io.File(url.getFile()); if (!wsdlFile.exists()) { logger.severe("Failed to find WSDL file '"+wsdlPath+"'"); } } ResourceLocator locator=new DefaultResourceLocator(wsdlFile.getParentFile()); StringBuffer composite=new StringBuffer(); StringBuffer transformers=new StringBuffer(); StringBuffer component=new StringBuffer(); String targetNamespace=defn.getTargetNamespace(); String name=role.getName(); composite.append("<switchyard xmlns=\"urn:switchyard-config:switchyard:1.0\"\r\n"); composite.append("\t\ttargetNamespace=\""+targetNamespace+"\"\r\n"); composite.append("\t\tname=\""+name+"\">\r\n"); composite.append("\t<composite xmlns=\"http: composite.append("\t\t\ttargetNamespace=\""); composite.append(targetNamespace); composite.append("\"\r\n\t\t\tname=\""); composite.append(name); composite.append("\" >\r\n"); @SuppressWarnings("unchecked") java.util.Iterator<PortType> portTypes=defn.getPortTypes().values().iterator(); while (portTypes.hasNext()) { PortType portType=portTypes.next(); addPortTypeTransformers(portType, true, transformers, defn, locator, srcFolder); String wsdlName=wsdlPath; int ind=wsdlName.lastIndexOf('/'); String wsdlLocation=wsdlName; if (ind != -1) { wsdlLocation = wsdlName.substring(ind+1); wsdlName = wsdlName.substring(ind+1) +"#wsdl.porttype("+portType.getQName().getLocalPart()+")"; } composite.append("\t\t<service name=\""+portType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +portType.getQName().getLocalPart()+"\">\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +wsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</service>\r\n"); String pack=JavaGeneratorUtil.getJavaPackage(defn.getTargetNamespace()); component.append("\t\t<component name=\""+portType.getQName().getLocalPart()+"Component\">\r\n"); component.append("\t\t\t<implementation.bean xmlns=\"urn:switchyard-component-bean:config:1.0\" " + "class=\""+pack+"."+portType.getQName().getLocalPart()+"Impl\"/>\r\n"); component.append("\t\t\t<service name=\""+portType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+pack+"." +portType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</service>\r\n"); for (int i=0; i < refWsdlPaths.size(); i++){ String refWsdlPath=refWsdlPaths.get(i); javax.wsdl.Definition refDefn=getWSDLReader().readWSDL(refWsdlPath); java.io.File refWsdlFile=new java.io.File(refWsdlPath); if (!refWsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(refWsdlPath); refWsdlFile = new java.io.File(url.getFile()); if (!refWsdlFile.exists()) { logger.severe("Failed to find ref WSDL file '"+refWsdlPath+"'"); } } ResourceLocator refLocator=new DefaultResourceLocator(refWsdlFile.getParentFile()); if (refDefn != null) { @SuppressWarnings("unchecked") java.util.Iterator<PortType> refPortTypes=refDefn.getPortTypes().values().iterator(); while (refPortTypes.hasNext()) { PortType refPortType=refPortTypes.next(); addPortTypeTransformers(refPortType, false, transformers, refDefn, refLocator, srcFolder); String refWsdlName=refWsdlPath; wsdlLocation=refWsdlName; ind = refWsdlName.lastIndexOf('/'); if (ind != -1) { wsdlLocation = refWsdlName.substring(ind+1); refWsdlName = refWsdlName.substring(ind+1) +"#wsdl.porttype("+refPortType.getQName().getLocalPart()+")"; } composite.append("\t\t<reference name=\""+refPortType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +refPortType.getQName().getLocalPart()+"\" multiplicity=\"1..1\" >\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +refWsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</reference>\r\n"); String refPack=JavaGeneratorUtil.getJavaPackage(refDefn.getTargetNamespace()); component.append("\t\t\t<reference name=\""+refPortType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+refPack+"." +refPortType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</reference>\r\n"); } } } component.append("\t\t</component>\r\n"); composite.append(component.toString()); } composite.append("\t</composite>\r\n"); if (transformers.length() > 0) { composite.append("\t<transforms xmlns:xform=\"urn:switchyard-config:transform:1.0\">\r\n"); composite.append(transformers.toString()); composite.append("\t</transforms>\r\n"); } composite.append("</switchyard>\r\n"); java.io.FileOutputStream fos=new java.io.FileOutputStream(resourceFolder+ java.io.File.separatorChar+"switchyard.xml"); fos.write(composite.toString().getBytes()); fos.close(); } }
SwitchyardJavaGenerator extends org.savara.java.generator.JavaServiceGenerator { public void createServiceComposite(Role role, java.util.List<Role> refRoles, String wsdlPath, java.util.List<String> refWsdlPaths, String resourceFolder, String srcFolder) throws Exception { javax.wsdl.Definition defn=getWSDLReader().readWSDL(wsdlPath); if (defn != null) { java.io.File wsdlFile=new java.io.File(wsdlPath); if (!wsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(wsdlPath); wsdlFile = new java.io.File(url.getFile()); if (!wsdlFile.exists()) { logger.severe("Failed to find WSDL file '"+wsdlPath+"'"); } } ResourceLocator locator=new DefaultResourceLocator(wsdlFile.getParentFile()); StringBuffer composite=new StringBuffer(); StringBuffer transformers=new StringBuffer(); StringBuffer component=new StringBuffer(); String targetNamespace=defn.getTargetNamespace(); String name=role.getName(); composite.append("<switchyard xmlns=\"urn:switchyard-config:switchyard:1.0\"\r\n"); composite.append("\t\ttargetNamespace=\""+targetNamespace+"\"\r\n"); composite.append("\t\tname=\""+name+"\">\r\n"); composite.append("\t<composite xmlns=\"http: composite.append("\t\t\ttargetNamespace=\""); composite.append(targetNamespace); composite.append("\"\r\n\t\t\tname=\""); composite.append(name); composite.append("\" >\r\n"); @SuppressWarnings("unchecked") java.util.Iterator<PortType> portTypes=defn.getPortTypes().values().iterator(); while (portTypes.hasNext()) { PortType portType=portTypes.next(); addPortTypeTransformers(portType, true, transformers, defn, locator, srcFolder); String wsdlName=wsdlPath; int ind=wsdlName.lastIndexOf('/'); String wsdlLocation=wsdlName; if (ind != -1) { wsdlLocation = wsdlName.substring(ind+1); wsdlName = wsdlName.substring(ind+1) +"#wsdl.porttype("+portType.getQName().getLocalPart()+")"; } composite.append("\t\t<service name=\""+portType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +portType.getQName().getLocalPart()+"\">\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +wsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</service>\r\n"); String pack=JavaGeneratorUtil.getJavaPackage(defn.getTargetNamespace()); component.append("\t\t<component name=\""+portType.getQName().getLocalPart()+"Component\">\r\n"); component.append("\t\t\t<implementation.bean xmlns=\"urn:switchyard-component-bean:config:1.0\" " + "class=\""+pack+"."+portType.getQName().getLocalPart()+"Impl\"/>\r\n"); component.append("\t\t\t<service name=\""+portType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+pack+"." +portType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</service>\r\n"); for (int i=0; i < refWsdlPaths.size(); i++){ String refWsdlPath=refWsdlPaths.get(i); javax.wsdl.Definition refDefn=getWSDLReader().readWSDL(refWsdlPath); java.io.File refWsdlFile=new java.io.File(refWsdlPath); if (!refWsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(refWsdlPath); refWsdlFile = new java.io.File(url.getFile()); if (!refWsdlFile.exists()) { logger.severe("Failed to find ref WSDL file '"+refWsdlPath+"'"); } } ResourceLocator refLocator=new DefaultResourceLocator(refWsdlFile.getParentFile()); if (refDefn != null) { @SuppressWarnings("unchecked") java.util.Iterator<PortType> refPortTypes=refDefn.getPortTypes().values().iterator(); while (refPortTypes.hasNext()) { PortType refPortType=refPortTypes.next(); addPortTypeTransformers(refPortType, false, transformers, refDefn, refLocator, srcFolder); String refWsdlName=refWsdlPath; wsdlLocation=refWsdlName; ind = refWsdlName.lastIndexOf('/'); if (ind != -1) { wsdlLocation = refWsdlName.substring(ind+1); refWsdlName = refWsdlName.substring(ind+1) +"#wsdl.porttype("+refPortType.getQName().getLocalPart()+")"; } composite.append("\t\t<reference name=\""+refPortType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +refPortType.getQName().getLocalPart()+"\" multiplicity=\"1..1\" >\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +refWsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</reference>\r\n"); String refPack=JavaGeneratorUtil.getJavaPackage(refDefn.getTargetNamespace()); component.append("\t\t\t<reference name=\""+refPortType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+refPack+"." +refPortType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</reference>\r\n"); } } } component.append("\t\t</component>\r\n"); composite.append(component.toString()); } composite.append("\t</composite>\r\n"); if (transformers.length() > 0) { composite.append("\t<transforms xmlns:xform=\"urn:switchyard-config:transform:1.0\">\r\n"); composite.append(transformers.toString()); composite.append("\t</transforms>\r\n"); } composite.append("</switchyard>\r\n"); java.io.FileOutputStream fos=new java.io.FileOutputStream(resourceFolder+ java.io.File.separatorChar+"switchyard.xml"); fos.write(composite.toString().getBytes()); fos.close(); } } }
SwitchyardJavaGenerator extends org.savara.java.generator.JavaServiceGenerator { public void createServiceComposite(Role role, java.util.List<Role> refRoles, String wsdlPath, java.util.List<String> refWsdlPaths, String resourceFolder, String srcFolder) throws Exception { javax.wsdl.Definition defn=getWSDLReader().readWSDL(wsdlPath); if (defn != null) { java.io.File wsdlFile=new java.io.File(wsdlPath); if (!wsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(wsdlPath); wsdlFile = new java.io.File(url.getFile()); if (!wsdlFile.exists()) { logger.severe("Failed to find WSDL file '"+wsdlPath+"'"); } } ResourceLocator locator=new DefaultResourceLocator(wsdlFile.getParentFile()); StringBuffer composite=new StringBuffer(); StringBuffer transformers=new StringBuffer(); StringBuffer component=new StringBuffer(); String targetNamespace=defn.getTargetNamespace(); String name=role.getName(); composite.append("<switchyard xmlns=\"urn:switchyard-config:switchyard:1.0\"\r\n"); composite.append("\t\ttargetNamespace=\""+targetNamespace+"\"\r\n"); composite.append("\t\tname=\""+name+"\">\r\n"); composite.append("\t<composite xmlns=\"http: composite.append("\t\t\ttargetNamespace=\""); composite.append(targetNamespace); composite.append("\"\r\n\t\t\tname=\""); composite.append(name); composite.append("\" >\r\n"); @SuppressWarnings("unchecked") java.util.Iterator<PortType> portTypes=defn.getPortTypes().values().iterator(); while (portTypes.hasNext()) { PortType portType=portTypes.next(); addPortTypeTransformers(portType, true, transformers, defn, locator, srcFolder); String wsdlName=wsdlPath; int ind=wsdlName.lastIndexOf('/'); String wsdlLocation=wsdlName; if (ind != -1) { wsdlLocation = wsdlName.substring(ind+1); wsdlName = wsdlName.substring(ind+1) +"#wsdl.porttype("+portType.getQName().getLocalPart()+")"; } composite.append("\t\t<service name=\""+portType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +portType.getQName().getLocalPart()+"\">\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +wsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</service>\r\n"); String pack=JavaGeneratorUtil.getJavaPackage(defn.getTargetNamespace()); component.append("\t\t<component name=\""+portType.getQName().getLocalPart()+"Component\">\r\n"); component.append("\t\t\t<implementation.bean xmlns=\"urn:switchyard-component-bean:config:1.0\" " + "class=\""+pack+"."+portType.getQName().getLocalPart()+"Impl\"/>\r\n"); component.append("\t\t\t<service name=\""+portType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+pack+"." +portType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</service>\r\n"); for (int i=0; i < refWsdlPaths.size(); i++){ String refWsdlPath=refWsdlPaths.get(i); javax.wsdl.Definition refDefn=getWSDLReader().readWSDL(refWsdlPath); java.io.File refWsdlFile=new java.io.File(refWsdlPath); if (!refWsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(refWsdlPath); refWsdlFile = new java.io.File(url.getFile()); if (!refWsdlFile.exists()) { logger.severe("Failed to find ref WSDL file '"+refWsdlPath+"'"); } } ResourceLocator refLocator=new DefaultResourceLocator(refWsdlFile.getParentFile()); if (refDefn != null) { @SuppressWarnings("unchecked") java.util.Iterator<PortType> refPortTypes=refDefn.getPortTypes().values().iterator(); while (refPortTypes.hasNext()) { PortType refPortType=refPortTypes.next(); addPortTypeTransformers(refPortType, false, transformers, refDefn, refLocator, srcFolder); String refWsdlName=refWsdlPath; wsdlLocation=refWsdlName; ind = refWsdlName.lastIndexOf('/'); if (ind != -1) { wsdlLocation = refWsdlName.substring(ind+1); refWsdlName = refWsdlName.substring(ind+1) +"#wsdl.porttype("+refPortType.getQName().getLocalPart()+")"; } composite.append("\t\t<reference name=\""+refPortType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +refPortType.getQName().getLocalPart()+"\" multiplicity=\"1..1\" >\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +refWsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</reference>\r\n"); String refPack=JavaGeneratorUtil.getJavaPackage(refDefn.getTargetNamespace()); component.append("\t\t\t<reference name=\""+refPortType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+refPack+"." +refPortType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</reference>\r\n"); } } } component.append("\t\t</component>\r\n"); composite.append(component.toString()); } composite.append("\t</composite>\r\n"); if (transformers.length() > 0) { composite.append("\t<transforms xmlns:xform=\"urn:switchyard-config:transform:1.0\">\r\n"); composite.append(transformers.toString()); composite.append("\t</transforms>\r\n"); } composite.append("</switchyard>\r\n"); java.io.FileOutputStream fos=new java.io.FileOutputStream(resourceFolder+ java.io.File.separatorChar+"switchyard.xml"); fos.write(composite.toString().getBytes()); fos.close(); } } SwitchyardJavaGenerator(); }
SwitchyardJavaGenerator extends org.savara.java.generator.JavaServiceGenerator { public void createServiceComposite(Role role, java.util.List<Role> refRoles, String wsdlPath, java.util.List<String> refWsdlPaths, String resourceFolder, String srcFolder) throws Exception { javax.wsdl.Definition defn=getWSDLReader().readWSDL(wsdlPath); if (defn != null) { java.io.File wsdlFile=new java.io.File(wsdlPath); if (!wsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(wsdlPath); wsdlFile = new java.io.File(url.getFile()); if (!wsdlFile.exists()) { logger.severe("Failed to find WSDL file '"+wsdlPath+"'"); } } ResourceLocator locator=new DefaultResourceLocator(wsdlFile.getParentFile()); StringBuffer composite=new StringBuffer(); StringBuffer transformers=new StringBuffer(); StringBuffer component=new StringBuffer(); String targetNamespace=defn.getTargetNamespace(); String name=role.getName(); composite.append("<switchyard xmlns=\"urn:switchyard-config:switchyard:1.0\"\r\n"); composite.append("\t\ttargetNamespace=\""+targetNamespace+"\"\r\n"); composite.append("\t\tname=\""+name+"\">\r\n"); composite.append("\t<composite xmlns=\"http: composite.append("\t\t\ttargetNamespace=\""); composite.append(targetNamespace); composite.append("\"\r\n\t\t\tname=\""); composite.append(name); composite.append("\" >\r\n"); @SuppressWarnings("unchecked") java.util.Iterator<PortType> portTypes=defn.getPortTypes().values().iterator(); while (portTypes.hasNext()) { PortType portType=portTypes.next(); addPortTypeTransformers(portType, true, transformers, defn, locator, srcFolder); String wsdlName=wsdlPath; int ind=wsdlName.lastIndexOf('/'); String wsdlLocation=wsdlName; if (ind != -1) { wsdlLocation = wsdlName.substring(ind+1); wsdlName = wsdlName.substring(ind+1) +"#wsdl.porttype("+portType.getQName().getLocalPart()+")"; } composite.append("\t\t<service name=\""+portType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +portType.getQName().getLocalPart()+"\">\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +wsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</service>\r\n"); String pack=JavaGeneratorUtil.getJavaPackage(defn.getTargetNamespace()); component.append("\t\t<component name=\""+portType.getQName().getLocalPart()+"Component\">\r\n"); component.append("\t\t\t<implementation.bean xmlns=\"urn:switchyard-component-bean:config:1.0\" " + "class=\""+pack+"."+portType.getQName().getLocalPart()+"Impl\"/>\r\n"); component.append("\t\t\t<service name=\""+portType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+pack+"." +portType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</service>\r\n"); for (int i=0; i < refWsdlPaths.size(); i++){ String refWsdlPath=refWsdlPaths.get(i); javax.wsdl.Definition refDefn=getWSDLReader().readWSDL(refWsdlPath); java.io.File refWsdlFile=new java.io.File(refWsdlPath); if (!refWsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(refWsdlPath); refWsdlFile = new java.io.File(url.getFile()); if (!refWsdlFile.exists()) { logger.severe("Failed to find ref WSDL file '"+refWsdlPath+"'"); } } ResourceLocator refLocator=new DefaultResourceLocator(refWsdlFile.getParentFile()); if (refDefn != null) { @SuppressWarnings("unchecked") java.util.Iterator<PortType> refPortTypes=refDefn.getPortTypes().values().iterator(); while (refPortTypes.hasNext()) { PortType refPortType=refPortTypes.next(); addPortTypeTransformers(refPortType, false, transformers, refDefn, refLocator, srcFolder); String refWsdlName=refWsdlPath; wsdlLocation=refWsdlName; ind = refWsdlName.lastIndexOf('/'); if (ind != -1) { wsdlLocation = refWsdlName.substring(ind+1); refWsdlName = refWsdlName.substring(ind+1) +"#wsdl.porttype("+refPortType.getQName().getLocalPart()+")"; } composite.append("\t\t<reference name=\""+refPortType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +refPortType.getQName().getLocalPart()+"\" multiplicity=\"1..1\" >\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +refWsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</reference>\r\n"); String refPack=JavaGeneratorUtil.getJavaPackage(refDefn.getTargetNamespace()); component.append("\t\t\t<reference name=\""+refPortType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+refPack+"." +refPortType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</reference>\r\n"); } } } component.append("\t\t</component>\r\n"); composite.append(component.toString()); } composite.append("\t</composite>\r\n"); if (transformers.length() > 0) { composite.append("\t<transforms xmlns:xform=\"urn:switchyard-config:transform:1.0\">\r\n"); composite.append(transformers.toString()); composite.append("\t</transforms>\r\n"); } composite.append("</switchyard>\r\n"); java.io.FileOutputStream fos=new java.io.FileOutputStream(resourceFolder+ java.io.File.separatorChar+"switchyard.xml"); fos.write(composite.toString().getBytes()); fos.close(); } } SwitchyardJavaGenerator(); static void main(String[] args); @Override void createServiceInterfaceFromWSDL(String wsdlPath, String wsdlLocation, String srcFolder); @Override void createServiceImplementationFromWSDL(Role role, java.util.List<Role> refRoles,
							ProtocolModel behaviour, String wsdlPath, String wsdlLocation,
						java.util.List<String> refWsdlPaths, String srcFolder,
						ResourceLocator locator); void createServiceComposite(Role role, java.util.List<Role> refRoles,
				String wsdlPath, java.util.List<String> refWsdlPaths,
				String resourceFolder, String srcFolder); }
SwitchyardJavaGenerator extends org.savara.java.generator.JavaServiceGenerator { public void createServiceComposite(Role role, java.util.List<Role> refRoles, String wsdlPath, java.util.List<String> refWsdlPaths, String resourceFolder, String srcFolder) throws Exception { javax.wsdl.Definition defn=getWSDLReader().readWSDL(wsdlPath); if (defn != null) { java.io.File wsdlFile=new java.io.File(wsdlPath); if (!wsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(wsdlPath); wsdlFile = new java.io.File(url.getFile()); if (!wsdlFile.exists()) { logger.severe("Failed to find WSDL file '"+wsdlPath+"'"); } } ResourceLocator locator=new DefaultResourceLocator(wsdlFile.getParentFile()); StringBuffer composite=new StringBuffer(); StringBuffer transformers=new StringBuffer(); StringBuffer component=new StringBuffer(); String targetNamespace=defn.getTargetNamespace(); String name=role.getName(); composite.append("<switchyard xmlns=\"urn:switchyard-config:switchyard:1.0\"\r\n"); composite.append("\t\ttargetNamespace=\""+targetNamespace+"\"\r\n"); composite.append("\t\tname=\""+name+"\">\r\n"); composite.append("\t<composite xmlns=\"http: composite.append("\t\t\ttargetNamespace=\""); composite.append(targetNamespace); composite.append("\"\r\n\t\t\tname=\""); composite.append(name); composite.append("\" >\r\n"); @SuppressWarnings("unchecked") java.util.Iterator<PortType> portTypes=defn.getPortTypes().values().iterator(); while (portTypes.hasNext()) { PortType portType=portTypes.next(); addPortTypeTransformers(portType, true, transformers, defn, locator, srcFolder); String wsdlName=wsdlPath; int ind=wsdlName.lastIndexOf('/'); String wsdlLocation=wsdlName; if (ind != -1) { wsdlLocation = wsdlName.substring(ind+1); wsdlName = wsdlName.substring(ind+1) +"#wsdl.porttype("+portType.getQName().getLocalPart()+")"; } composite.append("\t\t<service name=\""+portType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +portType.getQName().getLocalPart()+"\">\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +wsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</service>\r\n"); String pack=JavaGeneratorUtil.getJavaPackage(defn.getTargetNamespace()); component.append("\t\t<component name=\""+portType.getQName().getLocalPart()+"Component\">\r\n"); component.append("\t\t\t<implementation.bean xmlns=\"urn:switchyard-component-bean:config:1.0\" " + "class=\""+pack+"."+portType.getQName().getLocalPart()+"Impl\"/>\r\n"); component.append("\t\t\t<service name=\""+portType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+pack+"." +portType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</service>\r\n"); for (int i=0; i < refWsdlPaths.size(); i++){ String refWsdlPath=refWsdlPaths.get(i); javax.wsdl.Definition refDefn=getWSDLReader().readWSDL(refWsdlPath); java.io.File refWsdlFile=new java.io.File(refWsdlPath); if (!refWsdlFile.exists()) { java.net.URL url=ClassLoader.getSystemResource(refWsdlPath); refWsdlFile = new java.io.File(url.getFile()); if (!refWsdlFile.exists()) { logger.severe("Failed to find ref WSDL file '"+refWsdlPath+"'"); } } ResourceLocator refLocator=new DefaultResourceLocator(refWsdlFile.getParentFile()); if (refDefn != null) { @SuppressWarnings("unchecked") java.util.Iterator<PortType> refPortTypes=refDefn.getPortTypes().values().iterator(); while (refPortTypes.hasNext()) { PortType refPortType=refPortTypes.next(); addPortTypeTransformers(refPortType, false, transformers, refDefn, refLocator, srcFolder); String refWsdlName=refWsdlPath; wsdlLocation=refWsdlName; ind = refWsdlName.lastIndexOf('/'); if (ind != -1) { wsdlLocation = refWsdlName.substring(ind+1); refWsdlName = refWsdlName.substring(ind+1) +"#wsdl.porttype("+refPortType.getQName().getLocalPart()+")"; } composite.append("\t\t<reference name=\""+refPortType.getQName().getLocalPart()+ "\" promote=\""+portType.getQName().getLocalPart()+"Component/" +refPortType.getQName().getLocalPart()+"\" multiplicity=\"1..1\" >\r\n"); composite.append("\t\t\t<interface.wsdl interface=\"wsdl/" +refWsdlName+"\" />\r\n"); composite.append("\t\t\t<binding.soap xmlns=\"urn:switchyard-component-soap:config:1.0\">\r\n"); composite.append("\t\t\t\t<wsdl>wsdl/"+wsdlLocation+"</wsdl>\r\n"); composite.append("\t\t\t\t<socketAddr>:18001</socketAddr>\r\n"); composite.append("\t\t\t</binding.soap>\r\n"); composite.append("\t\t</reference>\r\n"); String refPack=JavaGeneratorUtil.getJavaPackage(refDefn.getTargetNamespace()); component.append("\t\t\t<reference name=\""+refPortType.getQName().getLocalPart()+"\" >\r\n"); component.append("\t\t\t\t<interface.java interface=\""+refPack+"." +refPortType.getQName().getLocalPart()+"\"/>\r\n"); component.append("\t\t\t</reference>\r\n"); } } } component.append("\t\t</component>\r\n"); composite.append(component.toString()); } composite.append("\t</composite>\r\n"); if (transformers.length() > 0) { composite.append("\t<transforms xmlns:xform=\"urn:switchyard-config:transform:1.0\">\r\n"); composite.append(transformers.toString()); composite.append("\t</transforms>\r\n"); } composite.append("</switchyard>\r\n"); java.io.FileOutputStream fos=new java.io.FileOutputStream(resourceFolder+ java.io.File.separatorChar+"switchyard.xml"); fos.write(composite.toString().getBytes()); fos.close(); } } SwitchyardJavaGenerator(); static void main(String[] args); @Override void createServiceInterfaceFromWSDL(String wsdlPath, String wsdlLocation, String srcFolder); @Override void createServiceImplementationFromWSDL(Role role, java.util.List<Role> refRoles,
							ProtocolModel behaviour, String wsdlPath, String wsdlLocation,
						java.util.List<String> refWsdlPaths, String srcFolder,
						ResourceLocator locator); void createServiceComposite(Role role, java.util.List<Role> refRoles,
				String wsdlPath, java.util.List<String> refWsdlPaths,
				String resourceFolder, String srcFolder);  }