Hi Sean,

I will not give you a lot of explanation but a single example taken directly from the restlets.
The following sites are served from only one machine :
1- www.restlet.org
2- search.restlet.org

The first one serves static files such as the Restlet API javadocs, the Noelios Restlet Engine javadocs, etc.
The second one set up 2 distinct redirections to the google search engine :
- search.restlet.org/custom?XXX is redirected to a custom URL www.google.com/<parameters defined by Google>&q=XXX
 - search.restlet.org/XXX is redirected to www.google.com/XXX

Jérôme has decided to set up the component (the container) with 2 virtual hosts one for "www.restlet.org", and one for "search.restlet.org" :
       // definition of virtual host #1
       VirtualHost host = new VirtualHost(component.getContext());
       host.setHostDomain("www.restlet.org");
       host.setHostPort("80");
       host.attach(new SubApplication1(<parameters>));
       component.getHosts().add(host);

       // definition of virtual host #2
       host = new VirtualHost(component.getContext());
       host.setHostDomain("search.restlet.org");
       host.setResourcePort("80");
       host.attach(new SubApplication2(<parameters>);
       host.attach("/custom", new SubApplication3(<otherParameters>);
       getHosts().add(host);

As you may have noticed, the first virtual host takes in charge 1 application and the second 2 applications.
In the "createRoot" method, SubApplication1  :
   - defines one Routeur intance (returned by the createRoot method)
- attaches several "Directory" instances to the Router instance in order to serve all distinct static directories (one the Reslet API javadocs, one for the NRE javadocs, etc). In the "createRoot" method, SubApplication2 and SubApplication3 define a single Redirection instance.

I know that Jérôme will give you a better explanation., but I hope this will help you. A great effort has to be done now for the documentation, and it is clear that a concrete and complete example will help anybody interessed by the Restlets. I think that Jérôme is about to present the application developped for all Restlets sites, but he need some times.

best regards,
Thierry

Sean Landis a écrit :
I am interested in composing a component like the one in the tutorial that
contains two virtual hosts and 3 applications. I'm not understanding what all
the parameters to the VirtualHost constructor mean and I can't find any use
of it in the source. The JavaDoc could be made clearer here.
Could someone elaborate on the meaning of the parameters?

Thanks,
Sean

Reply via email to