Search in sources :

Example 1 with GuiceInjectResourceFactory

use of com.linkedin.restli.server.guice.GuiceInjectResourceFactory in project incubator-gobblin by apache.

the class EmbeddedRestliServer method startUp.

@Override
protected void startUp() throws Exception {
    RestLiConfig config = new RestLiConfig();
    Set<String> resourceClassNames = Sets.newHashSet();
    for (Class<? extends BaseResource> resClass : this.resources) {
        resourceClassNames.add(resClass.getName());
    }
    config.addResourceClassNames(resourceClassNames);
    config.setServerNodeUri(this.serverUri);
    config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler());
    config.addFilter(new RestLiValidationFilter());
    ResourceFactory factory = new GuiceInjectResourceFactory(this.injector);
    TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory));
    String acceptedFilters = EncodingType.SNAPPY.getHttpName() + "," + EncodingType.GZIP.getHttpName();
    FilterChain filterChain = FilterChains.createRestChain(new ServerCompressionFilter(acceptedFilters));
    this.httpServer = Optional.of(new HttpNettyServerFactory(filterChain).createServer(this.port, dispatcher));
    this.log.info("Starting the {} embedded server at port {}.", this.name, this.port);
    this.httpServer.get().start();
}
Also used : RestLiValidationFilter(com.linkedin.restli.server.validation.RestLiValidationFilter) RestLiServer(com.linkedin.restli.server.RestLiServer) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) HttpNettyServerFactory(com.linkedin.r2.transport.http.server.HttpNettyServerFactory) ServerCompressionFilter(com.linkedin.r2.filter.compression.ServerCompressionFilter) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) FilterChain(com.linkedin.r2.filter.FilterChain) GuiceInjectResourceFactory(com.linkedin.restli.server.guice.GuiceInjectResourceFactory) ResourceFactory(com.linkedin.restli.server.resources.ResourceFactory) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) RestLiConfig(com.linkedin.restli.server.RestLiConfig) GuiceInjectResourceFactory(com.linkedin.restli.server.guice.GuiceInjectResourceFactory)

Aggregations

FilterChain (com.linkedin.r2.filter.FilterChain)1 ServerCompressionFilter (com.linkedin.r2.filter.compression.ServerCompressionFilter)1 TransportDispatcher (com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)1 HttpNettyServerFactory (com.linkedin.r2.transport.http.server.HttpNettyServerFactory)1 DefaultDocumentationRequestHandler (com.linkedin.restli.docgen.DefaultDocumentationRequestHandler)1 DelegatingTransportDispatcher (com.linkedin.restli.server.DelegatingTransportDispatcher)1 RestLiConfig (com.linkedin.restli.server.RestLiConfig)1 RestLiServer (com.linkedin.restli.server.RestLiServer)1 GuiceInjectResourceFactory (com.linkedin.restli.server.guice.GuiceInjectResourceFactory)1 ResourceFactory (com.linkedin.restli.server.resources.ResourceFactory)1 RestLiValidationFilter (com.linkedin.restli.server.validation.RestLiValidationFilter)1