%@ page import="java.net.URI"%><%--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
--%><%@page import="org.apache.jackrabbit.util.Text"%><%
request.setAttribute("title", "Remote Repository Access");
URI uri = new URI(request.getRequestURL().toString());
String base =
uri.getScheme() + "://" + uri.getHost() + ":" + uri.getPort()
+ request.getContextPath();
base = Text.encodeIllegalXMLCharacters(base);
%>
The content repository within this web application may be made available to remote clients through RMI and the jackrabbit-jcr-rmi component.
To access a remote repository stub, it needs to be registered in the RMI registry. By default, this is not started automatically by this web application. To change that, use the related properties in the bootstrap.properties file which are commented out in the template file. You can also make the stub available as a direct HTTP download by enabling the RemoteBindingServlet and the corresponding servlet mapping, which are commented out in the web.xml template. The default URLs for accessing the remote repository are:
Note that the above URLs are the defaults. You can disable or change them by modifying the /WEB-INF/web.xml deployment descriptor.
To access the remote content repository you need to use the jackrabbit-jcr-rmi component in your application. If you use Maven 2, you can declare the JCR and jackrabbit-jcr-rmi dependencies like this:
<dependency> <groupId>javax.jcr</groupId> <artifactId>jcr</artifactId> <version>1.0</version> </dependency> <dependency> <groupId>org.apache.jackrabbit</groupId> <artifactId>jackrabbit-jcr-rmi</artifactId> <version>1.4</version> </dependency>
With that dependency in place, you can use either the RMI registry or the direct HTTP download to access the repository.
The required code for accessing the repository using the RMI registry is:
import javax.jcr.Repository; import org.apache.jackrabbit.rmi.repository.RMIRemoteRepository; Repository repository = new RMIRemoteRepository("//localhost/jackrabbit.repository");
The required code for accessing the repository using the RMI registry is:
import javax.jcr.Repository; import org.apache.jackrabbit.rmi.repository.URLRemoteRepository; Repository repository = new URLRemoteRepository("<%= base %>/rmi");
See the JCR specification and the Repository javadoc for details on what to do with the acquired Repository instance.
Note that the design goal of the current jackrabbit-jcr-rmi component is correct and complete functionality instead of performance, so you should not rely on remote access for performance-critical applications.
You may want to look at the Jackrabbit clustering feature for best performance for concurrently accessing the repository on multiple separate servers.