use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project camel by apache.
the class DefaultCxfRsBinding method copyOperationResourceInfoStack.
protected void copyOperationResourceInfoStack(org.apache.cxf.message.Message cxfMessage, Message camelMessage) {
OperationResourceInfoStack stack = cxfMessage.get(OperationResourceInfoStack.class);
if (stack != null) {
// make a copy of the operation resource info for looking up the sub resource location
OperationResourceInfoStack copyStack = (OperationResourceInfoStack) stack.clone();
camelMessage.setHeader(CxfConstants.CAMEL_CXF_RS_OPERATION_RESOURCE_INFO_STACK, copyStack);
}
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project tomee by apache.
the class JAXRSUtils method pushOntoStack.
public static void pushOntoStack(OperationResourceInfo ori, MultivaluedMap<String, String> params, Message msg) {
OperationResourceInfoStack stack = msg.get(OperationResourceInfoStack.class);
if (stack == null) {
stack = new OperationResourceInfoStack();
msg.put(OperationResourceInfoStack.class, stack);
}
final List<String> values;
if (params.size() <= 1) {
values = Collections.emptyList();
} else {
values = new ArrayList<>(params.size() - 1);
addTemplateVarValues(values, params, ori.getClassResourceInfo().getURITemplate());
addTemplateVarValues(values, params, ori.getURITemplate());
}
Class<?> realClass = ori.getClassResourceInfo().getServiceClass();
stack.push(new MethodInvocationInfo(ori, realClass, values));
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project meecrowave by apache.
the class JAXRSFieldInjectionInterceptor method doInject.
private void doInject(final InvocationContext ic) throws Exception {
final Message current = JAXRSUtils.getCurrentMessage();
if (current != null) {
final OperationResourceInfoStack stack = OperationResourceInfoStack.class.cast(current.get(OperationResourceInfoStack.class.getName()));
if (stack != null && !stack.isEmpty()) {
final Object instance;
if (ConstructorInterceptorInvocationContext.class.isInstance(ic)) {
final ConstructorInterceptorInvocationContext constructorInterceptorInvocationContext = ConstructorInterceptorInvocationContext.class.cast(ic);
constructorInterceptorInvocationContext.directProceed();
instance = constructorInterceptorInvocationContext.getNewInstance();
} else {
instance = ic.getTarget();
}
Application application = null;
final Object appInfo = current.getExchange().getEndpoint().get(Application.class.getName());
if (ApplicationInfo.class.isInstance(appInfo)) {
application = ApplicationInfo.class.cast(appInfo).getProvider();
}
synchronized (this) {
if (injected.get()) {
return;
}
InjectionUtils.injectContextProxiesAndApplication(stack.lastElement().getMethodInfo().getClassResourceInfo(), instance, application, ProviderFactory.getInstance(current));
injected.compareAndSet(false, true);
}
}
}
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project cxf by apache.
the class UriInfoImplTest method testGetMatchedURIsSubResourceLocator.
@Test
public void testGetMatchedURIsSubResourceLocator() throws Exception {
System.out.println("testGetMatchedURIsSubResourceLocator");
Message m = mockMessage("http://localhost:8080/app", "/foo/sub");
OperationResourceInfoStack oriStack = new OperationResourceInfoStack();
ClassResourceInfo rootCri = getCri(RootResource.class, true);
OperationResourceInfo rootOri = getOri(rootCri, "getSubResourceLocator");
MethodInvocationInfo miInfo = new MethodInvocationInfo(rootOri, RootResource.class, new ArrayList<String>());
oriStack.push(miInfo);
ClassResourceInfo subCri = getCri(SubResource.class, false);
OperationResourceInfo subOri = getOri(subCri, "getFromSub");
miInfo = new MethodInvocationInfo(subOri, SubResource.class, new ArrayList<String>());
oriStack.push(miInfo);
m.put(OperationResourceInfoStack.class, oriStack);
UriInfoImpl u = new UriInfoImpl(m);
List<String> matchedUris = getMatchedURIs(u);
assertEquals(2, matchedUris.size());
assertEquals("foo/sub", matchedUris.get(0));
assertEquals("foo", matchedUris.get(1));
}
use of org.apache.cxf.jaxrs.model.OperationResourceInfoStack in project cxf by apache.
the class UriInfoImplTest method testGetMatchedURIsRootSub.
@Test
public void testGetMatchedURIsRootSub() throws Exception {
System.out.println("testGetMatchedURIsRootSub");
Message m = mockMessage("http://localhost:8080/app", "/foo/bar");
OperationResourceInfoStack oriStack = new OperationResourceInfoStack();
ClassResourceInfo cri = getCri(RootResource.class, true);
OperationResourceInfo ori = getOri(cri, "getSubMethod");
MethodInvocationInfo miInfo = new MethodInvocationInfo(ori, RootResource.class, new ArrayList<String>());
oriStack.push(miInfo);
m.put(OperationResourceInfoStack.class, oriStack);
UriInfoImpl u = new UriInfoImpl(m);
List<String> matchedUris = getMatchedURIs(u);
assertEquals(2, matchedUris.size());
assertEquals("foo/bar", matchedUris.get(0));
assertEquals("foo", matchedUris.get(1));
}
Aggregations