Search in sources :

Example 1 with ModelInfo

use of com.sun.xml.rpc.spi.tools.ModelInfo in project Payara by payara.

the class JaxRpcRICodegen method jaxrpcWebService.

private void jaxrpcWebService(WebService webService, ArrayList<String> files) throws Exception {
    if ((webService.getWsdlFileUrl() == null) || (webService.getMappingFileUri() == null)) {
        throw new Exception(localStrings.getLocalString("enterprise.webservice.jaxrpcFilesNotFound", "Service {0} seems to be a JAXRPC based web service but without " + "the mandatory WSDL and Mapping file. Deployment cannot proceed", new Object[] { webService.getName() }));
    }
    ModelInfo modelInfo = createModelInfo(webService);
    String[] args = createJaxrpcCompileArgs(true, false);
    CompileTool wscompile = rpcFactory.createCompileTool(System.out, "wscompile");
    wscompileForWebServices = wscompile;
    WsCompile delegate = new WsCompile(wscompile, webService);
    delegate.setModelInfo(modelInfo);
    wscompile.setDelegate(delegate);
    jaxrpc(args, delegate, webService, files);
}
Also used : CompileTool(com.sun.xml.rpc.spi.tools.CompileTool) ModelFileModelInfo(com.sun.xml.rpc.spi.tools.ModelFileModelInfo) ModelInfo(com.sun.xml.rpc.spi.tools.ModelInfo) J2EEModelInfo(com.sun.xml.rpc.spi.tools.J2EEModelInfo) NoMetadataModelInfo(com.sun.xml.rpc.spi.tools.NoMetadataModelInfo) IOException(java.io.IOException) WsCompile(org.glassfish.webservices.WsCompile)

Example 2 with ModelInfo

use of com.sun.xml.rpc.spi.tools.ModelInfo in project Payara by payara.

the class JaxRpcRICodegen method accept.

/**
 * Visits a webs service reference
 */
@Override
public void accept(ServiceReferenceDescriptor serviceRef) {
    if (!processServiceReferences) {
        return;
    }
    boolean codegenRequired = false;
    URL wsdlOverride = null;
    boolean wsdlOverriden = false;
    boolean jaxwsClient = false;
    super.accept(serviceRef);
    try {
        ClassLoader clr = serviceRef.getBundleDescriptor().getClassLoader();
        if (serviceRef.getServiceInterface() != null) {
            Class serviceInterface = clr.loadClass(serviceRef.getServiceInterface());
            if (javax.xml.ws.Service.class.isAssignableFrom(serviceInterface)) {
                jaxwsClient = true;
            }
        }
        // already set.
        for (Iterator ports = serviceRef.getPortsInfo().iterator(); ports.hasNext(); ) {
            ServiceRefPortInfo portInfo = (ServiceRefPortInfo) ports.next();
            if (portInfo.isLinkedToPortComponent()) {
                WebServiceEndpoint linkedPortComponent = portInfo.getPortComponentLink();
                if (linkedPortComponent == null) {
                    throw new Exception(localStrings.getLocalString("enterprise.webservice.componentlinkunresolved", "The port-component-link {0} cannot be resolved", new Object[] { portInfo.getPortComponentLinkName() }));
                }
                WsUtil wsUtil = new WsUtil();
                WebServerInfo wsi = wsUtil.getWebServerInfoForDAS();
                URL rootURL = wsi.getWebServerRootURL(linkedPortComponent.isSecure());
                URL actualAddress = linkedPortComponent.composeEndpointAddress(rootURL);
                if (jaxwsClient) {
                    portInfo.addStubProperty(javax.xml.ws.BindingProvider.ENDPOINT_ADDRESS_PROPERTY, actualAddress.toExternalForm());
                } else {
                    portInfo.addStubProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, actualAddress.toExternalForm());
                }
                if (serviceRef.getBundleDescriptor().getModuleType().equals(DOLUtils.carType())) {
                    wsdlOverride = serviceRef.getWsdlOverride();
                    if (wsdlOverride != null) {
                        wsdlOverriden = true;
                        serviceRef.setWsdlOverride(linkedPortComponent.getWebService().getWsdlFileUrl());
                    }
                }
            }
        }
        // If this is a post JAXRPC-1.1 based web service, then no need for code gen etc etc
        if (jaxwsClient) {
            return;
        }
        if (serviceRef.hasGeneratedServiceInterface()) {
            if (serviceRef.hasWsdlFile() && serviceRef.hasMappingFile()) {
                codegenRequired = true;
            } else {
                throw new Exception("Deployment error for service-ref " + serviceRef.getName() + ".\nService references with generated service " + "interface must include WSDL and mapping information.");
            }
        } else {
            if (serviceRef.hasWsdlFile()) {
                if (serviceRef.hasMappingFile()) {
                    codegenRequired = true;
                } else {
                    throw new Exception("Deployment error for service-ref " + serviceRef.getName() + ".\nService references with wsdl must also have " + "mapping information.");
                }
            }
        }
        if (codegenRequired) {
            ModelInfo modelInfo = createModelInfo(serviceRef);
            /*
                 * If clients exist, force regeneration so that the
                 * ClientArtifactsManager is populated. Issue 10612.
                 */
            String[] args = createJaxrpcCompileArgs(false, hasWebServiceClients);
            CompileTool wscompile = rpcFactory.createCompileTool(System.out, "wscompile");
            wscompileForAccept = wscompile;
            WsCompile delegate = new WsCompile(wscompile, serviceRef);
            delegate.setModelInfo(modelInfo);
            wscompile.setDelegate(delegate);
            jaxrpc(args, delegate, serviceRef, files);
            if (hasWebServiceClients) {
                addArtifactsForAppClient();
            }
        }
        if (wsdlOverriden) {
            serviceRef.setWsdlOverride(wsdlOverride);
        }
    } catch (IllegalStateException e) {
        // do nothing
        logger.info("Attempting to add artifacts for appClient after artifacts were generated" + " " + e.getMessage());
    } catch (Exception e) {
        RuntimeException re = new RuntimeException(e.getMessage());
        re.initCause(e);
        throw re;
    }
}
Also used : CompileTool(com.sun.xml.rpc.spi.tools.CompileTool) ModelFileModelInfo(com.sun.xml.rpc.spi.tools.ModelFileModelInfo) ModelInfo(com.sun.xml.rpc.spi.tools.ModelInfo) J2EEModelInfo(com.sun.xml.rpc.spi.tools.J2EEModelInfo) NoMetadataModelInfo(com.sun.xml.rpc.spi.tools.NoMetadataModelInfo) WebServerInfo(org.glassfish.web.deployment.util.WebServerInfo) WsUtil(org.glassfish.webservices.WsUtil) URL(java.net.URL) IOException(java.io.IOException) Iterator(java.util.Iterator) ASURLClassLoader(com.sun.enterprise.loader.ASURLClassLoader) WsCompile(org.glassfish.webservices.WsCompile)

