I wanted to set up something like is shown in the tutorial component diagram
where there are VirtualHost A and B and Application 1, 2, and 3. I'm using
RC3 and my code looks like this:
public class ComponentServer {
public static final String DOC_URI
file:////home/slandis/restlet-1.0rc3/docs/api/";
public static final String JAR_URI
"file:////home/slandis/restlet-1.0rc3/lib/org.restlet.jar";
public static void main(String[] args) throws Exception {
Component component = new Component();
component.getServers().add(Protocol.HTTP, 8182);
component.getClients().add(Protocol.FILE);
VirtualHost vh1 = new VirtualHost(component.getContext());
vh1.setHostDomain("localhost");
Application application1 = new Application(component.getContext()) {
@Override public Restlet createRoot() {
Directory directory = new Directory(getContext(), DOC_URI);
return directory;
}
};
VirtualHost vh2 = new VirtualHost(component.getContext());
vh2.setHostDomain("wasatch");
Application application2 = new Application(component.getContext()) {
@Override public Restlet createRoot() {
Restlet jarRestlet = new Restlet(getContext()) {
@Override public void handle(Request request, Response response) {
FileRepresentation frep = new FileRepresentation(JAR_URI,
MediaType.APPLICATION_JAVA_ARCHIVE, 1000);
response.setEntity(frep);
}
};
return jarRestlet;
}
};
vh1.attach("/docs", application1);
component.getHosts().add(vh1);
vh2.attach("/jar", application2);
component.getHosts().add(vh2);
component.start();
}
I can access "/docs" but "/jar" is not resolved. I get:
"The server has not found anything matching the request URI"
I tried looking at the code but got lost trying to figure out the dispatching
of the handle() method to the handler. I kept going in circles and never
could find where the servers list was being used.
Any help appreciated.
Sean