/** * Sets the modifiable list of virtual hosts. Note that the order of virtual * hosts in this list will be used to check the first one that matches. This * method clears the current list and adds all entries in the parameter * list. * * @param hosts * A list of virtual hosts. */ public void setHosts(List<VirtualHost> hosts) { synchronized (getHosts()) { if (hosts != getHosts()) { getHosts().clear(); if (hosts != null) { getHosts().addAll(hosts); } } } }
Component component = (...) // HTTPS VirtualHost hostHttps = new VirtualHost(component.getContext()); component.getHosts().add(hostHttps); hostHttps.setHostScheme("https"); Restlet restletSecure = (...) hostHttps.attachDefault(restletSecure); // HTTP VirtualHost hostHttp = new VirtualHost(component.getContext()); component.getHosts().add(hostHttp); hostHttp.setHostScheme("http"); Restlet restletUnsecure = (...) hostHttp.attachDefault(restletUnsecure);
/** * Starts the virtual hosts and the internal router. * * @throws Exception */ protected synchronized void startRouters() throws Exception { if (this.internalRouter != null) { this.internalRouter.start(); } if (this.defaultHost != null) { this.defaultHost.start(); } for (VirtualHost host : getHosts()) { host.start(); } }
/** * Stops the virtual hosts and the internal router. * * @throws Exception */ protected synchronized void stopRouters() throws Exception { for (VirtualHost host : getHosts()) { host.stop(); } if (this.defaultHost != null) { this.defaultHost.stop(); } if (this.internalRouter != null) { this.internalRouter.stop(); } }
final VirtualHost host = new VirtualHost(getContext()); parseHost(host, childNode); getHosts().add(host); } else if ("parameter".equals(childNode.getNodeName())) { final Node nameNode = childNode.getAttributes()
@Override public synchronized void stop() throws Exception { // Stop the server's router getServerRouter().stop(); // Stop all applications stopHostApplications(getHelped().getDefaultHost()); for (VirtualHost host : getHelped().getHosts()) { stopHostApplications(host); } }
definition.getEndpoints().add(endpoint); for (VirtualHost virtualHost : component.getHosts()) { endpoint = ComponentIntrospector.getEndpoint(virtualHost, application, scheme);
definition.getEndpoints().add(endpoint); for (VirtualHost virtualHost : component.getHosts()) { endpoint = ComponentIntrospector.getEndpoint(virtualHost, application, scheme);
definition.getEndpoints().add(endpoint); for (VirtualHost virtualHost : component.getHosts()) { endpoint = ComponentIntrospector.getEndpoint(virtualHost, application, scheme);
definition.getEndpoints().add(endpoint); for (VirtualHost virtualHost : component.getHosts()) { endpoint = ComponentIntrospector.getEndpoint(virtualHost, application, scheme);
definition.getEndpoints().add(endpoint); for (VirtualHost virtualHost : component.getHosts()) { endpoint = ComponentIntrospector.getEndpoint(virtualHost, application, scheme);
.getContext()); parseHost(host, childNode); getComponent().getHosts().add(host); } else if ("internalRouter".equals(childNode.getNodeName())) { parseRouter(getComponent().getInternalRouter(),
.getHosts().iterator(); (host == null) && hostIter.hasNext();) { currentHost = hostIter.next();
/** Starts the Restlet. */ @Override public synchronized void start() throws Exception { // Attach all virtual hosts for (VirtualHost host : getComponent().getHosts()) { getRoutes().add(new HostRoute(this, host)); } // Also attach the default host if it exists if (getComponent().getDefaultHost() != null) { getRoutes().add( new HostRoute(this, getComponent().getDefaultHost())); } // If no host matches, display and error page with a precise message final Restlet noHostMatched = new Restlet(getComponent().getContext() .createChildContext()) { @Override public void handle(Request request, Response response) { response.setStatus(Status.CLIENT_ERROR_NOT_FOUND, "No virtual host could handle the request"); } }; setDefaultRoute(new org.restlet.routing.TemplateRoute(this, "", noHostMatched)); // Start the router super.start(); }
for (VirtualHost host : getHelped().getHosts()) { success = success && checkVirtualHost(host);