org.restlet.Application.setInboundRoot()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(91)

本文整理了Java中org.restlet.Application.setInboundRoot()方法的一些代码示例,展示了Application.setInboundRoot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Application.setInboundRoot()方法的具体详情如下:
包路径:org.restlet.Application
类名称:Application
方法名:setInboundRoot

Application.setInboundRoot介绍

[英]Sets the inbound root Resource class.
[中]设置入站根资源类。

代码示例

代码示例来源:origin: org.restlet.osgi/org.restlet

/**
 * Sets the inbound root Resource class.
 * 
 * @param inboundRootClass
 *            The inbound root Resource class.
 */
public synchronized void setInboundRoot(
    Class<? extends ServerResource> inboundRootClass) {
  setInboundRoot(createFinder(inboundRootClass));
}

代码示例来源:origin: org.restlet.osgi/org.restlet.ext.osgi

@Override
public Application createApplication(Context context) {
  application = doCreateApplication(context);
  if (routerProvider != null)
    application.setInboundRoot(routerProvider.getInboundRoot(context));
  return application;
}

代码示例来源:origin: org.restlet.osgi/org.restlet.ext.osgi

/**
 * Called by OSGi DS to inject the router provider service
 * 
 * @param routerProvider
 *            the router provider service
 */
public void bindRouterProvider(RouterProvider routerProvider) {
  this.routerProvider = routerProvider;
  if (application != null)
    application.setInboundRoot(routerProvider
        .getInboundRoot(application.getContext()));
}

代码示例来源:origin: org.restlet.jse/org.restlet.example

public static void main(String[] args) throws Exception {
  // Instantiating the Application providing the Range Service
  Application app = new Application();
  // Plug the server resource.
  app.setInboundRoot(HelloServerResource.class);
  // Instantiating the HTTP server and listening on port 8111
  new Server(Protocol.HTTP, 8111, app).start();
}

代码示例来源:origin: unchartedsoftware/aperture-tiles

/**
 * Creates the restlet application that will be used to handle all rest calls
 * Takes a map of paths to resource classes
 * <p/>
 * Use the following three lines to access the routing multibinder:
 * TypeLiteral<String> pathType = new TypeLiteral<String>() {};
 * TypeLiteral<Class<? extends ServerResource>> clazzType = new TypeLiteral<Class<? extends ServerResource>>() {};
 * MapBinder<String, Class<? extends ServerResource>> resourceBinder = MapBinder.newMapBinder(binder(), pathType, clazzType);
 * resourceBinder.bind("/my/path").toInstance(MyResource.class);
 */
@Provides
Application createApplication( FinderFactory factory, Map<String, Class<? extends ServerResource>> routes ) {
  Context context = new Context();
  Application application = new Application();
  application.setContext( context );
  Router router = new Router( context );
  // Set binding rules here
  for ( Entry<String, Class<? extends ServerResource>> entry : routes.entrySet() ) {
    final Class<? extends ServerResource> resource = entry.getValue();
    logger.info( "Binding '" + entry.getKey() + "' to " + resource );
    router.attach( entry.getKey(), factory.finder( resource ) );
  }
  application.setInboundRoot( router );
  return application;
}

相关文章