Package org.restlet

Examples of org.restlet.Component


    static void startServer(String repo) throws Exception {
        GeoGIG geogig = loadGeoGIG(repo);
        org.restlet.Context context = new org.restlet.Context();
        Application application = new Main(geogig);
        application.setContext(context);
        Component comp = new Component();
        comp.getDefaultHost().attach(application);
        comp.getServers().add(Protocol.HTTP, 8182);
        comp.start();
    }
View Full Code Here


        String loc = repo != null && repo.size() > 0 ? repo.get(0) : ".";

        GeoGIG geogig = loadGeoGIG(loc, cli);
        Application application = new Main(geogig);

        Component comp = new Component();

        comp.getDefaultHost().attach(application);
        comp.getServers().add(Protocol.HTTP, port);

        cli.getConsole().println(
                String.format("Starting server on port %d, use CTRL+C to exit.", port));

        try {
            comp.start();
            cli.setExitOnFinish(false);
        } catch (BindException e) {
            String msg = String.format(
                    "Port %d already in use, use the --port parameter to specify a different port",
                    port);
View Full Code Here

    private Boolean pipeliningConnections;
    private Integer threadMaxIdleTimeMs;
    private Boolean useForwardedForHeader;

    public RestletComponent() {
        this(new Component());
    }
View Full Code Here

    }
   
    public static void main(String[] args) {
        try {
            // Create a new Component.
            Component component = new Component();

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

            // Attach the application which has all the mock url added
            component.getDefaultHost().attach("/simplefeatureservice", new MockSimpleFeatureService());

            // Start the component.
            component.start();
        } catch (Exception e) {
           
            System.out.println("Exception in StandAloneApplication "+e.getMessage());
        }
    }
View Full Code Here

   *            The HTTP Servlet request.
   * @return The new HTTP server handling calls.
   */
  public HttpServerHelper createServer(HttpServletRequest request) {
    HttpServerHelper result = null;
    Component component = getComponent();
    Application application = getApplication();

    if ((component != null) && (application != null)) {
      // First, let's locate the closest component
      Server server = new Server(component.getContext(),
          (List<Protocol>) null, request.getLocalAddr(), request
              .getLocalPort(), component);
      result = new HttpServerHelper(server);

      // Attach the application
      String uriPattern = request.getContextPath()
          + request.getServletPath();
      component.getDefaultHost().attach(uriPattern, application);
    }

    return result;
  }
View Full Code Here

   * Returns the component. It creates a new one if none exists.
   *
   * @return The component.
   */
  public Component getComponent() {
    Component result = this.component;

    if (result == null) {
      synchronized (ServerServlet.class) {
        // Find the attribute name to use to store the component
        String componentAttributeName = getInitParameter(
            NAME_COMPONENT_ATTRIBUTE,
            NAME_COMPONENT_ATTRIBUTE_DEFAULT);

        // Look up the attribute for a target
        result = (Component) getServletContext().getAttribute(
            componentAttributeName);

        if (result == null) {
          result = new Component();
          // The status service is disabled by default.
          result.getStatusService().setEnabled(false);
          getServletContext().setAttribute(componentAttributeName,
              result);
        }

        this.component = result;
View Full Code Here

 
  void startServer()
  {
    LOG.info("zkDataTransferServer starting on Port " + _localWebservicePort + " zkAddress " + _zkAddress);
   
    _component = new Component();
   
    _component.getServers().add(Protocol.HTTP, _localWebservicePort);
    Context applicationContext = _component.getContext().createChildContext();
    applicationContext.getAttributes().put(SERVER, this);
    applicationContext.getAttributes().put(PORT, "" + _localWebservicePort);
View Full Code Here

    else {
      logger.debug("_mockNode not null");
    }
    if (_mockNode != null) {
      // start web server with the zkServer address
      _component = new Component();
      _component.getServers().add(Protocol.HTTP, _serverPort);
      // Attach the application to the component and start it
      _component.getDefaultHost().attach(this); //(application);
      _context.getAttributes().put(COMPONENT_NAME, (Object)_component);
     // _context.getParameters().set("maxTotalConnections", "16",true);
View Full Code Here

    System.out.println("StopServiceResource.represent()");
    StringRepresentation presentation = null;
    try
    {
      logger.debug("in represent, stopping service");
      Component component = (Component)_context.getAttributes().get(MockEspressoService.COMPONENT_NAME);
      EspressoStorageMockNode mock = (EspressoStorageMockNode)_context.getAttributes().get(MockEspressoService.CONTEXT_MOCK_NODE_NAME);
      presentation = new StringRepresentation("Stopping in 1 second", MediaType.APPLICATION_JSON);
      Thread stopper = new Thread(new StopThread(component, mock));
      stopper.start();
    }
View Full Code Here

 
  void startServer()
  {
    LOG.info("zkDataTransferServer starting on Port " + _localWebservicePort + " zkAddress " + _zkAddress);
   
    _component = new Component();
   
    _component.getServers().add(Protocol.HTTP, _localWebservicePort);
    Context applicationContext = _component.getContext().createChildContext();
    applicationContext.getAttributes().put(SERVER, this);
    applicationContext.getAttributes().put(PORT, "" + _localWebservicePort);
View Full Code Here

TOP

Related Classes of org.restlet.Component

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.