Example 3 with ModelInfo

use of com.sun.xml.rpc.spi.tools.ModelInfo in project Payara by payara.

the class JaxRpcRICodegen method createModelInfo.

private ModelInfo createModelInfo(WebService webService) throws Exception {
    ModelInfo modelInfo = null;
    URL mappingFileUrl = webService.getMappingFile().toURL();
    modelInfo = createModelFileModelInfo(mappingFileUrl);
    if (isJaxrpcRIModelFile(mappingFileUrl)) {
        debug("000. JaxrpcRIModelFile.");
        modelInfo = createModelFileModelInfo(mappingFileUrl);
    } else {
        JaxrpcMappingDescriptor mappingDesc = getJaxrpcMappingInfo(mappingFileUrl, webService);
        if (mappingDesc.isSimpleMapping()) {
            debug("111. SimpleMapping.");
            modelInfo = createNoMetadataModelInfo(webService, mappingDesc);
        } else {
            debug("222. FullMapping .");
            modelInfo = createFullMappingModelInfo(webService);
        }
    }
    return modelInfo;
}
Also used : ModelFileModelInfo(com.sun.xml.rpc.spi.tools.ModelFileModelInfo) ModelInfo(com.sun.xml.rpc.spi.tools.ModelInfo) J2EEModelInfo(com.sun.xml.rpc.spi.tools.J2EEModelInfo) NoMetadataModelInfo(com.sun.xml.rpc.spi.tools.NoMetadataModelInfo) URL(java.net.URL)

Example 4 with ModelInfo

use of com.sun.xml.rpc.spi.tools.ModelInfo in project Payara by payara.

the class JaxRpcRICodegen method createModelInfo.

private ModelInfo createModelInfo(ServiceReferenceDescriptor serviceRef) throws Exception {
    ModelInfo modelInfo = null;
    URL mappingFileUrl = serviceRef.getMappingFile().toURL();
    if (isJaxrpcRIModelFile(mappingFileUrl)) {
        modelInfo = createModelFileModelInfo(mappingFileUrl);
    } else {
        JaxrpcMappingDescriptor mappingDesc = getJaxrpcMappingInfo(mappingFileUrl, serviceRef);
        if (mappingDesc.isSimpleMapping() && serviceRef.hasGeneratedServiceInterface()) {
            // model info for this modeler requires generated service
            // interface name.
            modelInfo = createNoMetadataModelInfo(serviceRef, mappingDesc);
        } else {
            modelInfo = createFullMappingModelInfo(serviceRef);
        }
    }
    return modelInfo;
}
Also used : ModelFileModelInfo(com.sun.xml.rpc.spi.tools.ModelFileModelInfo) ModelInfo(com.sun.xml.rpc.spi.tools.ModelInfo) J2EEModelInfo(com.sun.xml.rpc.spi.tools.J2EEModelInfo) NoMetadataModelInfo(com.sun.xml.rpc.spi.tools.NoMetadataModelInfo) URL(java.net.URL)

Aggregations

J2EEModelInfo (com.sun.xml.rpc.spi.tools.J2EEModelInfo)4 ModelFileModelInfo (com.sun.xml.rpc.spi.tools.ModelFileModelInfo)4 ModelInfo (com.sun.xml.rpc.spi.tools.ModelInfo)4 NoMetadataModelInfo (com.sun.xml.rpc.spi.tools.NoMetadataModelInfo)4 URL (java.net.URL)3 CompileTool (com.sun.xml.rpc.spi.tools.CompileTool)2 IOException (java.io.IOException)2 WsCompile (org.glassfish.webservices.WsCompile)2 ASURLClassLoader (com.sun.enterprise.loader.ASURLClassLoader)1 Iterator (java.util.Iterator)1 WebServerInfo (org.glassfish.web.deployment.util.WebServerInfo)1 WsUtil (org.glassfish.webservices.WsUtil)1