Search in sources :

Example 6 with ServiceRefPortInfo

use of com.sun.enterprise.deployment.ServiceRefPortInfo in project Payara by payara.

the class PortCreationCallbackImpl method postCreateProxy.

public void postCreateProxy(WSBindingProvider bp, Class<?> serviceEndpointInterface) {
    ServiceRefPortInfo portInfo = ref.getPortInfoBySEI(serviceEndpointInterface.getName());
    if (portInfo != null) {
        // Set MTOM for this port
        boolean mtomEnabled = false;
        if (portInfo.getMtomEnabled() != null && Boolean.valueOf(portInfo.getMtomEnabled())) {
            mtomEnabled = true;
        }
        if (mtomEnabled) {
            Binding bType = bp.getBinding();
            // enable mtom valid only for SOAPBindings
            if (SOAPBinding.class.isAssignableFrom(bType.getClass())) {
                ((SOAPBinding) bType).setMTOMEnabled(true);
            } else {
                logger.log(Level.SEVERE, LogUtils.INVALID_MTOM, portInfo.getName());
            }
        }
        // Set stub properties
        Set properties = portInfo.getStubProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext(); ) {
            NameValuePairDescriptor next = (NameValuePairDescriptor) iter.next();
            bp.getRequestContext().put(next.getName(), next.getValue());
        }
    }
}
Also used : Binding(javax.xml.ws.Binding) SOAPBinding(javax.xml.ws.soap.SOAPBinding) Set(java.util.Set) NameValuePairDescriptor(com.sun.enterprise.deployment.NameValuePairDescriptor) Iterator(java.util.Iterator) SOAPBinding(javax.xml.ws.soap.SOAPBinding) ServiceRefPortInfo(com.sun.enterprise.deployment.ServiceRefPortInfo)

Example 7 with ServiceRefPortInfo

use of com.sun.enterprise.deployment.ServiceRefPortInfo in project Payara by payara.

the class ServiceInvocationHandler method setStubProperties.

