use of com.sun.xml.rpc.spi.model.Service in project Payara by payara.
the class WsCompile method doServicePostProcessing.
private void doServicePostProcessing() {
Model model = wscompile.getProcessor().getModel();
Collection endpoints = webService.getEndpoints();
for (Iterator iter = endpoints.iterator(); iter.hasNext(); ) {
WebServiceEndpoint next = (WebServiceEndpoint) iter.next();
Service service = wsUtil.getServiceForPort(model, next.getWsdlPort());
if (service == null) {
service = (Service) model.getServices().next();
System.out.println("Warning : Can't find Service for Endpoint '" + next.getEndpointName() + "' Port '" + next.getWsdlPort() + "'");
System.out.println("Defaulting to " + service.getName());
}
QName serviceName = service.getName();
next.setServiceNamespaceUri(serviceName.getNamespaceURI());
next.setServiceLocalPart(serviceName.getLocalPart());
Port port = wsUtil.getPortFromModel(model, next.getWsdlPort());
if (port == null) {
String msg = "Can't find model port for endpoint " + next.getEndpointName() + " with wsdl-port " + next.getWsdlPort();
throw new IllegalStateException(msg);
}
// If port has a tie class name property, use it. Otherwise,
// use naming convention to derive tie class name. If there
// are multiple ports per SEI(binding), then the property then
// the TIE_CLASS_NAME property will be available. In that case,
// a separate tie and stub are generated per port.
String tieClassName = (String) port.getProperty(ModelProperties.PROPERTY_TIE_CLASS_NAME);
if (tieClassName == null) {
tieClassName = next.getServiceEndpointInterface() + "_Tie";
}
next.setTieClassName(tieClassName);
if (next.implementedByWebComponent()) {
wsUtil.updateServletEndpointRuntime(next);
} else {
wsUtil.validateEjbEndpoint(next);
}
String endpointAddressUri = next.getEndpointAddressUri();
if (endpointAddressUri == null) {
String msg = "Endpoint address uri must be set for endpoint " + next.getEndpointName();
throw new IllegalStateException(msg);
} else if (endpointAddressUri.indexOf('*') >= 0) {
String msg = "Endpoint address uri " + endpointAddressUri + " for endpoint " + next.getEndpointName() + " is invalid. It must not contain the '*' character";
throw new IllegalStateException(msg);
} else if (endpointAddressUri.endsWith("/")) {
String msg = "Endpoint address uri " + endpointAddressUri + " for endpoint " + next.getEndpointName() + " is invalid. It must not end with '/'";
throw new IllegalStateException(msg);
}
}
}
use of com.sun.xml.rpc.spi.model.Service in project Payara by payara.
the class WsUtil method getAllPorts.
// Return collection of Port objects
public Collection getAllPorts(Model model) {
Collection ports = new HashSet();
for (Iterator serviceIter = model.getServices(); serviceIter.hasNext(); ) {
Service next = (Service) serviceIter.next();
ports.addAll(next.getPortsList());
}
return ports;
}
use of com.sun.xml.rpc.spi.model.Service in project Payara by payara.
the class WsUtil method getSEIsFromGeneratedService.
/**
* @return Set of service endpoint interface class names supported by
* a generated service interface.
*
* @return Collection of String class names
*/
public Collection getSEIsFromGeneratedService(Class generatedServiceInterface) throws Exception {
Collection seis = new HashSet();
Method[] declaredMethods = generatedServiceInterface.getDeclaredMethods();
// Use naming convention from jaxrpc spec to derive SEI class name.
for (int i = 0; i < declaredMethods.length; i++) {
Method next = declaredMethods[i];
Class returnType = next.getReturnType();
if (next.getName().startsWith("get") && (next.getDeclaringClass() != javax.xml.rpc.Service.class) && java.rmi.Remote.class.isAssignableFrom(returnType)) {
seis.add(returnType.getName());
}
}
return seis;
}
use of com.sun.xml.rpc.spi.model.Service in project Payara by payara.
the class WsCompile method doClientPostProcessing.
private void doClientPostProcessing() {
Model model = wscompile.getProcessor().getModel();
Iterator serviceIter = model.getServices();
Service service = null;
if (serviceRef.hasServiceName()) {
while (serviceIter.hasNext()) {
Service next = (Service) serviceIter.next();
if (next.getName().equals(serviceRef.getServiceName())) {
service = next;
break;
}
}
if (service == null) {
throw new IllegalStateException("Service " + serviceRef.getServiceName() + " for service-ref " + serviceRef.getName() + " not found");
}
} else {
if (serviceIter.hasNext()) {
service = (Service) serviceIter.next();
if (serviceIter.hasNext()) {
throw new IllegalStateException("service ref " + serviceRef.getName() + " must specify" + " service name since its wsdl declares multiple" + " services");
}
QName sName = service.getName();
serviceRef.setServiceNamespaceUri(sName.getNamespaceURI());
serviceRef.setServiceLocalPart(sName.getLocalPart());
} else {
throw new IllegalStateException("service ref " + serviceRef.getName() + " WSDL must " + "define at least one Service");
}
}
// Use naming convention to derive Generated Service
// implementation class name.
String serviceImpl = service.getJavaIntf().getName() + "_Impl";
serviceRef.setServiceImplClassName(serviceImpl);
}
Aggregations