您好,我要对存储库进行程序化配置,因为存储库中配置的大部分参数只能在运行时确定。
当im尝试打印会话时,我似乎无法使用匿名凭据,它抛出了下面的NPE代码
config.repositorySource("store")
.usingClass(DiskSource.class)
.setProperty("repositoryRootPath", "c:/x/repo1")
.setProperty("defaultWorkspaceName","default");
config.repository("content")
.setOption(JcrRepository.Option.USE_ANONYMOUS_ACCESS_ON_FAILED_LOGIN, "true")
.setSource("store");
Session session = engine.getRepository("content").login("default");是否可以将自定义身份验证器添加到JcrConfiguration?
发布于 2012-10-01 20:04:22
配置ModeShape引擎的正确方法是使用JcrConfiguration对象,如here所述。这似乎就是你正在做的,所以这部分是正确的。
一旦你创建了你的配置,你可以检查它是否有问题:
if ( !configuration.getProblems().isEmpty() ) {
for ( Problem problem : configuration.getProblems() ) {
// Report these problems!
}
}假设没有问题,然后可以使用您的配置创建一个新的JcrEngine实例(请参阅documentation):
JcrConfiguration config = ...
JcrEngine engine = config.build();
engine.start();然后,根据存储库的名称查找存储库,并使用JCR API登录:
javax.jcr.Repository repository = engine.getRepository("Name of repository");
Credentials credentials = ...; // JCR credentials
String workspaceName = ...; // Name of repository workspace
Session session = repository.login(credentials,workspaceName);https://stackoverflow.com/questions/12668604
复制相似问题