}
}
protected void createServerFromApplication(String cName) throws ServletException {
Class<?> appClass = loadClass(cName, "Application");
Application app = null;
try {
app = (Application)appClass.newInstance();
} catch (InstantiationException ex) {
ex.printStackTrace();
throw new ServletException("Application class " + cName
+ " can not be instantiated");
} catch (IllegalAccessException ex) {
ex.printStackTrace();
throw new ServletException("Application class " + cName
+ " can not be instantiated due to IllegalAccessException");
}
verifySingletons(app.getSingletons());
List<Class> resourceClasses = new ArrayList<Class>();
List<Object> providers = new ArrayList<Object>();
Map<Class, ResourceProvider> map = new HashMap<Class, ResourceProvider>();
// at the moment we don't support per-request providers, only resource classes
// Note, app.getClasse() returns a list of per-resource classes
for (Class<?> c : app.getClasses()) {
if (isValidPerRequestResourceClass(c, app.getSingletons())) {
resourceClasses.add(c);
map.put(c, new PerRequestResourceProvider(c));
}
}
// we can get either a provider or resource class here
for (Object o : app.getSingletons()) {
boolean isProvider = o.getClass().getAnnotation(Provider.class) != null;
if (isProvider) {
providers.add(o);
} else {
resourceClasses.add(o.getClass());