Map<String, String> getJerseyFeatures(final JerseyConfig jerseyConfig) { final Map<String, String> jerseyFeatures = Maps.newHashMap(); jerseyFeatures.put(ResourceConfig.FEATURE_TRACE, Boolean.toString(jerseyConfig.isTraceEnabled())); jerseyFeatures.put(ResourceConfig.FEATURE_TRACE_PER_REQUEST, Boolean.toString(jerseyConfig.isTracePerRequestEnabled())); jerseyFeatures.put(ResourceConfig.FEATURE_DISABLE_WADL, Boolean.toString(!jerseyConfig.isGenerateWadlEnabled())); // Expose the @RequiresAuthentication annotation jerseyFeatures.put(ResourceConfig.PROPERTY_WADL_GENERATOR_CONFIG, NessWadlAnnotationsConfig.class.getName()); return jerseyFeatures; }
@Override protected void configureServlets() { final JerseyConfig jerseyConfig = config.getBean(JerseyConfig.class); bind(JerseyConfig.class).toInstance(jerseyConfig); install (new NessJerseyExceptionMapperModule()); bind(ResourceConfig.class).to(NessResourceConfig.class); NessJerseyBinder.bindResponseFilter(binder()).to(JsonUtf8ResponseFilter.class); if (jerseyConfig.isGzipEnabled()) { NessJerseyBinder.bindRequestFilter(binder()).to(GZIPContentEncodingFilter.class); NessJerseyBinder.bindResponseFilter(binder()).to(GZIPContentEncodingFilter.class); } if (jerseyConfig.isLoggingEnabled()) { NessJerseyBinder.bindRequestFilter(binder()).to(LoggingFilter.class); NessJerseyBinder.bindResponseFilter(binder()).to(LoggingFilter.class); } bind(GuiceContainer.class).to(NessGuiceContainer.class).in(Scopes.SINGLETON); String first = paths.get(0); String[] rest = paths.subList(1, paths.size()).toArray(new String[paths.size()-1]); serve(first, rest).with(GuiceContainer.class, getJerseyFeatures(jerseyConfig)); }