use of com.sun.xml.rpc.spi.tools.CompileTool 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);
}
use of com.sun.xml.rpc.spi.tools.CompileTool 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;
}
}
Aggregations