*/
@SuppressWarnings("unchecked")
public static <A> A createContainer(Class<A> type, ResourceConfig resourceConfig,
IoCComponentProviderFactory factory)
throws ContainerException, IllegalArgumentException {
WebApplication wa = WebApplicationFactory.createWebApplication();
// Reverse the order so that applications may override
LinkedList<ContainerProvider> cps = new LinkedList<ContainerProvider>();
for (ContainerProvider cp : ServiceFinder.find(ContainerProvider.class, true))
cps.addFirst(cp);
for (ContainerProvider<A> cp : cps) {
A c = cp.createContainer(type, resourceConfig, wa);
if (c != null) {
// Initiate the web application
if (!wa.isInitiated()) {
wa.initiate(resourceConfig, factory);
}
// Register a container listener
Object o = resourceConfig.getProperties().get(
ResourceConfig.PROPERTY_CONTAINER_NOTIFIER);