Esempio n. 1
0
 public static void main(String[] args) throws Exception {
   Component component = new Component();
   component.getServers().add(Protocol.HTTP, 8182);
   component.getDefaultHost().attach("/text", TextResource.class);
   component.getDefaultHost().attach("/json", JsonResource.class);
   component.start();
 }
 /**
  * Launches the application with an HTTP server.
  *
  * @param args The arguments.
  * @throws Exception
  */
 public static void main(String[] args) throws Exception {
   Component mailServer = new Component();
   mailServer.getClients().add(Protocol.CLAP);
   mailServer.getServers().add(Protocol.HTTP, 8111);
   mailServer.getDefaultHost().attach(new MailServerApplication());
   mailServer.start();
 }
Esempio n. 3
0
  /**
   * @param args
   * @throws Exception Something bad happened.
   */
  public static void main(String[] args) throws Exception {

    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);
    //    component.getClients().add(Protocol.FILE);
    component.getClients().add(Protocol.CLAP);

    // Create an application
    Application application =
        new Application() {
          @Override
          public Restlet createInboundRoot() {
            Router router = new Router(getContext());
            // Directory directory = new Directory(getContext(), ROOT_URI);
            ////        String path = "file://" + System.getProperty("user.dir") +
            // "/src/main/resources/spa";
            ////        System.out.println("path: " + path);
            //        Directory directory = new Directory(getContext(), path);
            Directory directory =
                new Directory(
                    getContext(),
                    LocalReference.createClapReference(LocalReference.CLAP_CLASS, "/spa"));
            directory.setIndexName("index.html");
            //        directory.setDeeplyAccessible(true);
            router.attach("/spa/", directory);
            // Directory directory = new Directory(getContext(), "clap://application/spa/");

            return router;
          }
        };

    // Attach the application to the component and start it
    component.getDefaultHost().attach("/wattdepot", application);
    component.start();
  }
Esempio n. 4
0
 public void start() {
   try {
     _component.start();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   component = new Component();
   component.getServers().add(Protocol.HTTP, TEST_PORT);
   component.getDefaultHost().attach(new TestDigestApplication());
   component.start();
 }
Esempio n. 6
0
 @Override
 public void startServer() throws Exception {
   component = new Component();
   component.getServers().add(Protocol.HTTP, 8182);
   RestApplication application = module.newObject(RestApplication.class, component.getContext());
   component.getDefaultHost().attach(application);
   component.start();
 }
  public static void main(String[] args) throws Exception {
    Engine.getInstance().getRegisteredConverters().add(new JacksonConverter());
    Engine.getInstance().getRegisteredConverters().add(new HtmlConverter());
    Component c = new Component();
    c.getServers().add(Protocol.HTTP, 9003);

    c.getDefaultHost().attach("/v1", new FormServerApplication());
    c.start();
  }
Esempio n. 8
0
 public static void main(String[] args) throws Exception {
   Component component = new Component();
   Server server = new Server(Protocol.HTTP, 8312);
   component.getServers().add(server);
   server.getContext().getParameters().set("maxTotalConnections", Defaults.MAX_CONNECTIONS);
   server.getContext().getParameters().set("maxThreads", Defaults.MAX_THREADS);
   component.getDefaultHost().attach(new SubscriberTest());
   component.start();
 }
 private void initializeRestServer() throws Exception {
   log.info("*** initializeRestServer ***");
   component = new Component();
   // Add a new HTTP server listening on port 8182.
   component.getServers().add(Protocol.HTTP, REST_PORT);
   // component.getDefaultHost().attach(new
   // ActivitiRestServicesApplication());
   component.getDefaultHost().attach(new EsDmsActivitiRestServicesApplication());
   component.start();
 }
Esempio n. 10
0
  public void start(BundleContext context) throws Exception {
    // Create a component
    component = new Component();
    component.getServers().add(Protocol.HTTP, 8088);

    // Create an application
    final Application application = new Test12();

    // Attach the application to the component and start it
    component.getDefaultHost().attachDefault(application);
    component.start();
  }
  /**
   * Run the example as a standalone component.
   *
   * @param args The optional arguments.
   * @throws Exception
   */
  public static void main(String[] args) throws Exception {
    // Create a component
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8111);
    component.getClients().add(Protocol.FILE);

    // Create an application
    Application application = new Part09a_GuardAccess();

    // Attach the application to the component and start it
    component.getDefaultHost().attachDefault(application);
    component.start();
  }
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    component.getServers().add(Protocol.HTTP, 8111);
    component.getClients().add(Protocol.CLAP);
    component
        .getDefaultHost()
        .attach("/CoopOData.svc", new org.restlet.test.ext.odata.deepexpand.feed.CoOpApplication());
    component.start();

    service = new ContainerService();
  }