private void setStubProperties(Stub stub, int methodType, Method method, Object[] args) {
    // Port info lookup will be based on SEI or port.
    QName port = null;
    String serviceEndpointInterface = null;
    switch(methodType) {
        case GET_PORT_CONTAINER_MANAGED:
            serviceEndpointInterface = ((Class) args[0]).getName();
            break;
        case GET_PORT_CLIENT_MANAGED:
            port = (QName) args[0];
            serviceEndpointInterface = ((Class) args[1]).getName();
            break;
        case GENERATED_SERVICE_METHOD:
            // java.rmi.Remote get<Name_of_wsdl:port>()
            String portLocalPart = method.getName().startsWith("get") ? method.getName().substring(3) : null;
            if (portLocalPart != null) {
                QName serviceName = serviceRef.getServiceName();
                port = new QName(serviceName.getNamespaceURI(), portLocalPart);
            }
            serviceEndpointInterface = method.getReturnType().getName();
            break;
        default:
            return;
    }
    ServiceRefPortInfo portInfo = null;
    // If port is known, it takes precedence in lookup.
    if (port != null) {
        portInfo = serviceRef.getPortInfoByPort(port);
    }
    if (portInfo == null) {
        portInfo = serviceRef.getPortInfoBySEI(serviceEndpointInterface);
    }
    if (portInfo != null) {
        Set properties = portInfo.getStubProperties();
        for (Iterator iter = properties.iterator(); iter.hasNext(); ) {
            NameValuePairDescriptor next = (NameValuePairDescriptor) iter.next();
            stub._setProperty(next.getName(), next.getValue());
        }
        // precedence.
        if (portInfo.hasTargetEndpointAddress()) {
            if (!portInfo.hasStubProperty(Stub.ENDPOINT_ADDRESS_PROPERTY)) {
                stub._setProperty(Stub.ENDPOINT_ADDRESS_PROPERTY, portInfo.getTargetEndpointAddress());
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) NameValuePairDescriptor(com.sun.enterprise.deployment.NameValuePairDescriptor) QName(javax.xml.namespace.QName) Iterator(java.util.Iterator) ServiceRefPortInfo(com.sun.enterprise.deployment.ServiceRefPortInfo)

Example 8 with ServiceRefPortInfo

use of com.sun.enterprise.deployment.ServiceRefPortInfo in project Payara by payara.

the class ServiceInvocationHandler method getMessageSecurityHandlerInfo.

public HandlerInfo getMessageSecurityHandlerInfo(QName port) throws Exception {
    HandlerInfo rvalue = null;
    MessageSecurityBindingDescriptor binding = null;
    ServiceRefPortInfo portInfo = serviceRef.getPortInfoByPort(port);
    if (portInfo != null) {
        binding = portInfo.getMessageSecurityBinding();
    }
    if (secServ != null) {
        rvalue = secServ.getMessageSecurityHandler(binding, serviceRef.getServiceName());
    }
    return rvalue;
}
Also used : MessageSecurityBindingDescriptor(com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor) ServiceRefPortInfo(com.sun.enterprise.deployment.ServiceRefPortInfo) HandlerInfo(javax.xml.rpc.handler.HandlerInfo)

Example 9 with ServiceRefPortInfo

use of com.sun.enterprise.deployment.ServiceRefPortInfo in project Payara by payara.

the class ServiceInvocationHandler method invoke.

public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
    if (method.getDeclaringClass() == java.lang.Object.class) {
        return invokeJavaObjectMethod(this, method, args);
    }
    int methodType = getMethodType(method);
    checkUnsupportedMethods(methodType);
    Object returnValue = null;
    try {
        // Initialize method info for invocation based on arguments.
        // Some/All of this might be overridden below.
        Object serviceToInvoke = serviceDelegate;
        Method methodToInvoke = method;
        int methodTypeToInvoke = methodType;
        Object[] argsForInvoke = args;
        switch(methodType) {
            case GET_PORT_CONTAINER_MANAGED:
                Class serviceEndpointInterfaceClass = (Class) args[0];
                String serviceEndpointInterface = serviceEndpointInterfaceClass.getName();
                ServiceRefPortInfo portInfo = serviceRef.getPortInfo(serviceEndpointInterface);
                // If we have a port, use it to call getPort(QName, SEI) instead
                if ((portInfo != null) && portInfo.hasWsdlPort()) {
                    methodToInvoke = getClientManagedPortMethod;
                    methodTypeToInvoke = GET_PORT_CLIENT_MANAGED;
                    argsForInvoke = new Object[] { portInfo.getWsdlPort(), args[0] };
                } else {
                // This means the deployer did not resolve the port to
                // which this SEI is mapped.  Just call getPort(SEI)
                // method on delegate. This is not guaranteed to work.
                }
                break;
            case GET_WSDL_LOCATION:
                return wsdlLocation;
            case CREATE_CALL_PORT:
            case CREATE_CALL_OPERATION_QNAME:
            case CREATE_CALL_OPERATION_STRING:
            case GET_CALLS:
            case GET_PORTS:
                serviceToInvoke = getConfiguredServiceDelegate();
                break;
            default:
                break;
        }
        // End switch (methodType)
        returnValue = methodToInvoke.invoke(serviceToInvoke, argsForInvoke);
        if (returnValue instanceof Stub) {
            Stub stub = (Stub) returnValue;
            setStubProperties(stub, methodTypeToInvoke, methodToInvoke, argsForInvoke);
        } else if (returnValue instanceof Call) {
            Call[] calls = new Call[1];
            calls[0] = (Call) returnValue;
            setCallProperties(calls, methodTypeToInvoke, argsForInvoke);
        } else if (methodType == GET_CALLS) {
            Call[] calls = (Call[]) returnValue;
            setCallProperties(calls, methodTypeToInvoke, argsForInvoke);
        }
    } catch (InvocationTargetException ite) {
        throw ite.getCause();
    }
    return returnValue;
}
Also used : Call(javax.xml.rpc.Call) Stub(javax.xml.rpc.Stub) Method(java.lang.reflect.Method) ServiceRefPortInfo(com.sun.enterprise.deployment.ServiceRefPortInfo) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

ServiceRefPortInfo (com.sun.enterprise.deployment.ServiceRefPortInfo)9 Iterator (java.util.Iterator)4 Set (java.util.Set)4 QName (javax.xml.namespace.QName)4 HashSet (java.util.HashSet)3 NameValuePairDescriptor (com.sun.enterprise.deployment.NameValuePairDescriptor)2 MessageSecurityBindingDescriptor (com.sun.enterprise.deployment.runtime.common.MessageSecurityBindingDescriptor)2 InjectionTarget (com.sun.enterprise.deployment.InjectionTarget)1 WebServiceEndpoint (com.sun.enterprise.deployment.WebServiceEndpoint)1 DisplayableComponentNode (com.sun.enterprise.deployment.node.DisplayableComponentNode)1 InjectionTargetNode (com.sun.enterprise.deployment.node.InjectionTargetNode)1 JndiEnvRefNode (com.sun.enterprise.deployment.node.JndiEnvRefNode)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Method (java.lang.reflect.Method)1 Call (javax.xml.rpc.Call)1 Stub (javax.xml.rpc.Stub)1 HandlerInfo (javax.xml.rpc.handler.HandlerInfo)1 Binding (javax.xml.ws.Binding)1 SOAPBinding (javax.xml.ws.soap.SOAPBinding)1