Simply because you use this protocol within the ROOT_URI
variable ;-) Regarding protocols, you need to explicitly add them when creating the Restlet component. Client connectors provide a way to use protocols to access resources (local or remote).
Here are some more details about what happens under the hood:
When adding a Restlet extension in the classpath, some elements are registered within the engine. You can have converters, server connectors, client connectors, ... You can see what is registered on the instance of the Engine
itself:
List<ConnectorHelper<Client>> clientConnectors
= Engine.getInstance().getRegisteredClients();
for (ConnectorHelper<Client> clientConnector : clientConnectors) {
System.out.println(clientConnector);
}
Regarding client connectors, they correspond to entities that are able to handle particular protocol(s). For example, the Jetty extension providers a client connector to execute HTTP and HTTPS requests based on the Jetty client API.
- To actually be able to use these registered client connectors, you need to enable them by specifying the protocol you want to use. For example, if you add the
HTTP
protocol, Restlet will find the first client connector in the list of registered one that is able to handle this protocol. For execute HTTP request, it will use this connector. If there is no available connector, it will throw an exception...
In your case, the client connector for the FILE
protocol is provided by Restlet core itself so it's automatically registered. But you need to explicitly tell Restlet that you want to use this protocol.
Hope it helps you,
Thierry