private Stage getStage(ServletContext context) { final String stageAsString = context.getInitParameter("resteasy.guice.stage"); if (stageAsString == null) { return null; } try { return Stage.valueOf(stageAsString.trim()); } catch (IllegalArgumentException e) { throw new RuntimeException(Messages.MESSAGES.injectorStageNotProperlyDefined(stageAsString)); } }
private List<Module> getModules(final ServletContext context) { final List<Module> result = new ArrayList<Module>(); final String modulesString = context.getInitParameter("resteasy.guice.modules"); if (modulesString != null) { final String[] moduleStrings = modulesString.trim().split(","); for (final String moduleString : moduleStrings) { try { LogMessages.LOGGER.info(Messages.MESSAGES.foundModule(moduleString)); final Class clazz = Thread.currentThread().getContextClassLoader().loadClass(moduleString.trim()); final Module module = (Module) clazz.newInstance(); result.add(module); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InstantiationException e) { throw new RuntimeException(e); } } } return result; }