11-23-2008 03:41 PM
<%@page import="java.rmi.Naming" %>
<%@page import="java.util.Properties" %>
<%@page import="javax.jcr.*" %>
<%@page import="org.apache.commons.logging.Log" %>
<%@page import="org.apache.commons.logging.LogFactory" %>
<%@page import="org.apache.jackrabbit.rmi.client.ClientAdapterFactory" %>
<%@page import="org.apache.jackrabbit.rmi.client.LocalAdapterFactory" %>
<%@page import="org.apache.jackrabbit.rmi.remote.RemoteRepository" %>
<%
/* define locals */
String vRmiRegistryLocation = null;
Object vRemoteObjectReference = null;
Repository vJcrRepository = null;
LocalAdapterFactory vLocalAdapterFactory = null;
Session vJcrSession = null;
Node vJcrNode = null;
String vRmiServerName = null;
String vRmiServerPort = null;
String vRmiBindingName = null;
Properties vJcrRmiProperties = null;
try
{
/* intitalize */
vJcrRmiProperties = new Properties();
vLocalAdapterFactory = new ClientAdapterFactory();
vJcrRmiProperties.load(this.getClass().getClassLoader().getResourceAsStream("/alfresco/extension/jcr-rmi.properties"));
/* get command line argments for connection parameters */
vRmiServerName = vJcrRmiProperties.getProperty("rmi.jcr.binding.servername");
vRmiServerPort = vJcrRmiProperties.getProperty("rmi.jcr.binding.port");
vRmiBindingName = vJcrRmiProperties.getProperty("rmi.jcr.binding.name");
vRmiRegistryLocation = "//"+vRmiServerName;
vRmiRegistryLocation += ":"+vRmiServerPort;
vRmiRegistryLocation += "/"+vRmiBindingName;
%>
<h1>JCR RMI Test</H1></br>
<b>RMI Registery Server Name :</b><%=vRmiServerName%></br>
<b>RMI Registery Server Name :</b><%=vRmiServerName%></br>
<b>Remote JCR reference binding name:</b><%=vRmiBindingName%></br>
</p>
<b>Connection String:</b><%=vRmiRegistryLocation%></br>
<p>
<h2>Testing…</h2></br>
<%
out.write("looking up remote reference at ["+vRmiRegistryLocation+"]</br>");
vRemoteObjectReference = Naming.lookup(vRmiRegistryLocation);
out.write("creating local adapter for remotereference ["+vRemoteObjectReference+"]</br>");
vJcrRepository = vLocalAdapterFactory.getRepository((RemoteRepository)vRemoteObjectReference);
out.write("logging in as admin admin to default workspace</br>");
vJcrSession = vJcrRepository.login(new SimpleCredentials("admin", "admin".toCharArray()));
out.write("looking up workspace root node</br>");
vJcrNode = vJcrSession.getRootNode();
Node cHome = vJcrNode.getNode("app:company_home");
NodeIterator iter = vJcrSession.getRootNode().getNode("app:company_home").getNode("cm:TestDocs").getNodes();
Node node = iter.nextNode();
node = iter.nextNode();
Property property = node.getProperty("mydm:sampleMultiValuedProp");
Value[] values = property.getValues();
out.write("node UUID ["+node.getUUID() +"]</br>");
out.write("root node UUID ["+vJcrNode.getUUID() +"]</br>");
out.write("logging out</br>");
vJcrSession.logout();
}
catch(Exception eTestFailure)
{
out.write("unexpected exception encountered ["+eTestFailure+"]</br>");
}
%>
09-25-2009 02:19 PM
<!– Runtime dependencies –>
<dependency>
<groupId>javax.jcr</groupId>
<artifactId>jcr</artifactId>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-jcr-commons</artifactId>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
10-21-2009 10:08 AM
10-22-2009 05:41 AM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.