Esempio n. 13
0
  public void start() {
    KillBugApp app = new KillBugApp();

    component.getServers().add(Protocol.HTTP, port);

    component.getDefaultHost().attach(app);
    try {
      component.start();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Esempio n. 14
0
 public void startServer() {
   if (!started) {
     server = new Component();
     server.getServers().add(Protocol.HTTP, getConfig().getPort());
     server.getDefaultHost().attach(this);
     try {
       server.start();
       started = true;
     } catch (Exception e) {
       stopServer();
       throw new RuntimeException("Exception while starting server", e);
     }
   }
 }
  @Override
  protected void setUp() throws Exception {
    super.setUp();
    component = new Component();
    component.getServers().add(Protocol.HTTP, TEST_PORT);
    component.getClients().add(Protocol.FILE);
    component.getDefaultHost().attach(new TestRangeApplication());
    component.start();

    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < 1000; i++) {
      sb.append("1");
    }
    str1000 = sb.toString();
  }
Esempio n. 16
0
  @Before
  public void setUp() {
    testContext = new Context();

    component = new Component();
    component.getServers().add(Protocol.HTTP, PORT);
    component.getClients().add(Protocol.CLAP);
    component.getClients().add(Protocol.FILE);
    component.getDefaultHost().attach(testApp);

    try {
      component.start();
      factory.setUp();
    } catch (Exception e) {
      e.printStackTrace();
      Assert.fail();
    }
  }
  public void start(Properties configuration) throws Exception {
    if (!started) {
      component = new Component();
      component
          .getServers()
          .add(
              Protocol.HTTP,
              Integer.valueOf(configuration.getProperty(MediaServerConfiguration.HTTP_PORT)));

      Context context = component.getContext().createChildContext();
      component.getDefaultHost().attach(new MediaServerApplication(context));

      component.start();

      LOGGER.debug("Started test HTTP server");

      started = true;
    }
  }
Esempio n. 18
0
  public static void main(String[] args) throws Exception {
    // Create a component
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);
    component.getClients().add(Protocol.FILE);

    // Create an application
    Application application =
        new Application() {
          @Override
          public Restlet createInboundRoot() {
            return new Directory(getContext(), ROOT_URI);
          }
        };

    // Attach the application to the component and start it
    component.getDefaultHost().attach(application);
    component.start();
  }
Esempio n. 19
0
  public static void main(String[] args) {
    System.out.println("Starting server");

    try {
      // Create a new Component.
      Component component = new Component();

      // Add a new HTTP server listening on port 4080.
      component.getServers().add(Protocol.HTTP, 4080);

      // Attach the sample application.
      component.getDefaultHost().attach("/main", new QServerApplication());

      // Start the component.
      component.start();
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  public void testTemplateFilter() {
    try {
      // Create a temporary directory for the tests
      this.testDir = new File(System.getProperty("java.io.tmpdir"), "TemplateFilterTestCase");
      deleteDir(this.testDir);
      this.testDir.mkdir();

      // Create temporary template files
      // Will be templated
      final File testFileFm1 = new File(this.testDir, "testFm1.txt.fmt");
      FileWriter fw = new FileWriter(testFileFm1);
      fw.write("Method=${m}/Authority=${ra}");
      fw.close();

      // Will not be templated
      final File testFileFm2 = new File(this.testDir, "testFm2.txt");
      fw = new FileWriter(testFileFm2);
      fw.write("Method=${m}/Authority=${ra}");
      fw.close();

      // Will be templated
      final File testFileVl1 = new File(this.testDir, "testVl1.txt.vm");
      fw = new FileWriter(testFileVl1);
      fw.write("Method=${m}/Path=${rp}");
      fw.close();

      // Will not be templated
      final File testFileVl2 = new File(this.testDir, "testVl2.txt");
      fw = new FileWriter(testFileVl2);
      fw.write("Method=${m}/Path=${rp}");
      fw.close();

      // Create a new component
      final Component component = new Component();
      component.getServers().add(Protocol.HTTP, 8182);
      component.getClients().add(Protocol.FILE);

      // Create an application filtered with Freemarker
      final MyFreemakerApplication freemarkerApplication = new MyFreemakerApplication(this.testDir);
      // Create an application filtered with Velocity
      final MyVelocityApplication velocityApplication = new MyVelocityApplication(this.testDir);

      // Attach the applications to the component and start it
      component.getDefaultHost().attach("/freemarker", freemarkerApplication);
      component.getDefaultHost().attach("/velocity", velocityApplication);

      // Now, let's start the component!
      component.start();

      // Allow extensions tunneling
      freemarkerApplication.getTunnelService().setExtensionsTunnel(true);
      velocityApplication.getTunnelService().setExtensionsTunnel(true);
      final Client client = new Client(Protocol.HTTP);
      Response response = client.get("http://localhost:8182/freemarker/" + testFileFm1.getName());
      if (response.isEntityAvailable()) {
        assertEquals(response.getEntity().getText(), "Method=GET/Authority=localhost:8182");
      }
      response = client.get("http://localhost:8182/freemarker/" + testFileFm2.getName());
      assertTrue(response.getStatus().isSuccess());
      if (response.isEntityAvailable()) {
        assertEquals(response.getEntity().getText(), "Method=${m}/Authority=${ra}");
      }

      response = client.get("http://localhost:8182/velocity/" + testFileVl1.getName());
      if (response.isEntityAvailable()) {
        assertEquals(response.getEntity().getText(), "Method=GET/Path=/velocity/testVl1");
      }
      response = client.get("http://localhost:8182/velocity/" + testFileVl2.getName());
      assertTrue(response.getStatus().isSuccess());
      if (response.isEntityAvailable()) {
        assertEquals(response.getEntity().getText(), "Method=${m}/Path=${rp}");
      }
      // Now, let's stop the component!
      component.stop();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Esempio n. 21
0
 public static void main(String[] args) throws Exception {
   Component component = new DemoComponent();
   component.start();
 }