use of org.apache.openejb.core.webservices.AddressingSupport in project tomee by apache.
the class EjbWsContext method getAddressingSupport.
private AddressingSupport getAddressingSupport() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
if (wsaSupport == null) {
throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
}
return wsaSupport;
}
use of org.apache.openejb.core.webservices.AddressingSupport in project tomee by apache.
the class EjbWsContext method getAddressingSupport.
private AddressingSupport getAddressingSupport() {
final ThreadContext threadContext = ThreadContext.getThreadContext();
final AddressingSupport wsaSupport = threadContext.get(AddressingSupport.class);
if (wsaSupport == null) {
throw new IllegalStateException("Only calls on the service-endpoint can get the EndpointReference.");
}
return wsaSupport;
}
use of org.apache.openejb.core.webservices.AddressingSupport in project tomee by apache.
the class SingletonContainer method invokeWebService.
private Object invokeWebService(final Object[] args, final BeanContext beanContext, final Method runMethod, final Instance instance) throws Exception {
if (args.length < 2) {
throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
}
final Object messageContext = args[0];
if (messageContext == null) {
throw new IllegalArgumentException("MessageContext is null.");
}
// This object will be used as an interceptor in the stack and will be responsible
// for unmarshalling the soap message parts into an argument list that will be
// used for the actual method invocation.
//
// We just need to make it an interceptor in the OpenEJB sense and tack it on the end
// of our stack.
final Object interceptor = args[1];
if (interceptor == null) {
throw new IllegalArgumentException("Interceptor instance is null.");
}
final Class<?> interceptorClass = interceptor.getClass();
// Add the webservice interceptor to the list of interceptor instances
final Map<String, Object> interceptors = new HashMap<String, Object>(instance.interceptors);
{
interceptors.put(interceptorClass.getName(), interceptor);
}
// Create an InterceptorData for the webservice interceptor to the list of interceptorDatas for this method
final List<InterceptorData> interceptorDatas = new ArrayList<InterceptorData>();
{
final InterceptorData providerData = new InterceptorData(interceptorClass);
List<Method> aroundInvokes = interceptorCache.get(interceptorClass);
if (aroundInvokes == null) {
aroundInvokes = new ClassFinder(interceptorClass).findAnnotatedMethods(AroundInvoke.class);
if (SingletonContainer.class.getClassLoader() == interceptorClass.getClassLoader()) {
// use cache only for server classes
final List<Method> value = new CopyOnWriteArrayList<Method>(aroundInvokes);
// ensure it to be thread safe
aroundInvokes = interceptorCache.putIfAbsent(interceptorClass, value);
if (aroundInvokes == null) {
aroundInvokes = value;
}
}
}
providerData.getAroundInvoke().addAll(aroundInvokes);
interceptorDatas.add(0, providerData);
interceptorDatas.addAll(beanContext.getMethodInterceptors(runMethod));
}
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS_WS, interceptorDatas, interceptors);
final Object[] params = new Object[runMethod.getParameterTypes().length];
if (messageContext instanceof javax.xml.rpc.handler.MessageContext) {
ThreadContext.getThreadContext().set(javax.xml.rpc.handler.MessageContext.class, (javax.xml.rpc.handler.MessageContext) messageContext);
return interceptorStack.invoke((javax.xml.rpc.handler.MessageContext) messageContext, params);
} else if (messageContext instanceof javax.xml.ws.handler.MessageContext) {
AddressingSupport wsaSupport = NoAddressingSupport.INSTANCE;
for (int i = 2; i < args.length; i++) {
if (args[i] instanceof AddressingSupport) {
wsaSupport = (AddressingSupport) args[i];
}
}
ThreadContext.getThreadContext().set(AddressingSupport.class, wsaSupport);
ThreadContext.getThreadContext().set(javax.xml.ws.handler.MessageContext.class, (javax.xml.ws.handler.MessageContext) messageContext);
return interceptorStack.invoke((javax.xml.ws.handler.MessageContext) messageContext, params);
}
throw new IllegalArgumentException("Uknown MessageContext type: " + messageContext.getClass().getName());
}
use of org.apache.openejb.core.webservices.AddressingSupport in project tomee by apache.
the class StatelessContainer method invokeWebService.
private Object invokeWebService(final Object[] args, final BeanContext beanContext, final Method runMethod, final Instance instance) throws Exception {
if (args.length < 2) {
throw new IllegalArgumentException("WebService calls must follow format {messageContext, interceptor, [arg...]}.");
}
final Object messageContext = args[0];
// This object will be used as an interceptor in the stack and will be responsible
// for unmarshalling the soap message parts into an argument list that will be
// used for the actual method invocation.
//
// We just need to make it an interceptor in the OpenEJB sense and tack it on the end
// of our stack.
final Object interceptor = args[1];
final Class<?> interceptorClass = interceptor.getClass();
// Add the webservice interceptor to the list of interceptor instances
final Map<String, Object> interceptors = new HashMap<String, Object>(instance.interceptors);
interceptors.put(interceptor.getClass().getName(), interceptor);
// Create an InterceptorData for the webservice interceptor to the list of interceptorDatas for this method
final List<InterceptorData> interceptorDatas = new ArrayList<InterceptorData>();
final InterceptorData providerData = new InterceptorData(interceptorClass);
providerData.getAroundInvoke().addAll(retrieveAroundInvokes(interceptorClass));
interceptorDatas.add(0, providerData);
interceptorDatas.addAll(beanContext.getMethodInterceptors(runMethod));
final InterceptorStack interceptorStack = new InterceptorStack(instance.bean, runMethod, Operation.BUSINESS_WS, interceptorDatas, interceptors);
final Object[] params = new Object[runMethod.getParameterTypes().length];
final ThreadContext threadContext = ThreadContext.getThreadContext();
Object returnValue = null;
if (messageContext instanceof javax.xml.rpc.handler.MessageContext) {
threadContext.set(javax.xml.rpc.handler.MessageContext.class, (javax.xml.rpc.handler.MessageContext) messageContext);
returnValue = interceptorStack.invoke((javax.xml.rpc.handler.MessageContext) messageContext, params);
} else if (messageContext instanceof javax.xml.ws.handler.MessageContext) {
AddressingSupport wsaSupport = NoAddressingSupport.INSTANCE;
for (int i = 2; i < args.length; i++) {
if (args[i] instanceof AddressingSupport) {
wsaSupport = (AddressingSupport) args[i];
}
}
threadContext.set(AddressingSupport.class, wsaSupport);
threadContext.set(javax.xml.ws.handler.MessageContext.class, (javax.xml.ws.handler.MessageContext) messageContext);
returnValue = interceptorStack.invoke((javax.xml.ws.handler.MessageContext) messageContext, params);
}
return returnValue;
}
Aggregations