Package org.restlet.routing

Examples of org.restlet.routing.VirtualHost


                            getComponent().getContext().getParameters().add(p);
                        }
                    } else if ("defaultHost".equals(childNode.getNodeName())) {
                        parseHost(getComponent().getDefaultHost(), childNode);
                    } else if ("host".equals(childNode.getNodeName())) {
                        final VirtualHost host = new VirtualHost(getComponent()
                                .getContext());
                        parseHost(host, childNode);
                        getComponent().getHosts().add(host);
                    } else if ("internalRouter".equals(childNode.getNodeName())) {
                        parseRouter(getComponent().getInternalRouter(),
View Full Code Here


                            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)) {
View Full Code Here

    @Override
    protected void logRoute(org.restlet.routing.Route route) {
        if (getLogger().isLoggable(Level.FINE)) {
            if (route instanceof HostRoute) {
                VirtualHost vhost = ((HostRoute) route).getVirtualHost();

                if (getComponent().getDefaultHost() == vhost) {
                    getLogger().fine("Default virtual host selected");
                } else {
                    getLogger().fine(
                            "Virtual host selected: \"" + vhost.getHostScheme()
                                    + "\", \"" + vhost.getHostDomain()
                                    + "\", \"" + vhost.getHostPort() + "\"");
                }
            } else {
                super.logRoute(route);
            }
        }
View Full Code Here

      this.edited = edited;
      this.docLoader = new SAXDocumentLoader();
      this.isStatic = isStatic;
      context.getAttributes().put(WebComponent.LINKS_ATTR, hostConf.getLinks());
      getLogger().info("Adding host "+hostConf.getName()+":"+server.getPort());
      this.vhost = new VirtualHost(context) {
         public void handle(Request request, Response response) {
            long startTime = System.currentTimeMillis();
            super.handle(request,response);
            if (hostLog!=null) {
               int duration = (int) (System.currentTimeMillis() - startTime);
View Full Code Here

        this.realms = new CopyOnWriteArrayList<Realm>();
        this.services = new ServiceList(getContext());

        if (Engine.getInstance() != null) {
            this.helper = new ComponentHelper(this);
            this.defaultHost = new VirtualHost(getContext()
                    .createChildContext());
            this.internalRouter = new InternalRouter(getContext()
                    .createChildContext());
            this.services.add(new LogService());
            this.services.add(new StatusService());
View Full Code Here

    }

    public void testDefaultHost() throws Exception {
        System.out.println("-- testDefaultHost()");

        final VirtualHost dh = c.getDefaultHost();
        assertNotNull("Default Host MUST NOT be null", dh);

        assertEquals(dh.getName(), RESTLET_NAME);
        assertEquals(dh.getDescription(), RESTLET_DESCRIPTION);
    }
View Full Code Here

    }

    public void testDefaultHostParams() throws Exception {
        System.out.println("-- testDefaultHostParams()");

        VirtualHost dh = c.getDefaultHost();
        assertNotNull("Default Host MUST NOT be null", dh);
        String msg = "[" + HOST + ":" + dh.getHostPort() + "] ";
        Context ctx = dh.getContext();

        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "1");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "2");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "3");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "4");
View Full Code Here

        System.out.println("-- testHostParams()");

        List<VirtualHost> hosts = c.getHosts();
        assertNotNull("Host List MUST NOT be null", hosts);
        assertEquals("Server list MUST contain 1 item", 1, hosts.size());
        VirtualHost host = hosts.get(0);
        assertNotNull("The single Host MUST NOT be null", host);

        String msg = "[" + HOST + ":" + host.getHostPort() + "] ";
        Context ctx = host.getContext();

        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "1");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "2");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "3");
        checkNegativeParam(msg, ctx, CON_PARAM_NAME + "4");
View Full Code Here

     * @param component
     *            The parent component to update.
     * @return The parent virtual host.
     */
    public VirtualHost attachToComponent(Component component) {
        VirtualHost result = null;

        if (getBaseRef() != null) {
            // Create the virtual host
            result = getVirtualHost(component);

View Full Code Here

        // Create the virtual host if necessary
        final String hostDomain = this.baseRef.getHostDomain();
        final String hostPort = Integer.toString(this.baseRef.getHostPort());
        final String hostScheme = this.baseRef.getScheme();

        VirtualHost host = null;
        for (final VirtualHost vh : component.getHosts()) {
            if (vh.getHostDomain().equals(hostDomain)
                    && vh.getHostPort().equals(hostPort)
                    && vh.getHostScheme().equals(hostScheme)) {
                host = vh;
            }
        }

        if (host == null) {
            // A new virtual host needs to be created
            host = new VirtualHost(component.getContext().createChildContext());
            host.setHostDomain(hostDomain);
            host.setHostPort(hostPort);
            host.setHostScheme(hostScheme);
            component.getHosts().add(host);
        }

        return host;
    }
View Full Code Here

TOP

Related Classes of org.restlet.routing.VirtualHost

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.