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());
}
}
}
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());
}
}
}
}
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;
}
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;
}
Aggregations