org.restlet.resource.Directory Java Examples

The following examples show how to use org.restlet.resource.Directory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdminApplication.java    From scava with Eclipse Public License 2.0 7 votes vote down vote up
@Override
public Restlet createInboundRoot() {
	Router router = new Router(getContext());
	Directory directory =  new Directory(getContext(), ROOT_URI);

	router.attach("/", AdminIndex.class);
	router.attach("/status/{what}", Status.class);
	router.attach("/projects/{view}", Projects.class);
	
	router.attach("/performance/projects", ProjectListAnalysis.class);
	router.attach("/performance/metrics", MetricListAnalysis.class);
	router.attach("/performance/projects/{projectId}/m/{metricId}", ProjectMetricAnalysis.class);
	router.attach("/performance/metrics/{metricId}", FullMetricAnalysis.class);
	//router.attach("/logger", LoggingInformation.class);
	router.attach("/home", directory); 
	return router;
}
 
Example #2
Source File: StaticWebRoutable.java    From floodlight_with_topoguard with Apache License 2.0 5 votes vote down vote up
@Override
public Restlet getRestlet(Context context) {
       Router router = new Router(context);
       router.attach("", new Directory(context, "clap://classloader/web/"));
       context.setClientDispatcher(new Client(context, Protocol.CLAP));
       return router;
}
 
Example #3
Source File: StuffApplication.java    From spring-5-examples with MIT License 4 votes vote down vote up
@Override
public synchronized void start() throws Exception {
  Router router = new Router(getContext());


  Properties props = new Properties();
  props.load(getClass().getResourceAsStream("/velocity.properties"));

  VelocityEngine velocity = new VelocityEngine(props);

  Function<String, Function<Identifier, ? extends Entity>> entityFactory =
      type -> identifier ->
      {
        switch (type) {
          case "task":
            return new Task(identifier);

          case "project":
            return new Project(identifier);
        }

        throw new IllegalArgumentException(type);
      };

  eventStore = new InMemoryEventStore();
  Repository repository = new InMemoryRepository(eventStore, eventStore, entityFactory);

  graphDb = new GraphDatabaseFactory().newEmbeddedDatabase("graphdb");

  InboxModel inboxModel = new Neo4jInboxModel(graphDb);
  eventStore.addInteractionContextSink(inboxModel);

  ObjectMapper mapper = new ObjectMapper();
  mapper.registerModule(new SimpleModule("EventSourcing", new Version(1, 0, 0, null, "eventsourcing", "eventsourcing")).
      addSerializer(InteractionContext.class, new InteractionContextSerializer()).
      addDeserializer(InteractionContext.class, new InteractionContextDeserializer()).setMixInAnnotation(Event.class, JacksonEvent.class)
  );

  File file = new File("events.log").getAbsoluteFile();
  LoggerFactory.getLogger(getClass()).info("Event log:" + file);
  storage = new FileEventStorage(mapper);

  if (file.exists())
    storage.load(file, eventStore);

  storage.save(file, eventStore);

  eventStore.addInteractionContextSink(new LoggingModel(mapper));

  InboxResource inboxResource = new InboxResource(velocity, repository,
      new TaskResource(velocity, repository, inboxModel), inboxModel);
  router.attach("inbox/{task}/{command}", inboxResource);
  router.attach("inbox/{task}/", inboxResource);
  router.attach("inbox/{command}", inboxResource);
  router.attach("inbox/", inboxResource);

  Reference staticContent = new Reference(new File(getClass().getResource("/htdocs/index.html").getFile()).getParentFile().toURI());
  router.attachDefault(new Directory(getContext(), staticContent)).setMatchingMode(Template.MODE_STARTS_WITH);

  setInboundRoot(router);

  super.start();
}