FileDocCategorySizeDatePackage
WsCompileInvokerImpl.javaAPI DocGlassfish v2 API6973Fri May 04 22:32:00 BST 2007com.sun.enterprise.deployment.util.webservice

WsCompileInvokerImpl

public class WsCompileInvokerImpl extends WsCompileInvoker
This is an implementation of the WsCompileInvoker

Fields Summary
private OutputStream
output
Constructors Summary
public WsCompileInvokerImpl(OutputStream out)

    
       
        output = out;
    
Methods Summary
public voidgenerateClientStubs(WSDLConfig config)
This is used to generate non-portable client stubs given information on WSDL file location, require package name

        File configFile = File.createTempFile("wscompileinvoker_stubsinfo",
                                                  "config");
        configFile.deleteOnExit();
        FileWriter writer = new FileWriter(configFile);
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
        writer.write("<configuration xmlns=\"http://java.sun.com/xml/ns/jax-rpc/ri/config\">\n");
        writer.write("<wsdl name=\"" + config.getWebServiceName() + "\" location=\"" + config.getWsdlLocation() + 
                            "\" packageName=\"" + config.getPackageName() +"\">\n");
        writer.write("<typeMappingRegistry />\n");
        writer.write("</wsdl>\n");
        writer.write("</configuration>\n");
        writer.close();
        invokeTool(configFile, "gen:client");
    
public voidgenerateSEI(WSDLConfig config)
This is used to generate SEI and mapping files given information on WSDL file location, require package name

        File configFile = File.createTempFile("wscompileinvoker_wsdlinfo",
                                                  "config");
        configFile.deleteOnExit();
        FileWriter writer = new FileWriter(configFile);
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
        writer.write("<configuration xmlns=\"http://java.sun.com/xml/ns/jax-rpc/ri/config\">\n");
        writer.write("<wsdl location=\"" + config.getWsdlLocation() + 
                            "\" packageName=\"" + config.getPackageName() +"\">\n");
        writer.write("<typeMappingRegistry />\n");
        writer.write("</wsdl>\n");
        writer.write("</configuration>\n");
        writer.close();
        invokeTool(configFile, "import");
    
public voidgenerateWSDL(SEIConfig config)
This is used to generate WSDL and mapping files given information on SEI config

        File configFile = File.createTempFile("wscompileinvoker_seiinfo",
                                                  "config");
        configFile.deleteOnExit();
        FileWriter writer = new FileWriter(configFile);
        writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n\n");
        writer.write("<configuration xmlns=\"http://java.sun.com/xml/ns/jax-rpc/ri/config\">\n");
        writer.write("<service name=\"" + config.getWebServiceName() + "\" ");
        writer.write("targetNamespace=\"urn:" + config.getNameSpace() + "\" ");
        writer.write("typeNamespace=\"urn:" + config.getNameSpace() + "\" ");
        writer.write("packageName=\"" + config.getPackageName() + "\">\n");
        writer.write("<interface name=\"" + config.getInterface() + "\" ");
        writer.write("servantName=\"" + config.getServant() + "\"/>\n");
        writer.write("<typeMappingRegistry />\n");
        writer.write("</service>\n");
        writer.write("</configuration>\n");
        writer.close();
        invokeTool(configFile, "define");
    
private voidinvokeTool(java.io.File configFile, java.lang.String operation)


        String key, value;
        int wsCompileOptionCount = 0;
        
        Object[] keySet = wsCompileOptions.keySet().toArray();
        
        for(int j=0; j<keySet.length; j++) {
            key = (String) keySet[j];
            value = (String) wsCompileOptions.get(keySet[j]);
            if(value == null)
                wsCompileOptionCount++;
            else
                wsCompileOptionCount+=2;
        }
                
        String[] wscompileArgs = new String[wsCompileOptionCount+3];
        int argsIndex = 0 ;

        for(int i=0; i<keySet.length; i++) {
            key = (String) keySet[i];
            value = (String) wsCompileOptions.get(keySet[i]);
            wscompileArgs[argsIndex++] = key;
            if(value != null)
                wscompileArgs[argsIndex++] = value;
        }
        wscompileArgs[argsIndex++] = "-" + operation;
        wscompileArgs[argsIndex++] = "-keep";        
        wscompileArgs[argsIndex++] = configFile.getPath();

        CompileTool tool = JaxRpcObjectFactory.newInstance().createCompileTool(output, "wscompile");
        if(!tool.run(wscompileArgs))
            throw new WsCompileInvokerException("wscompile invocation failed");