@SuppressWarnings("unchecked") Collection<DocumentFilterChain> chains =
beanFactory.getBeansOfType(DocumentFilterChain.class).values();
if (chains == null || chains.size() == 0) {
// No chains defined, so I'll make one. But the order of the filters
// should be considered random.
return new DocumentFilterChain(Lists.newArrayList(filters));
} else if (chains.size() == 1) {
// If there is just one, return it.
return chains.iterator().next();
} else {
// More than one filter chain is defined??? I will allow it, but...
return new DocumentFilterChain(Lists.newArrayList(chains));
}
}