Package org.restlet

Examples of org.restlet.Component


  protected void setUp()
      throws Exception
  {
    super.setUp();

    component = new Component();

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

    TestApplication app = (TestApplication) getContainer().lookup(Application.class, "test");
View Full Code Here


  }

  public void testRest()
      throws Exception
  {
    Component component = new Component();
    component.getServers().add(Protocol.HTTP, 8182);
    PlexusRestletApplicationBridge app = (PlexusRestletApplicationBridge) getContainer().lookup(Application.class);
    component.getDefaultHost().attach(app);
    component.start();
    component.stop();
  }
View Full Code Here

  }

  public void testXML()
      throws Exception
  {
    Component component = new Component();

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

    TestApplication app = (TestApplication) getContainer().lookup(Application.class, "test");

    component.getDefaultHost().attach(app);

    component.start();

    Status status = post(URL, VALID).getStatus();
    assertTrue(status.toString(), status.isSuccess());
    status = post(URL, INVALID).getStatus();
    assertEquals(status.toString(), 400, status.getCode());

    component.stop();
  }
View Full Code Here

      Globals.overrideConfigLocation(args[0]);

    try
      {         
          // Create a new Component. 
          Component component = new Component()
   
          // Add a new HTTP server listening on port 8184. 
          int port = 8184;
          component.getServers().add(Protocol.HTTP, port);
         
          // Increase the # threads
          component.getServers().get(0).getContext().getParameters().add("maxThreads", "100");
         
          // Attach the sample application. 
          component.getDefaultHost().attach(new EmbeddedRestletApp())
   
          // Start background threads:
          EmbeddedRestletApp.setupPollingHandlers();         
         
          // Start the component. 
          component.start();
      }
      catch (Exception e)
      { 
          // Something is wrong. 
          e.printStackTrace()
View Full Code Here

    }

    try
      {         
          // Create a new Component. 
          Component component = new Component()
   
          // Add a new HTTP server listening on port 8184. 
          int port = 8185;
          component.getServers().add(Protocol.HTTP, port)
          // Attach the sample application. 
          component.getDefaultHost().attach(new AppServer())
   
          // Start the polls
          AppServer.setupPollingHandlers();
         
          // Start the component. 
          component.start();
      }
      catch (Exception e)
      { 
          // Something is wrong. 
          e.printStackTrace()
View Full Code Here

  private boolean running;
 
  public NutchServer(int port) {
    this.port = port;
    // Create a new Component.
    component = new Component();
    //component.getLogger().setLevel(Level.FINEST);
  
    // Add a new HTTP server listening on port 8182.
    component.getServers().add(Protocol.HTTP, port);
  
View Full Code Here

            LinkedDataServer server = new LinkedDataServer(this.getSail(),
                    internalBaseURI,
                    externalBaseURI,
                    datasetURI);

            Component component = new Component();
            server.setInboundRoot(component);
            component.getServers().add(Protocol.HTTP, port);
            component.getServers().add(Protocol.FILE, port);

            component.getDefaultHost().attach("/", new Directory(server.getContext(), "file://" + staticContentDir + "/"));

            for (TwitLogic.ResourceType t : TwitLogic.ResourceType.values()) {
                String p = t.getUriPath();
                if (!p.equals("graph") && !p.equals("person")) {
                    component.getDefaultHost().attach("/" + p + "/", WebResource.class);
                }
            }
            component.getDefaultHost().attach("/person/twitter/", PersonResource.class);
            component.getDefaultHost().attach("/graph/", GraphResource.class);

            component.getDefaultHost().attach("/sparql", new SparqlResource());
            component.getDefaultHost().attach("/stream/relatedTweets", new RelatedTweetsResource());
            component.getDefaultHost().attach("/stream/relatedTags", new RelatedHashtagsResource());

            server.start();
        } catch (Throwable e) {
            throw new ServerException(e);
        }
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();
                    getServletContext().setAttribute(componentAttributeName,
                            result);
                }

                this.component = result;
View Full Code Here

        setupGlobalProperties(port);
       
        // Start Heritrix.
        try {
            engine = new Engine(jobsDir);
            component = new Component();
           
            if(bindHosts.isEmpty()) {
                // listen all addresses
                setupServer(port, null, keystorePath, keystorePassword, keyPassword);
            } else {
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.