Search in sources :

Example 1 with PhotoDatabaseImpl

use of com.linkedin.restli.example.impl.PhotoDatabaseImpl in project rest.li by linkedin.

the class TestMockHttpServerFactory method getBeans.

/**
   * Returns beans that are needed by the resource classes
   *
   * @return
   */
private Map<String, Object> getBeans() {
    Map<String, Object> beans = new HashMap<String, Object>();
    final PhotoDatabase photoDb = new PhotoDatabaseImpl(10);
    beans.put("photoDb", photoDb);
    beans.put("albumDb", new AlbumDatabaseImpl(5));
    beans.put("albumEntryDb", new AlbumEntryDatabaseImpl(photoDb, 5));
    return beans;
}
Also used : PhotoDatabase(com.linkedin.restli.example.impl.PhotoDatabase) AlbumEntryDatabaseImpl(com.linkedin.restli.example.impl.AlbumEntryDatabaseImpl) HashMap(java.util.HashMap) AlbumDatabaseImpl(com.linkedin.restli.example.impl.AlbumDatabaseImpl) PhotoDatabaseImpl(com.linkedin.restli.example.impl.PhotoDatabaseImpl)

Example 2 with PhotoDatabaseImpl

use of com.linkedin.restli.example.impl.PhotoDatabaseImpl in project rest.li by linkedin.

the class RestLiExampleBasicServer method createServer.

public static HttpServer createServer() {
    // create Rest.li resource class information and initialize documentation generator
    // only the resource classes in the specified package names are visible for public
    final RestLiConfig config = new RestLiConfig();
    config.addResourcePackageNames("com.linkedin.restli.example.impl");
    config.setServerNodeUri(URI.create(getServerUrl()));
    config.setDocumentationRequestHandler(new DefaultDocumentationRequestHandler());
    // Create an instance of the Example Filter and add it to the config.
    RestLiExampleFilter filter = new RestLiExampleFilter();
    config.addFilter(filter);
    // demonstrate dynamic dependency injection
    final PhotoDatabase photoDb = new PhotoDatabaseImpl(10);
    final SimpleBeanProvider beanProvider = new SimpleBeanProvider();
    beanProvider.add("photoDb", photoDb);
    beanProvider.add("albumDb", new AlbumDatabaseImpl(10));
    beanProvider.add("albumEntryDb", new AlbumEntryDatabaseImpl(photoDb, 3));
    // using InjectMockResourceFactory to keep examples spring-free
    final ResourceFactory factory = new InjectMockResourceFactory(beanProvider);
    final TransportDispatcher dispatcher = new DelegatingTransportDispatcher(new RestLiServer(config, factory));
    return new HttpServerFactory(FilterChains.empty()).createServer(SERVER_PORT, dispatcher);
}
Also used : HttpServerFactory(com.linkedin.r2.transport.http.server.HttpServerFactory) RestLiServer(com.linkedin.restli.server.RestLiServer) SimpleBeanProvider(com.linkedin.restli.server.mock.SimpleBeanProvider) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) DefaultDocumentationRequestHandler(com.linkedin.restli.docgen.DefaultDocumentationRequestHandler) ResourceFactory(com.linkedin.restli.server.resources.ResourceFactory) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) DelegatingTransportDispatcher(com.linkedin.restli.server.DelegatingTransportDispatcher) TransportDispatcher(com.linkedin.r2.transport.common.bridge.server.TransportDispatcher) PhotoDatabase(com.linkedin.restli.example.impl.PhotoDatabase) AlbumEntryDatabaseImpl(com.linkedin.restli.example.impl.AlbumEntryDatabaseImpl) AlbumDatabaseImpl(com.linkedin.restli.example.impl.AlbumDatabaseImpl) PhotoDatabaseImpl(com.linkedin.restli.example.impl.PhotoDatabaseImpl) InjectMockResourceFactory(com.linkedin.restli.server.mock.InjectMockResourceFactory) RestLiConfig(com.linkedin.restli.server.RestLiConfig)

Aggregations

AlbumDatabaseImpl (com.linkedin.restli.example.impl.AlbumDatabaseImpl)2 AlbumEntryDatabaseImpl (com.linkedin.restli.example.impl.AlbumEntryDatabaseImpl)2 PhotoDatabase (com.linkedin.restli.example.impl.PhotoDatabase)2 PhotoDatabaseImpl (com.linkedin.restli.example.impl.PhotoDatabaseImpl)2 TransportDispatcher (com.linkedin.r2.transport.common.bridge.server.TransportDispatcher)1 HttpServerFactory (com.linkedin.r2.transport.http.server.HttpServerFactory)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 InjectMockResourceFactory (com.linkedin.restli.server.mock.InjectMockResourceFactory)1 SimpleBeanProvider (com.linkedin.restli.server.mock.SimpleBeanProvider)1 ResourceFactory (com.linkedin.restli.server.resources.ResourceFactory)1 HashMap (java.util.HashMap)1