/** * Returns a new instance of the DefaultRuntimeInjector. <br> * This does and should return a new instance of a RuntimeInjector, as it is only ever called once * per configured filter. This means that a web application can create multiple instances of the * JaspiRuntimeFilter and each instance will have its own self contained injector which uses that * instances filter configuration. * * @param config The instance of the FilterConfig. * @return A RuntimeInjector. * @throws ServletException If there is an error creating the RuntimeInjector. */ public static RuntimeInjector getRuntimeInjector(final FilterConfig config) throws ServletException { try { return new DefaultRuntimeInjector(config); } catch (AuthException e) { LOGGER.error("Failed to construct RuntimeInjector", e); throw new ServletException("Failed to construct RuntimeInjector", e); } }
/** * {@inheritDoc} <br> * Will only ever return the singleton instance (for this instance of the JaspiRuntimeFilter) and * if asked for an instance of a different type will throw a {@link RuntimeException}. * * @param type {@inheritDoc} * @param <T> {@inheritDoc} * @return {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public <T> T getInstance(final Class<T> type) { if (!JaspiRuntime.class.equals(type)) { LOGGER.error("Type not registered! " + type.getName()); throw new RuntimeException("Type not registered! " + type.getName()); } return (T) jaspiRuntime; }