use of org.apache.cxf.jaxrs.model.FilterProviderInfo in project cxf by apache.
the class ServerProviderFactory method setProviders.
@SuppressWarnings("unchecked")
@Override
protected void setProviders(boolean custom, boolean busGlobal, Object... providers) {
List<Object> allProviders = new LinkedList<Object>();
for (Object p : providers) {
if (p instanceof Feature) {
FeatureContext featureContext = createServerFeatureContext();
Feature feature = (Feature) p;
injectApplicationIntoFeature(feature);
feature.configure(featureContext);
Configuration cfg = featureContext.getConfiguration();
for (Object featureProvider : cfg.getInstances()) {
Map<Class<?>, Integer> contracts = cfg.getContracts(featureProvider.getClass());
if (contracts != null && !contracts.isEmpty()) {
Class<?> providerCls = ClassHelper.getRealClass(getBus(), featureProvider);
allProviders.add(new FilterProviderInfo<Object>(featureProvider.getClass(), providerCls, featureProvider, getBus(), getFilterNameBindings(getBus(), featureProvider), false, contracts));
} else {
allProviders.add(featureProvider);
}
}
} else {
allProviders.add(p);
}
}
List<ProviderInfo<ContainerRequestFilter>> postMatchRequestFilters = new LinkedList<ProviderInfo<ContainerRequestFilter>>();
List<ProviderInfo<ContainerResponseFilter>> postMatchResponseFilters = new LinkedList<ProviderInfo<ContainerResponseFilter>>();
List<ProviderInfo<? extends Object>> theProviders = prepareProviders(custom, busGlobal, allProviders.toArray(), application);
super.setCommonProviders(theProviders);
for (ProviderInfo<? extends Object> provider : theProviders) {
Class<?> providerCls = ClassHelper.getRealClass(getBus(), provider.getProvider());
if (filterContractSupported(provider, providerCls, ContainerRequestFilter.class)) {
addContainerRequestFilter(postMatchRequestFilters, (ProviderInfo<ContainerRequestFilter>) provider);
}
if (filterContractSupported(provider, providerCls, ContainerResponseFilter.class)) {
postMatchResponseFilters.add((ProviderInfo<ContainerResponseFilter>) provider);
}
if (DynamicFeature.class.isAssignableFrom(providerCls)) {
// TODO: review the possibility of DynamicFeatures needing to have Contexts injected
Object feature = provider.getProvider();
dynamicFeatures.add((DynamicFeature) feature);
}
if (filterContractSupported(provider, providerCls, ExceptionMapper.class)) {
addProviderToList(exceptionMappers, provider);
}
}
Collections.sort(preMatchContainerRequestFilters, new BindingPriorityComparator(ContainerRequestFilter.class, true));
mapInterceptorFilters(postMatchContainerRequestFilters, postMatchRequestFilters, ContainerRequestFilter.class, true);
mapInterceptorFilters(containerResponseFilters, postMatchResponseFilters, ContainerResponseFilter.class, false);
injectContextProxies(exceptionMappers, postMatchContainerRequestFilters.values(), preMatchContainerRequestFilters, containerResponseFilters.values());
}
Aggregations