我需要使用远程jackrabbit 存储库。我使用以下代码连接到本地存储库:
Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));
这适用于本地存储库,但如果是远程jackrabbit,我该怎么办?
我需要使用远程jackrabbit 存储库。我使用以下代码连接到本地存储库:
Repository repository = new TransientRepository();
Session session = repository.login(new SimpleCredentials("username", "password".toCharArray()));
这适用于本地存储库,但如果是远程jackrabbit,我该怎么办?
Another option is WebDav, which is supposed to be somewhat faster than RMI, though not as fast as the native interface:
import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;
import org.apache.jackrabbit.commons.JcrUtils;
public class main {
/**
* @param args
*/
public static void main(String[] args) throws Throwable{
String url = "http://localhost:8080/server";
System.out.println("Connecting to " + url);
Repository repository = JcrUtils.getRepository(url);
SimpleCredentials creds = new SimpleCredentials("admin",
"admin".toCharArray());
Session jcrSession = repository.login(creds, "default");
System.out.println("Login successful, workspace: " + jcrSession.getWorkspace());
你试过用这个吗?
import javax.jcr.Repository;
import org.apache.jackrabbit.commons.JcrUtils;
Repository repository = JcrUtils.getRepository("http://$SERVER_ADDRESS:$PORT/$CONTEXT");
如果远程存储库正在公开 RMI 服务,那应该可以工作。请注意,RMI 访问通常被认为非常慢。
您将在此处找到有关访问远程存储库的更多信息。
我们使用Sling提供的 REST 接口来远程访问我们的存储库。