コード例 #1
0
  /*
   * (non-Javadoc)
   *
   * @see org.restlet.Application#createInboundRoot()
   */
  @Override
  public Restlet createInboundRoot() {
    // Create a router Restlet that routes each call to a new instance of
    // HelloWorldResource.
    Router router = new Router(getContext());
    router.setDefaultMatchingQuery(false);

    router.attach("/symbol/2525B/{id}", SymbolResource2525B.class);
    router.attach("/symbol", SymbolServlet.class);

    router.attach("/query/2525B/{id}", SymbolQueryResource2525B.class);
    router.attach("/query/2525B/", SymbolQueryResource2525B.class);
    router.attach("/query/2525B", SymbolQueryResource2525B.class);
    router.attach("/graphics", TacticalGraphicsQueryResource2525B.class);
    try {
      Directory dir =
          new Directory(
              getContext(), new Reference(this.getClass().getResource("/static").toURI()));
      dir.setListingAllowed(true);
      dir.setDeeplyAccessible(true);
      router.attachDefault(dir);
    } catch (URISyntaxException e) {
      getLogger().log(Level.SEVERE, "Unable to create a directory browser resource", e);
    }
    return router;
  }
コード例 #2
0
ファイル: AppTodo.java プロジェクト: adrianojlt/helloRestlet
  @Override
  public Restlet createInboundRoot() {

    String resources = "clap://class/static/todo/";

    Directory directory = new Directory(getContext(), resources);
    directory.setListingAllowed(true);
    directory.setDeeplyAccessible(true);

    /*
    LocalReference localReference = LocalReference.createClapReference(LocalReference.CLAP_THREAD, "/src/com/pmonteiro/fasttrial/ui/");
       CompositeClassLoader compositeCL = new CompositeClassLoader();
       compositeCL.addClassLoader(Thread.currentThread().getContextClassLoader());
       compositeCL.addClassLoader(Router.class.getClassLoader());
       ClassLoaderDirectory dir = new ClassLoaderDirectory(getContext(),localReference,compositeCL);
       */

    Router todoRouter = new Router(this.getContext());

    todoRouter.attach("/web", directory);
    todoRouter.attach("/todos", TodosResource.class);
    todoRouter.attach("/todos/{todoId}", TodoResource.class);
    // todoRouter.attachDefault(TodosResource.class);

    return todoRouter;
  }