Search in sources :

Example 1 with Service

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);
        }
    }
}
Also used : WebServiceEndpoint(com.sun.enterprise.deployment.WebServiceEndpoint) QName(javax.xml.namespace.QName) Port(com.sun.xml.rpc.spi.model.Port) Model(com.sun.xml.rpc.spi.model.Model) Iterator(java.util.Iterator) Collection(java.util.Collection) Service(com.sun.xml.rpc.spi.model.Service) WebService(com.sun.enterprise.deployment.WebService)

Example 2 with Service

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;
}
Also used : Service(com.sun.xml.rpc.spi.model.Service)

Example 3 with Service

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;
}
Also used : Service(com.sun.xml.rpc.spi.model.Service) Method(java.lang.reflect.Method) UserDataConstraint(com.sun.enterprise.deployment.web.UserDataConstraint) SecurityConstraint(com.sun.enterprise.deployment.web.SecurityConstraint)

Example 4 with Service

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);
}
Also used : QName(javax.xml.namespace.QName) Model(com.sun.xml.rpc.spi.model.Model) Iterator(java.util.Iterator) Service(com.sun.xml.rpc.spi.model.Service) WebService(com.sun.enterprise.deployment.WebService)

Aggregations

Service (com.sun.xml.rpc.spi.model.Service)4 WebService (com.sun.enterprise.deployment.WebService)2 Model (com.sun.xml.rpc.spi.model.Model)2 Iterator (java.util.Iterator)2 QName (javax.xml.namespace.QName)2 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 SecurityConstraint (com.sun.enterprise.deployment.web.SecurityConstraint)1 UserDataConstraint (com.sun.enterprise.deployment.web.UserDataConstraint)1 Port (com.sun.xml.rpc.spi.model.Port)1 Method (java.lang.reflect.Method)1 Collection (java.util.Collection)1