use of org.apache.cxf.jaxrs.impl.ResourceInfoImpl in project cxf by apache.
the class ServerProviderFactory method doApplyDynamicFeatures.
private void doApplyDynamicFeatures(ClassResourceInfo cri) {
Set<OperationResourceInfo> oris = cri.getMethodDispatcher().getOperationResourceInfos();
for (OperationResourceInfo ori : oris) {
String nameBinding = DEFAULT_FILTER_NAME_BINDING + ori.getClassResourceInfo().getServiceClass().getName() + "." + ori.getMethodToInvoke().toString();
for (DynamicFeature feature : dynamicFeatures) {
FeatureContext featureContext = createServerFeatureContext();
feature.configure(new ResourceInfoImpl(ori), featureContext);
Configuration cfg = featureContext.getConfiguration();
for (Object provider : cfg.getInstances()) {
Map<Class<?>, Integer> contracts = cfg.getContracts(provider.getClass());
if (contracts != null && !contracts.isEmpty()) {
Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider);
registerUserProvider(new FilterProviderInfo<Object>(provider.getClass(), providerCls, provider, getBus(), Collections.singleton(nameBinding), true, contracts));
ori.addNameBindings(Collections.singletonList(nameBinding));
}
}
}
}
Collection<ClassResourceInfo> subs = cri.getSubResources();
for (ClassResourceInfo sub : subs) {
if (sub != cri) {
doApplyDynamicFeatures(sub);
}
}
}
use of org.apache.cxf.jaxrs.impl.ResourceInfoImpl in project cxf by apache.
the class JAXRSUtils method createContextValue.
public static <T> T createContextValue(Message m, Type genericType, Class<T> clazz) {
Message contextMessage = getContextMessage(m);
Object o = null;
if (UriInfo.class.isAssignableFrom(clazz)) {
o = createUriInfo(contextMessage);
} else if (HttpHeaders.class.isAssignableFrom(clazz) || ProtocolHeaders.class.isAssignableFrom(clazz)) {
o = createHttpHeaders(contextMessage, clazz);
} else if (SecurityContext.class.isAssignableFrom(clazz)) {
SecurityContext customContext = contextMessage.get(SecurityContext.class);
o = customContext == null ? new SecurityContextImpl(contextMessage) : customContext;
} else if (MessageContext.class.isAssignableFrom(clazz)) {
o = new MessageContextImpl(m);
} else if (ResourceInfo.class.isAssignableFrom(clazz)) {
o = new ResourceInfoImpl(contextMessage);
} else if (ResourceContext.class.isAssignableFrom(clazz)) {
o = new ResourceContextImpl(contextMessage, contextMessage.getExchange().get(OperationResourceInfo.class));
} else if (Request.class.isAssignableFrom(clazz)) {
o = new RequestImpl(contextMessage);
} else if (Providers.class.isAssignableFrom(clazz)) {
o = new ProvidersImpl(contextMessage);
} else if (ContextResolver.class.isAssignableFrom(clazz)) {
o = createContextResolver(genericType, contextMessage);
} else if (Configuration.class.isAssignableFrom(clazz)) {
o = ProviderFactory.getInstance(contextMessage).getConfiguration(contextMessage);
} else if (Application.class.isAssignableFrom(clazz)) {
ProviderInfo<?> providerInfo = (ProviderInfo<?>) contextMessage.getExchange().getEndpoint().get(Application.class.getName());
o = providerInfo == null ? null : providerInfo.getProvider();
} else if (contextMessage != null) {
ContextProvider<?> provider = ProviderFactory.getInstance(contextMessage).createContextProvider(clazz, contextMessage);
if (provider != null) {
o = provider.createContext(contextMessage);
}
}
if (o == null && contextMessage != null && !MessageUtils.isRequestor(contextMessage)) {
o = HttpUtils.createServletResourceValue(contextMessage, clazz);
}
return clazz.cast(o);
}
Aggregations