use of org.platformlayer.extensions.HttpConfiguration in project platformlayer by platformlayer.
the class UserAuthServletModule method configureServlets.
@Override
protected void configureServlets() {
extensions.addHttpExtensions(new HttpConfiguration() {
@Override
public FilterKeyBindingBuilder filter(String urlPattern) {
return UserAuthServletModule.this.filter(urlPattern);
}
@Override
public ServletKeyBindingBuilder serve(String urlPattern) {
return UserAuthServletModule.this.serve(urlPattern);
}
@Override
public <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz) {
return UserAuthServletModule.this.bind(clazz);
}
});
bind(CORSFilter.class).asEagerSingleton();
filter("/api/*").through(CORSFilter.class);
bind(RegisterResource.class);
bind(PingResource.class);
serve("/api/tokens").with(RestLoginServlet.class);
Map<String, String> params = Maps.newHashMap();
params.put(PackagesResourceConfig.PROPERTY_PACKAGES, "org.codehaus.jackson.jaxrs;com.fathomdb.jersey");
serve("/*").with(GuiceContainer.class, params);
}
use of org.platformlayer.extensions.HttpConfiguration in project platformlayer by platformlayer.
the class PlatformLayerServletModule method configureServlets.
@Override
protected void configureServlets() {
// switch (ApplicationMode.getMode()) {
// case DEVELOPMENT:
// bind(OpenstackAuthenticationFilterBase.class).to(DevelopmentOpenstackAuthenticationFilter.class).in(Scopes.SINGLETON);
// break;
//
// default:
// throw new IllegalStateException("Unhandled application mode: " + ApplicationMode.getMode());
// }
bind(MetricDataSourceWriter.class);
bind(CORSFilter.class).asEagerSingleton();
filter("/*").through(CORSFilter.class);
bind(ScopeFilter.class).asEagerSingleton();
filter("/*").through(ScopeFilter.class);
extensions.addHttpExtensions(new HttpConfiguration() {
@Override
public FilterKeyBindingBuilder filter(String urlPattern) {
return PlatformLayerServletModule.this.filter(urlPattern);
}
@Override
public ServletKeyBindingBuilder serve(String urlPattern) {
return PlatformLayerServletModule.this.serve(urlPattern);
}
@Override
public <T> AnnotatedBindingBuilder<T> bind(Class<T> clazz) {
return PlatformLayerServletModule.this.bind(clazz);
}
});
bind(ProjectAuthorization.class).toProvider(ScopeProjectAuthorizationProvider.class);
bind(Scope.class).toProvider(ScopeProvider.class);
// if (ApplicationMode.isDevelopment()) {
// bind(AuthenticationTokenValidator.class).to(DevelopmentTokenValidator.class);
// } else {
// bind(AuthenticationTokenValidator.class).to(PlatformLayerTokenValidator.class);
// }
bind(OpsAuthenticationFilter.class).asEagerSingleton();
// /* bind the REST resources */
// bind(ManagedItemCollectionResource.class);
// bind(ManagedItemResource.class);
bind(RootResource.class);
// bind(ServiceAuthorizationCollectionResource.class);
// bind(ServiceAuthorizationResource.class);
// bind(ServiceResource.class);
// bind(ServicesCollectionResource.class);
filter("/v0/*").through(OpsAuthenticationFilter.class);
Map<String, String> params = Maps.newHashMap();
List<String> packages = Lists.newArrayList();
packages.add("org.platformlayer.xaas.web.jaxrs");
packages.add("org.platformlayer.xaas.web.resources");
// packages.add("org.codehaus.jackson.jaxrs");
TypeFactory typeFactory = TypeFactory.defaultInstance();
ObjectMapper objectMapper = JsonHelper.buildObjectMapper(typeFactory, false);
// TypeResolverBuilder<?> typer = new PlatformLayerTypeResolverBuilder();
// TypeIdResolver typeIdResolver = new PlatformLayerTypeIdResolver(null, typeFactory);
// this.requestInjection(typeIdResolver);
// typer = typer.init(JsonTypeInfo.Id.CLASS, typeIdResolver);
// typer = typer.inclusion(JsonTypeInfo.As.PROPERTY);
// typer = typer.typeProperty("type");
// objectMapper.setDefaultTyping(typer);
bind(ObjectMapper.class).toInstance(objectMapper);
bind(ObjectMapperProvider.class).in(Scopes.SINGLETON);
bind(PlatformLayerJsonProvider.class).in(Scopes.SINGLETON);
params.put(PackagesResourceConfig.PROPERTY_PACKAGES, Joiner.on(';').join(packages));
serve("/v0/*").with(GuiceContainer.class, params);
// ImmutableMap.of(JSONConfiguration.FEATURE_POJO_MAPPING, "true"));
}
Aggregations