Package org.restlet

Examples of org.restlet.Component


  {
    LOG.info("helixAdminWebApp starting");
    if(_component == null)
    {
      _zkClient = new ZkClient(_zkServerAddress,  ZkClient.DEFAULT_SESSION_TIMEOUT, ZkClient.DEFAULT_CONNECTION_TIMEOUT, new ZNRecordSerializer());
      _component =  new Component();
      _component.getServers().add(Protocol.HTTP, _helixAdminPort);
      Context applicationContext = _component.getContext().createChildContext();
      applicationContext.getAttributes().put(RestAdminApplication.ZKSERVERADDRESS, _zkServerAddress);
      applicationContext.getAttributes().put(RestAdminApplication.PORT, ""+_helixAdminPort);
      applicationContext.getAttributes().put(RestAdminApplication.ZKCLIENT, _zkClient);
View Full Code Here


        if (protocol.equals(Protocol.RIAP)) {
            // Let's dispatch it
            final LocalReference cr = new LocalReference(request
                    .getResourceRef());
            final Component component = getComponent();

            if (component != null) {
                if (cr.getRiapAuthorityType() == LocalReference.RIAP_COMPONENT) {
                    // This causes the baseRef of the resource reference to be
                    // set as if it had actually arrived from a server
                    // connector.
                    request.getResourceRef().setBaseRef(
                            request.getResourceRef().getHostIdentifier());

                    // Ask the private internal route to handle the call
                    component.getInternalRouter().handle(request, response);
                } else if (cr.getRiapAuthorityType() == LocalReference.RIAP_HOST) {
                    VirtualHost host = null;
                    VirtualHost currentHost = null;
                    final Integer hostHashCode = VirtualHost.getCurrent();

                    // Lookup the virtual host
                    for (final Iterator<VirtualHost> hostIter = getComponent()
                            .getHosts().iterator(); (host == null)
                            && hostIter.hasNext();) {
                        currentHost = hostIter.next();

                        if (currentHost.hashCode() == hostHashCode) {
                            host = currentHost;
                        }
                    }

                    if ((host == null) && (component.getDefaultHost() != null)) {
                        if (component.getDefaultHost().hashCode() == hostHashCode) {
                            host = component.getDefaultHost();
                        }
                    }

                    if (host != null) {
                        // This causes the baseRef of the resource reference to
View Full Code Here

     * Returns the parent component.
     *
     * @return The parent component.
     */
    private Component getComponent() {
        Component result = null;

        if ((getComponentContext() != null)
                && (getComponentContext().getComponentHelper() != null)) {
            result = getComponentContext().getComponentHelper().getHelped();
        }
View Full Code Here

   
    identityService.createMembership(user.getId(), group.getId());
  }
 
  protected void initializeRestServer() throws Exception {
    component = new Component()
    // Add a new HTTP server listening on port 8182. 
    component.getServers().add(Protocol.HTTP, 8182);  
    component.getDefaultHost().attach(new ActivitiRestApplication());
    component.start();
  }
View Full Code Here

                    return new JacksonRepresentation<Status>(status);
                }               
            });
           
            try {
                final Component component = new Component();
                component.getServers().add(Protocol.HTTP, restPort);
                component.getClients().add(Protocol.CLAP);
                component.getDefaultHost().attach(this);
                component.start();
               
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
View Full Code Here

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

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

   * @param config
   */
  static void start(ProxyConfig config) throws Exception {
    Engine.setRestletLogLevel(Level.INFO);

    Component c = new Component();
   
    // turn off Restlet url access logging
    c.getLogService().setEnabled(config.getAccessLog());

    // specify the Jetty helpers
    String httpHelper = "org.restlet.ext.jetty.HttpServerHelper";
    String httpsHelper = "org.restlet.ext.jetty.HttpsServerHelper";
   
    // create a Restlet server
    if (config.getBindAddresses().size() == 0) {
      // start server on all available addresses
      if (config.getHttpPort() > 0) {
        Server server = new Server(null, Arrays.asList(Protocol.HTTP), null, config.getHttpPort(), c, httpHelper);
        c.getServers().add(server);
      }
      if (config.getHttpsPort() > 0) {
        Server server = new Server(null, Arrays.asList(Protocol.HTTPS), null, config.getHttpsPort(), c, httpsHelper);
        c.getServers().add(server);
        configureHttps(server, config);
      }
    } else {
      // start server on specific address(es)
      for (String address : config.getBindAddresses()) {
        if (config.getHttpPort() > 0) {
          Server server = new Server(null, Arrays.asList(Protocol.HTTP), address, config.getHttpPort(), c, httpHelper);
          c.getServers().add(server);
        }
        if (config.getHttpsPort() > 0) {
          Server server = new Server(null, Arrays.asList(Protocol.HTTPS), address, config.getHttpsPort(), c, httpsHelper);
          c.getServers().add(server);
          configureHttps(server, config);
        }
      }
    }

    // add client classpath protocol to enable resource loading from the jar
    c.getClients().add(Protocol.CLAP);

    // add client file protocol to enable serving artifacts from filesystem
    c.getClients().add(Protocol.FILE);

    // override the default error pages
    c.setStatusService(new ErrorStatusService(c.getContext()));

    // get the default virtual host
    VirtualHost host = c.getDefaultHost();   

    MoxieProxy app = new MoxieProxy(config);

    // Guard Moxie Proxy with BASIC authentication.
    Authenticator guard = new Authenticator(app);
    host.attachDefault(guard);
    guard.setNext(app);
   
    // start the shutdown monitor
    if (config.getShutdownPort() > 0) {
      Thread shutdownMonitor = new ShutdownMonitorThread(c, app, config);
      shutdownMonitor.start();
    }

    // start the Restlet http/https server
    c.start();
  }
View Full Code Here

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

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

public class RestServer extends Application {

  public static void createRestServer(ApplicationContext appCtx, String propertiesPath, int port) throws Exception {

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

    Context context = component.getContext().createChildContext();
    RestServer application = new RestServer(context);
   
    application.getContext().getParameters().add("useForwardedForHeader", "true");
   
    application.getContext().getAttributes().put("appCtx", appCtx);
    application.getContext().getAttributes().put("file", propertiesPath);

    // Attach the application to the component and start it
    component.getDefaultHost().attach(application);
    component.start();
  }
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.