Ejemplo n.º 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;
  }
Ejemplo n.º 2
0
  @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;
  }
  @Override
  public Restlet createInboundRoot() {
    // Create a simple password verifier
    MapVerifier verifier = new MapVerifier();
    verifier.getLocalSecrets().put("scott", "tiger".toCharArray());

    // Create a Guard
    ChallengeAuthenticator authenticator =
        new ChallengeAuthenticator(getContext(), ChallengeScheme.HTTP_BASIC, "Tutorial");
    authenticator.setVerifier(verifier);

    // Create a Directory able to return a deep hierarchy of files
    Directory directory = new Directory(getContext(), ROOT_URI);
    directory.setListingAllowed(true);
    authenticator.setNext(directory);
    return authenticator;
  }
Ejemplo n.º 4
0
  public APIRouter(
      @Uses Context context,
      @Structure Module module,
      @Service AuthenticationFilterService filterService,
      @Service AvailabilityService availabilityService)
      throws Exception {
    super(context);
    this.factory = module.objectBuilderFactory();
    this.filterService = filterService;

    Restlet cqr =
        factory.newObjectBuilder(CommandQueryRestlet.class).use(getContext()).newInstance();

    Filter availabilityFilter =
        factory
            .newObjectBuilder(AvailabilityFilter.class)
            .use(getContext(), cqr, availabilityService)
            .newInstance();
    Filter authenticationFilter =
        factory
            .newObjectBuilder(AuthenticationFilter.class)
            .use(getContext(), availabilityFilter, this.filterService)
            .newInstance();
    Filter noCacheFilter = new NoCacheFilter(context, authenticationFilter);
    Filter performanceLoggingFilter = new PerformanceLoggingFilter(context, noCacheFilter);

    attachDefault(new ExtensionMediaTypeFilter(getContext(), performanceLoggingFilter));

    // Events
    attach(
        "/events/domain",
        new ExtensionMediaTypeFilter(
            getContext(), createServerResourceFinder(DomainEventsServerResource.class)),
        Template.MODE_STARTS_WITH);
    attach(
        "/events/application",
        new ExtensionMediaTypeFilter(
            getContext(), createServerResourceFinder(ApplicationEventsServerResource.class)),
        Template.MODE_STARTS_WITH);

    // Admin resources
    Router adminRouter = new Router(getContext());
    adminRouter.attach("/entity", createServerResourceFinder(EntitiesResource.class));
    adminRouter.attach("/entity/{identity}", createServerResourceFinder(EntityResource.class));
    adminRouter.attach(
        "/query",
        new PerformanceLoggingFilter(context, createServerResourceFinder(SPARQLResource.class)),
        Template.MODE_STARTS_WITH);
    adminRouter.attach("/index", createServerResourceFinder(IndexResource.class));
    adminRouter.attach("/console", createServerResourceFinder(ConsoleServerResource.class));
    adminRouter.attach("/search", createServerResourceFinder(SolrSearchServerResource.class));
    adminRouter.attach("/log", LoggingServerResource.class);
    attach("/admin/tools", new ExtensionMediaTypeFilter(getContext(), adminRouter));

    {
      Directory dir = new Directory(getContext(), "clap://thread/static/admin/");
      dir.setIndexName("index.html");
      attach("/admin/", dir);
    }

    {
      Directory dir = new Directory(getContext(), "clap://thread/static/crystal/");
      dir.setIndexName("index.html");
      attach("/statistics/", dir);
    }

    // Version info
    Directory directory = new Directory(getContext(), "clap://thread/static/");
    directory.setListingAllowed(true);
    attach(
        "/static",
        factory
            .newObjectBuilder(AuthenticationFilter.class)
            .use(getContext(), directory, this.filterService)
            .newInstance());
  }