You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by an...@apache.org on 2009/06/16 13:52:14 UTC
svn commit: r785169 - in /jackrabbit/trunk: ./ jackrabbit-jcr-client/
jackrabbit-jcr-client/src/ jackrabbit-jcr-client/src/main/
jackrabbit-jcr-client/src/main/java/ jackrabbit-jcr-client/src/main/java/org/
jackrabbit-jcr-client/src/main/java/org/apach...
Author: angela
Date: Tue Jun 16 11:52:13 2009
New Revision: 785169
URL: http://svn.apache.org/viewvc?rev=785169&view=rev
Log:
JCR-2041: Create Jcr-Client Module
Added:
jackrabbit/trunk/jackrabbit-jcr-client/ (with props)
jackrabbit/trunk/jackrabbit-jcr-client/README.txt
jackrabbit/trunk/jackrabbit-jcr-client/pom.xml
jackrabbit/trunk/jackrabbit-jcr-client/src/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/AbstractRepositoryConfig.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/RepositoryConfigImpl.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/RepositoryConfigImpl.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/RepositoryConfigImpl.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/RepositoryConfigImpl.java
jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/
jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
jackrabbit/trunk/jackrabbit-jcr-client/src/test/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java
Modified:
jackrabbit/trunk/pom.xml
Propchange: jackrabbit/trunk/jackrabbit-jcr-client/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jun 16 11:52:13 2009
@@ -0,0 +1,5 @@
+*.iml
+*.ipr
+*.iws
+target
+.*
Added: jackrabbit/trunk/jackrabbit-jcr-client/README.txt
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/README.txt?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/README.txt (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/README.txt Tue Jun 16 11:52:13 2009
@@ -0,0 +1,6 @@
+=================================
+Welcome to Jackrabbit JCR Client
+=================================
+
+This is the Jackrabbit JCR Client component of the Apache Jackrabbit project.
+
Added: jackrabbit/trunk/jackrabbit-jcr-client/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/pom.xml?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/pom.xml (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/pom.xml Tue Jun 16 11:52:13 2009
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ 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.
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+ http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <!-- ====================================================================== -->
+ <!-- P R O J E C T D E S C R I P T I O N -->
+ <!-- ====================================================================== -->
+ <parent>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-parent</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <relativePath>../jackrabbit-parent/pom.xml</relativePath>
+ </parent>
+ <artifactId>jackrabbit-jcr-client</artifactId>
+ <name>Jackrabbit JCR Client</name>
+
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-client
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/jackrabbit/trunk/jackrabbit-jcr-client
+ </developerConnection>
+ <url>http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client</url>
+ </scm>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <configuration>
+ <skip>true</skip>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ <forkMode>once</forkMode>
+ <argLine>-Xmx128m -enableassertions</argLine>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.jcr</groupId>
+ <artifactId>jcr</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-jcr2spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <classifier></classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-spi</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <classifier></classifier>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-spi-commons</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-spi2jcr</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.jackrabbit</groupId>
+ <artifactId>jackrabbit-spi2dav</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/AbstractRepositoryConfig.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/AbstractRepositoryConfig.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/AbstractRepositoryConfig.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/AbstractRepositoryConfig.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,152 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+
+import java.util.Map;
+
+/** <code>AbstractRepositoryConfig</code>... */
+public abstract class AbstractRepositoryConfig implements RepositoryConfig {
+
+ private static Logger log = LoggerFactory.getLogger(AbstractRepositoryConfig.class);
+
+ public static final String REPOSITORY_ITEM_CACHE_SIZE = "org.apache.jackrabbit.repository.itemCacheSize";
+ public static final String REPOSITORY_CACHEBEHAVIOUR = "org.apache.jackrabbit.repository.cacheBehaviour";
+ public static final String REPOSITORY_POLL_TIMEOUT = "org.apache.jackrabbit.repository.pollTimeout";
+
+ public static final int DEFAULT_ITEM_CACHE_SIZE = 5000;
+ public static final int DEFAULT_POLL_TIMEOUT = 1000; // ms
+
+ private final CacheBehaviour cacheBehaviour;
+ private final int itemCacheSize;
+ private final int pollTimeout;
+
+ /**
+ * Create a new <code>AbstractRepositoryConfig</code>.
+ *
+ * @param parameters Map of parameters used to create the RepositoryConfiguration.
+ * The following parameters are respected:
+ * <ul>
+ * <li>{@link #REPOSITORY_CACHEBEHAVIOUR}</li>
+ * <li>{@link #REPOSITORY_ITEM_CACHE_SIZE}</li>
+ * <li>{@link #REPOSITORY_POLL_TIMEOUT}</li>
+ * </ul>
+ * Any of the parameters can be omitted in which case the default values
+ * are used:
+ * <ul>
+ * <li>CacheBehaviour: {@link CacheBehaviour#INVALIDATE}</li>
+ * <li>item cache size: {@link #DEFAULT_ITEM_CACHE_SIZE}</li>
+ * <li>poll time out: {@link #DEFAULT_POLL_TIMEOUT}.</li>
+ * </ul>
+ */
+ protected AbstractRepositoryConfig(Map parameters) {
+ if (parameters == null) {
+ cacheBehaviour = CacheBehaviour.INVALIDATE;
+ itemCacheSize = DEFAULT_ITEM_CACHE_SIZE;
+ pollTimeout = DEFAULT_POLL_TIMEOUT;
+ } else {
+ int cacheSize = AbstractRepositoryConfig.DEFAULT_ITEM_CACHE_SIZE;
+ Object param = parameters.get(REPOSITORY_ITEM_CACHE_SIZE);
+ if (param != null) {
+ if (param instanceof Integer) {
+ cacheSize = ((Integer) param).intValue();
+ } else {
+ try {
+ cacheSize = Integer.parseInt(param.toString());
+ } catch (NumberFormatException e) {
+ // ignore.
+ }
+ }
+ }
+
+ CacheBehaviour cacheBehaviour = CacheBehaviour.INVALIDATE;
+ param = parameters.get(REPOSITORY_CACHEBEHAVIOUR);
+ if (param != null && param instanceof CacheBehaviour) {
+ cacheBehaviour = (CacheBehaviour) param;
+ }
+
+ int pollTimeout = AbstractRepositoryConfig.DEFAULT_POLL_TIMEOUT;
+ param = parameters.get(REPOSITORY_POLL_TIMEOUT);
+ if (param != null) {
+ if (param instanceof Integer) {
+ pollTimeout = ((Integer) param).intValue();
+ } else {
+ try {
+ pollTimeout = Integer.parseInt(param.toString());
+ } catch (NumberFormatException e) {
+ // ignore.
+ }
+ }
+ }
+ this.cacheBehaviour = cacheBehaviour;
+ this.itemCacheSize = cacheSize;
+ this.pollTimeout = pollTimeout;
+ }
+ }
+
+ /**
+ * Create a new <code>AbstractRepositoryConfig</code>.
+ *
+ * @param cacheBehaviour The desired cache behaviour. Either
+ * {@link CacheBehaviour#INVALIDATE} or {@link CacheBehaviour#OBSERVATION}.
+ * @param itemCacheSize Integer defining the size of the item cache.
+ * @param pollTimeout Integer defining the poll timeout.
+ */
+ protected AbstractRepositoryConfig(CacheBehaviour cacheBehaviour, int itemCacheSize, int pollTimeout) {
+ this.cacheBehaviour = cacheBehaviour;
+ this.itemCacheSize = itemCacheSize;
+ this.pollTimeout = pollTimeout;
+ }
+
+ /**
+ * Same as {@link #AbstractRepositoryConfig(CacheBehaviour, int, int)} where
+ * <pre>
+ * CacheBehaviour is {@link CacheBehaviour#INVALIDATE},
+ * item cache size is {@link #DEFAULT_ITEM_CACHE_SIZE} and
+ * poll time out is {@link #DEFAULT_POLL_TIMEOUT}.
+ * </pre>
+ */
+ protected AbstractRepositoryConfig() {
+ this(CacheBehaviour.INVALIDATE, DEFAULT_ITEM_CACHE_SIZE, DEFAULT_POLL_TIMEOUT);
+ }
+
+ //---------------------------------------------------< RepositoryConfig >---
+ /**
+ * @see RepositoryConfig#getCacheBehaviour()
+ */
+ public CacheBehaviour getCacheBehaviour() {
+ return cacheBehaviour;
+ }
+
+ /**
+ * @see RepositoryConfig#getItemCacheSize()
+ */
+ public int getItemCacheSize() {
+ return itemCacheSize;
+ }
+
+ /**
+ * @see RepositoryConfig#getPollTimeout()
+ */
+ public int getPollTimeout() {
+ return pollTimeout;
+ }
+}
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/RepositoryFactoryImpl.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client;
+
+import org.apache.jackrabbit.jcr2spi.RepositoryImpl;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+import javax.jcr.RepositoryFactory;
+import java.util.Map;
+
+/**
+ * <code>RepositoryFactoryImpl</code>...
+ */
+public class RepositoryFactoryImpl implements RepositoryFactory {
+
+ private static Logger log = LoggerFactory.getLogger(RepositoryFactoryImpl.class);
+
+ public static final String REPOSITORY_CONFIG = "org.apache.jackrabbit.repository.config";
+
+ //--------------------------------------------------< RepositoryFactory >---
+ /**
+ * Creates a JCR repository from the given <code>parameters</code>.
+ * If the <code>parameters</code> map is <code>null</code> the default
+ * repository (i.e. JCR2SPI repository on top of SPI2DAVex) is returned.<p/>
+ * If the <code>parameters</code> map contains a {@link #REPOSITORY_CONFIG}
+ * entry it's value is expected to be a implementation of
+ * {@link org.apache.jackrabbit.jcr2spi.config.RepositoryConfig} and the
+ * repository will be created based on this configuration.<p/>
+ * If the <code>parameters</code> map does not contain a {@link #REPOSITORY_CONFIG}
+ * entry or if the corresponding value isn't a valid <code>RepositoryConfig</code>
+ * an attempt is made to create a
+ * {@link org.apache.jackrabbit.jcr2spi.config.RepositoryConfig} for any of
+ * the known SPI implementations:
+ * <ul>
+ * <li>SPI2DAVex (see jackrabbit-spi2dav module)</li>
+ * <li>SPI2DAV (see jackrabbit-spi2dav module)</li>
+ * <li>SPI2JCR (see jackrabbit-spi2jcr module)</li>
+ * </ul>
+ * NOTE: If the <code>parameters</code> map contains an
+ * {@link org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl#PARAM_LOG_WRITER_PROVIDER PARAM_LOG_WRITER_PROVIDER}
+ * entry the {@link org.apache.jackrabbit.spi.RepositoryService RepositoryService} obtained
+ * from the configuration is wrapped by a SPI logger. See the
+ * {@link org.apache.jackrabbit.spi.commons.logging.SpiLoggerFactory SpiLoggerFactory}
+ * for details.
+ *
+ * @see RepositoryFactory#getRepository(java.util.Map)
+ */
+ public Repository getRepository(Map parameters) throws RepositoryException {
+ RepositoryConfig config = null;
+ if (parameters == null) {
+ config = org.apache.jackrabbit.client.spi2dav.RepositoryConfigImpl.create((Map) null);
+ } else {
+ Object param = parameters.get(REPOSITORY_CONFIG);
+ if (param != null && param instanceof RepositoryConfig) {
+ config = (RepositoryConfig) param;
+ }
+ if (config == null) {
+ config = org.apache.jackrabbit.client.spi2dav.RepositoryConfigImpl.create(parameters);
+ if (config == null) {
+ config = org.apache.jackrabbit.client.spi2dav.RepositoryConfigImpl.create(parameters);
+ }
+ if (config == null) {
+ config = org.apache.jackrabbit.client.spi2jcr.RepositoryConfigImpl.create(parameters);
+ }
+ }
+ }
+
+ if (config != null) {
+ config = org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl.create(config, parameters);
+ return RepositoryImpl.create(config);
+ } else {
+ log.debug("Unable to create Repository: Unknown parameters.");
+ return null;
+ }
+ }
+}
\ No newline at end of file
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/RepositoryConfigImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/RepositoryConfigImpl.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/RepositoryConfigImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2dav/RepositoryConfigImpl.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,149 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client.spi2dav;
+
+import org.apache.jackrabbit.client.AbstractRepositoryConfig;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.identifier.IdFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.NameFactoryImpl;
+import org.apache.jackrabbit.spi.commons.name.PathFactoryImpl;
+import org.apache.jackrabbit.spi.commons.value.QValueFactoryImpl;
+import org.apache.jackrabbit.spi2dav.RepositoryServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * <code>RepositoryFactoryImpl</code>...
+ */
+public class RepositoryConfigImpl extends AbstractRepositoryConfig {
+
+ private static Logger log = LoggerFactory.getLogger(org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl.class);
+
+ /**
+ * Mandatory configuration parameter: It's value is expected to specify the
+ * URI of the JCR server implementation.
+ *
+ * @see org.apache.jackrabbit.webdav.jcr.JCRWebdavServerServlet
+ */
+ public static final String REPOSITORY_SPI2DAV_URI = "org.apache.jackrabbit.repository.spi2dav.uri";
+ /**
+ * Optional configuration parameter: It's value is expected to be an instance
+ * of {@link IdFactory}. If missing {@link IdFactoryImpl} is used.
+ */
+ public static final String REPOSITORY_SPI2DAV_IDFACTORY = "org.apache.jackrabbit.repository.spi2dav.idfactory";
+ /**
+ * Optional configuration parameter: It's value is expected to be an instance
+ * of {@link NameFactory}. If missing {@link NameFactoryImpl} is used.
+ */
+ public static final String REPOSITORY_SPI2DAV_NAMEFACTORY = "org.apache.jackrabbit.repository.spi2dav.namefactory";
+ /**
+ * Optional configuration parameter: It's value is expected to be an instance
+ * of {@link PathFactory}. If missing {@link PathFactoryImpl} is used.
+ */
+ public static final String REPOSITORY_SPI2DAV_PATHFACTORY = "org.apache.jackrabbit.repository.spi2dav.pathfactory";
+ /**
+ * Optional configuration parameter: It's value is expected to be an instance
+ * of {@link QValueFactory}. If missing {@link QValueFactoryImpl} is used.
+ */
+ public static final String REPOSITORY_SPI2DAV_VALUEFACTORY = "org.apache.jackrabbit.repository.spi2dav.valuefactory";
+
+ private final RepositoryService service;
+
+ public static RepositoryConfig create(Map parameters) {
+ if (!parameters.containsKey(REPOSITORY_SPI2DAV_URI)) {
+ return null;
+ }
+
+ String uri = parameters.get(REPOSITORY_SPI2DAV_URI).toString();
+ try {
+ return new RepositoryConfigImpl(uri, parameters);
+ } catch (RepositoryException e) {
+ log.warn(e.getMessage());
+ return null;
+ }
+ }
+
+ public static RepositoryConfig create(String uri) {
+ if (uri == null) {
+ return null;
+ }
+ try {
+ return new RepositoryConfigImpl(uri);
+ } catch (RepositoryException e) {
+ log.warn(e.getMessage());
+ return null;
+ }
+ }
+
+ private RepositoryConfigImpl(String uri) throws RepositoryException {
+ super();
+ service = createService(uri, Collections.EMPTY_MAP);
+ }
+
+ private RepositoryConfigImpl(String uri, Map parameters) throws RepositoryException {
+ super(parameters);
+ service = createService(uri, parameters);
+ }
+
+ private static RepositoryService createService(String uri, Map parameters) throws RepositoryException {
+ IdFactory idFactory;
+ Object param = parameters.get(REPOSITORY_SPI2DAV_IDFACTORY);
+ if (param != null && param instanceof IdFactory) {
+ idFactory = (IdFactory) param;
+ } else {
+ idFactory = IdFactoryImpl.getInstance();
+ }
+
+ NameFactory nameFactory;
+ param = parameters.get(REPOSITORY_SPI2DAV_NAMEFACTORY);
+ if (param != null && param instanceof NameFactory) {
+ nameFactory = (NameFactory) param;
+ } else {
+ nameFactory = NameFactoryImpl.getInstance();
+ }
+
+ PathFactory pathFactory;
+ param = parameters.get(REPOSITORY_SPI2DAV_PATHFACTORY);
+ if (param != null && param instanceof PathFactory) {
+ pathFactory = (PathFactory) param;
+ } else {
+ pathFactory = PathFactoryImpl.getInstance();
+ }
+
+ QValueFactory vFactory;
+ param = parameters.get(REPOSITORY_SPI2DAV_VALUEFACTORY);
+ if (param != null && param instanceof QValueFactory) {
+ vFactory = (QValueFactory) param;
+ } else {
+ vFactory = QValueFactoryImpl.getInstance();
+ }
+ return new RepositoryServiceImpl(uri, idFactory, nameFactory, pathFactory, vFactory);
+ }
+
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+}
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/RepositoryConfigImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/RepositoryConfigImpl.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/RepositoryConfigImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2davex/RepositoryConfigImpl.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,147 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client.spi2davex;
+
+import org.apache.jackrabbit.jcr2spi.config.CacheBehaviour;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi2davex.RepositoryServiceImpl;
+import org.apache.jackrabbit.spi2davex.BatchReadConfig;
+import org.apache.jackrabbit.spi.commons.conversion.PathResolver;
+import org.apache.jackrabbit.client.AbstractRepositoryConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.NamespaceException;
+import java.util.Map;
+import java.util.Collections;
+
+/**
+ * <code>RepositoryFactoryImpl</code>...
+ */
+public class RepositoryConfigImpl extends AbstractRepositoryConfig {
+
+ private static Logger log = LoggerFactory.getLogger(org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl.class);
+
+ /**
+ * Default URI for the {@link #REPOSITORY_SPI2DAVEX_URI} configuration
+ * parameter.
+ */
+ public static String DEFAULT_URI = "http://localhost:8080/jackrabbit/server";
+
+ /**
+ * Mandatory configuration parameter: It's value is expected to specify the
+ * URI of the JCR server implementation. {@link #DEFAULT_URI} is used as
+ * fallback if no parameters or uri has been specified and the uri could not
+ * been retrieved from system props either.
+ *
+ * @see org.apache.jackrabbit.server.remoting.davex.JcrRemotingServlet
+ */
+ public static final String REPOSITORY_SPI2DAVEX_URI = "org.apache.jackrabbit.repository.spi2davex.uri";
+ /**
+ * Optional batch read configuration parameter: If present it's value is
+ * expected to be an instance of {@link BatchReadConfig}
+ */
+ public static final String REPOSITORY_SPI2DAVEX_BATCHREADCONFIG = "org.apache.jackrabbit.repository.spi2dav.batchreadconfig";
+
+ private final RepositoryService service;
+
+ public static RepositoryConfig create(Map parameters) {
+ String uri = getURI(parameters);
+ if (uri == null) {
+ return null;
+ }
+ try {
+ return new RepositoryConfigImpl(uri, parameters);
+ } catch (RepositoryException e) {
+ log.warn(e.getMessage());
+ return null;
+ }
+ }
+
+ public static RepositoryConfig create(String uri) {
+ if (uri == null) {
+ uri = getURI(null);
+ }
+ if (uri == null) {
+ return null;
+ }
+ try {
+ return new RepositoryConfigImpl(uri);
+ } catch (RepositoryException e) {
+ log.warn(e.getMessage());
+ return null;
+ }
+ }
+
+ private static String getURI(Map parameters) {
+ String uri;
+ if (parameters != null) {
+ uri = (parameters.containsKey(REPOSITORY_SPI2DAVEX_URI) ? parameters.get(REPOSITORY_SPI2DAVEX_URI).toString() : null);
+ } else {
+ uri = System.getProperty(REPOSITORY_SPI2DAVEX_URI);
+ if (uri == null) {
+ log.debug("Missing repository uri -> using default " + DEFAULT_URI);
+ uri = DEFAULT_URI;
+ }
+ }
+ return uri;
+ }
+
+ private RepositoryConfigImpl(String uri) throws RepositoryException {
+ super();
+ service = createService(uri, Collections.EMPTY_MAP);
+ }
+
+ private RepositoryConfigImpl(String uri, Map parameters) throws RepositoryException {
+ super(parameters);
+ service = createService(uri, parameters);
+ }
+
+ public RepositoryConfigImpl(String uri, CacheBehaviour cacheBehaviour, int itemCacheSize) throws RepositoryException {
+ this(uri, cacheBehaviour, itemCacheSize, DEFAULT_POLL_TIMEOUT);
+ }
+
+ public RepositoryConfigImpl(String uri, CacheBehaviour cacheBehaviour, int itemCacheSize, int pollTimeout) throws RepositoryException {
+ super(cacheBehaviour, itemCacheSize, pollTimeout);
+ service = createService(uri, Collections.EMPTY_MAP);
+ }
+
+ private static RepositoryService createService(String uri, Map parameters) throws RepositoryException {
+ BatchReadConfig brc = null;
+ if (parameters != null) {
+ Object param = parameters.get(REPOSITORY_SPI2DAVEX_BATCHREADCONFIG);
+ if (param != null && param instanceof BatchReadConfig) {
+ brc = (BatchReadConfig) param;
+ }
+ }
+ if (brc == null) {
+ brc = new BatchReadConfig() {
+ public int getDepth(Path path, PathResolver pathResolver) throws NamespaceException {
+ return 4;
+ }
+ };
+ }
+ return new RepositoryServiceImpl(uri, brc);
+ }
+
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+}
\ No newline at end of file
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/RepositoryConfigImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/RepositoryConfigImpl.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/RepositoryConfigImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spi2jcr/RepositoryConfigImpl.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client.spi2jcr;
+
+import org.apache.jackrabbit.client.AbstractRepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.spi2jcr.BatchReadConfig;
+import org.apache.jackrabbit.spi2jcr.RepositoryServiceImpl;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Repository;
+import java.util.Map;
+
+/**
+ * <code>RepositoryConfigImpl</code>...
+ */
+public class RepositoryConfigImpl extends AbstractRepositoryConfig {
+
+ private static Logger log = LoggerFactory.getLogger(org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl.class);
+
+ /**
+ * Mandatory repository parameter: expects value to be an instance of {@link javax.jcr.Repository}.
+ */
+ public static final String PARAM_REPOSITORY = "org.apache.jackrabbit.spi2jcr.repository";
+ /**
+ * Optional batch read config paramater. If it is present the value is
+ * expected to be an instance of {@link org.apache.jackrabbit.spi2jcr.BatchReadConfig}.
+ */
+ public static final String PARAM_BATCH_READ_CONFIG = "org.apache.jackrabbit.spi2jcr.batchReadConfig";
+
+ private final RepositoryService service;
+
+ public static RepositoryConfig create(Map parameters) {
+ if (!parameters.containsKey(PARAM_REPOSITORY)) {
+ return null;
+ }
+ try {
+ return new RepositoryConfigImpl(parameters);
+ } catch (RepositoryException e) {
+ log.warn(e.getMessage());
+ return null;
+ }
+ }
+
+ private RepositoryConfigImpl(Map params) throws RepositoryException {
+ super(params);
+ Object repo = params.get(PARAM_REPOSITORY);
+ if (repo == null || !(repo instanceof Repository)) {
+ throw new RepositoryException();
+ }
+ BatchReadConfig brConfig = new BatchReadConfig();
+ Object obj = params.get(PARAM_BATCH_READ_CONFIG);
+ if (obj != null && obj instanceof BatchReadConfig) {
+ brConfig = (BatchReadConfig) obj;
+ }
+ service = new RepositoryServiceImpl((Repository) repo, brConfig);
+ }
+
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+}
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/RepositoryConfigImpl.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/RepositoryConfigImpl.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/RepositoryConfigImpl.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/java/org/apache/jackrabbit/client/spilogger/RepositoryConfigImpl.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,54 @@
+package org.apache.jackrabbit.client.spilogger;
+
+import org.apache.jackrabbit.client.AbstractRepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.commons.logging.SpiLoggerFactory;
+import org.apache.jackrabbit.spi.commons.logging.LogWriterProvider;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+
+import javax.jcr.RepositoryException;
+import java.util.Map;
+
+/**
+ * <code>RepositoryConfigImpl</code>...
+ */
+public class RepositoryConfigImpl extends AbstractRepositoryConfig {
+
+ /**
+ * LogWriterProvider configuration parameter: If the parameter is present the
+ * <code>RepositoryService</code> defined by the specified
+ * <code>RepositoryConfig</code> will be wrapped by calling
+ * {@link SpiLoggerFactory#create(org.apache.jackrabbit.spi.RepositoryService, org.apache.jackrabbit.spi.commons.logging.LogWriterProvider) }
+ * if the param value is an instance of <code>LogWriterProvider</code> or
+ * {@link SpiLoggerFactory#create(org.apache.jackrabbit.spi.RepositoryService)}
+ * otherwise.
+ *
+ * @see SpiLoggerFactory#create(org.apache.jackrabbit.spi.RepositoryService)
+ * @see SpiLoggerFactory#create(org.apache.jackrabbit.spi.RepositoryService, org.apache.jackrabbit.spi.commons.logging.LogWriterProvider)
+ */
+ public static final String PARAM_LOG_WRITER_PROVIDER = "org.apache.jackrabbit.repository.spi.logging.logwriterprovider";
+
+ private final RepositoryService service;
+
+ public static RepositoryConfig create(RepositoryConfig config, Map params) throws RepositoryException {
+ if (config == null || params == null || !params.containsKey(PARAM_LOG_WRITER_PROVIDER)) {
+ return config;
+ } else {
+ return new RepositoryConfigImpl(config, params);
+ }
+ }
+
+ private RepositoryConfigImpl(RepositoryConfig config, Map params) throws RepositoryException {
+ super(config.getCacheBehaviour(), config.getItemCacheSize(), config.getPollTimeout());
+ Object lwProvider = params.get(PARAM_LOG_WRITER_PROVIDER);
+ if (lwProvider == null || !(lwProvider instanceof LogWriterProvider)) {
+ service = SpiLoggerFactory.create(config.getRepositoryService());
+ } else {
+ service = SpiLoggerFactory.create(config.getRepositoryService(), (LogWriterProvider) lwProvider);
+ }
+ }
+
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+}
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/main/resources/META-INF/services/javax.jcr.RepositoryFactory Tue Jun 16 11:52:13 2009
@@ -0,0 +1,21 @@
+# 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.
+
+#
+# This file lists the repository factory implementation for jackrabbit-jcr-client
+#
+
+org.apache.jackrabbit.client.RepositoryFactoryImpl
+
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryImplTest.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,388 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client;
+
+import junit.framework.TestCase;
+import org.apache.jackrabbit.jcr2spi.config.RepositoryConfig;
+import org.apache.jackrabbit.spi.RepositoryService;
+import org.apache.jackrabbit.spi.IdFactory;
+import org.apache.jackrabbit.spi.NameFactory;
+import org.apache.jackrabbit.spi.PathFactory;
+import org.apache.jackrabbit.spi.QValueFactory;
+import org.apache.jackrabbit.spi.SessionInfo;
+import org.apache.jackrabbit.spi.ItemId;
+import org.apache.jackrabbit.spi.QNodeDefinition;
+import org.apache.jackrabbit.spi.NodeId;
+import org.apache.jackrabbit.spi.QPropertyDefinition;
+import org.apache.jackrabbit.spi.PropertyId;
+import org.apache.jackrabbit.spi.NodeInfo;
+import org.apache.jackrabbit.spi.PropertyInfo;
+import org.apache.jackrabbit.spi.Batch;
+import org.apache.jackrabbit.spi.Name;
+import org.apache.jackrabbit.spi.LockInfo;
+import org.apache.jackrabbit.spi.QueryInfo;
+import org.apache.jackrabbit.spi.EventFilter;
+import org.apache.jackrabbit.spi.Path;
+import org.apache.jackrabbit.spi.Subscription;
+import org.apache.jackrabbit.spi.EventBundle;
+import org.apache.jackrabbit.spi.QValue;
+import org.apache.jackrabbit.spi.QNodeTypeDefinition;
+import org.apache.jackrabbit.spi.commons.logging.Slf4jLogWriterProvider;
+import org.apache.jackrabbit.client.spilogger.RepositoryConfigImpl;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Repository;
+import javax.jcr.Credentials;
+import javax.jcr.LoginException;
+import javax.jcr.NoSuchWorkspaceException;
+import javax.jcr.ItemNotFoundException;
+import javax.jcr.PathNotFoundException;
+import javax.jcr.ValueFormatException;
+import javax.jcr.AccessDeniedException;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import javax.jcr.ItemExistsException;
+import javax.jcr.InvalidItemStateException;
+import javax.jcr.ReferentialIntegrityException;
+import javax.jcr.MergeException;
+import javax.jcr.NamespaceException;
+import javax.jcr.RepositoryFactory;
+import javax.jcr.query.InvalidQueryException;
+import javax.jcr.lock.LockException;
+import javax.jcr.version.VersionException;
+import javax.jcr.nodetype.NoSuchNodeTypeException;
+import javax.jcr.nodetype.ConstraintViolationException;
+import javax.jcr.nodetype.InvalidNodeTypeDefinitionException;
+import javax.jcr.nodetype.NodeTypeExistsException;
+import java.util.Map;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ArrayList;
+import java.io.InputStream;
+
+/**
+ * <code>RepositoryFactoryImplTest</code>...
+ */
+public class RepositoryFactoryImplTest extends TestCase {
+
+ private final RepositoryFactory factory = new RepositoryFactoryImpl();
+ private final RepositoryService service = new RepositoryServiceImpl();
+
+ public void testGetDefaultRepository() throws RepositoryException {
+ try {
+ Repository repo = factory.getRepository(null);
+ assertNotNull(repo);
+ } catch (RepositoryException e) {
+ // repository on top of spi2davex can only be initialized if the
+ // server is running. ok.
+ }
+
+ try {
+ System.setProperty(org.apache.jackrabbit.client.spi2davex.RepositoryConfigImpl.REPOSITORY_SPI2DAVEX_URI, org.apache.jackrabbit.client.spi2davex.RepositoryConfigImpl.DEFAULT_URI);
+ Repository repo = factory.getRepository(null);
+ assertNotNull(repo);
+ } catch (RepositoryException e) {
+ // repository on top of spi2davex can only be initialized if the
+ // server is running. ok.
+ }
+ }
+
+ public void testGetRepository() throws RepositoryException {
+ RepositoryConfig config = new AbstractRepositoryConfig() {
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+ };
+
+ Repository repo = factory.getRepository(Collections.singletonMap(RepositoryFactoryImpl.REPOSITORY_CONFIG, config));
+ assertNotNull(repo);
+ }
+
+ public void testGetRepositoryWithLogger() throws RepositoryException {
+ RepositoryConfig config = new AbstractRepositoryConfig() {
+ public RepositoryService getRepositoryService() throws RepositoryException {
+ return service;
+ }
+ };
+
+ List lwprovider = new ArrayList();
+ lwprovider.add(null);
+ lwprovider.add(new Boolean(true));
+ lwprovider.add(new Slf4jLogWriterProvider());
+
+ Map params = new HashMap();
+ params.put(RepositoryFactoryImpl.REPOSITORY_CONFIG, config);
+
+ for (int i = 0; i < lwprovider.size(); i++) {
+ params.put(RepositoryConfigImpl.PARAM_LOG_WRITER_PROVIDER, lwprovider.get(i));
+ Repository repo = factory.getRepository(params);
+ assertNotNull(repo);
+ }
+ }
+
+ public void testGetRepositoryUnknownParams() throws RepositoryException {
+ Repository repo = factory.getRepository(Collections.EMPTY_MAP);
+ assertNull(repo);
+ }
+
+ //--------------------------------------------------------------------------
+ /**
+ * Dummy RepositoryService
+ */
+ private static final class RepositoryServiceImpl implements RepositoryService {
+
+ public IdFactory getIdFactory() throws RepositoryException {
+ return null;
+ }
+
+ public NameFactory getNameFactory() throws RepositoryException {
+ return null;
+ }
+
+ public PathFactory getPathFactory() throws RepositoryException {
+ return null;
+ }
+
+ public QValueFactory getQValueFactory() throws RepositoryException {
+ return null;
+ }
+
+ public Map getRepositoryDescriptors() throws RepositoryException {
+ return null;
+ }
+
+ public SessionInfo obtain(Credentials credentials, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ return null;
+ }
+
+ public SessionInfo obtain(SessionInfo sessionInfo, String workspaceName) throws LoginException, NoSuchWorkspaceException, RepositoryException {
+ return null;
+ }
+
+ public SessionInfo impersonate(SessionInfo sessionInfo, Credentials credentials) throws LoginException, RepositoryException {
+ return null;
+ }
+
+ public void dispose(SessionInfo sessionInfo) throws RepositoryException {
+ }
+
+ public String[] getWorkspaceNames(SessionInfo sessionInfo) throws RepositoryException {
+ return new String[0];
+ }
+
+ public boolean isGranted(SessionInfo sessionInfo, ItemId itemId, String[] actions) throws RepositoryException {
+ return false;
+ }
+
+ public QNodeDefinition getNodeDefinition(SessionInfo sessionInfo, NodeId nodeId) throws RepositoryException {
+ return null;
+ }
+
+ public QPropertyDefinition getPropertyDefinition(SessionInfo sessionInfo, PropertyId propertyId) throws RepositoryException {
+ return null;
+ }
+
+ public NodeInfo getNodeInfo(SessionInfo sessionInfo, NodeId nodeId) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ public Iterator getItemInfos(SessionInfo sessionInfo, NodeId nodeId) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ public Iterator getChildInfos(SessionInfo sessionInfo, NodeId parentId) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ public Iterator<PropertyId> getReferences(SessionInfo sessionInfo, NodeId nodeId, Name propertyName, boolean weakReferences) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ public PropertyInfo getPropertyInfo(SessionInfo sessionInfo, PropertyId propertyId) throws ItemNotFoundException, RepositoryException {
+ return null;
+ }
+
+ public Batch createBatch(SessionInfo sessionInfo, ItemId itemId) throws RepositoryException {
+ return null;
+ }
+
+ public void submit(Batch batch) throws PathNotFoundException, ItemNotFoundException, NoSuchNodeTypeException, ValueFormatException, VersionException, LockException, ConstraintViolationException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public void importXml(SessionInfo sessionInfo, NodeId parentId, InputStream xmlStream, int uuidBehaviour) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public void move(SessionInfo sessionInfo, NodeId srcNodeId, NodeId destParentNodeId, Name destName) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, AccessDeniedException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public void copy(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, Name destName) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public void update(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName) throws NoSuchWorkspaceException, AccessDeniedException, LockException, InvalidItemStateException, RepositoryException {
+ }
+
+ public void clone(SessionInfo sessionInfo, String srcWorkspaceName, NodeId srcNodeId, NodeId destParentNodeId, Name destName, boolean removeExisting) throws NoSuchWorkspaceException, ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public LockInfo getLockInfo(SessionInfo sessionInfo, NodeId nodeId) throws AccessDeniedException, RepositoryException {
+ return null;
+ }
+
+ public LockInfo lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep, boolean sessionScoped) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
+ return null;
+ }
+
+ public LockInfo lock(SessionInfo sessionInfo, NodeId nodeId, boolean deep, boolean sessionScoped, long timeoutHint, String ownerHint) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
+ return null;
+ }
+
+ public void refreshLock(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
+ }
+
+ public void unlock(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, LockException, AccessDeniedException, RepositoryException {
+ }
+
+ public NodeId checkin(SessionInfo sessionInfo, NodeId nodeId) throws VersionException, UnsupportedRepositoryOperationException, InvalidItemStateException, LockException, RepositoryException {
+ return null;
+ }
+
+ public void checkout(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, LockException, RepositoryException {
+ }
+
+ public NodeId checkpoint(SessionInfo sessionInfo, NodeId nodeId) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public void removeVersion(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId) throws ReferentialIntegrityException, AccessDeniedException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
+ }
+
+ public void restore(SessionInfo sessionInfo, NodeId nodeId, NodeId versionId, boolean removeExisting) throws VersionException, PathNotFoundException, ItemExistsException, UnsupportedRepositoryOperationException, LockException, InvalidItemStateException, RepositoryException {
+ }
+
+ public void restore(SessionInfo sessionInfo, NodeId[] versionIds, boolean removeExisting) throws ItemExistsException, UnsupportedRepositoryOperationException, VersionException, LockException, InvalidItemStateException, RepositoryException {
+ }
+
+ public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName, boolean bestEffort) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
+ return null;
+ }
+
+ public Iterator merge(SessionInfo sessionInfo, NodeId nodeId, String srcWorkspaceName, boolean bestEffort, boolean isShallow) throws NoSuchWorkspaceException, AccessDeniedException, MergeException, LockException, InvalidItemStateException, RepositoryException {
+ return null;
+ }
+
+ public void resolveMergeConflict(SessionInfo sessionInfo, NodeId nodeId, NodeId[] mergeFailedIds, NodeId[] predecessorIds) throws VersionException, InvalidItemStateException, UnsupportedRepositoryOperationException, RepositoryException {
+ }
+
+ public void addVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, Name label, boolean moveLabel) throws VersionException, RepositoryException {
+ }
+
+ public void removeVersionLabel(SessionInfo sessionInfo, NodeId versionHistoryId, NodeId versionId, Name label) throws VersionException, RepositoryException {
+ }
+
+ public NodeId createActivity(SessionInfo sessionInfo, String title) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public void removeActivity(SessionInfo sessionInfo, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+
+ }
+
+ public Iterator mergeActivity(SessionInfo sessionInfo, NodeId activityId) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public NodeId createConfiguration(SessionInfo sessionInfo, NodeId nodeId, NodeId baselineId) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public String[] getSupportedQueryLanguages(SessionInfo sessionInfo) throws RepositoryException {
+ return new String[0];
+ }
+
+ public void checkQueryStatement(SessionInfo sessionInfo, String statement, String language, Map namespaces) throws InvalidQueryException, RepositoryException {
+ }
+
+ public QueryInfo executeQuery(SessionInfo sessionInfo, String statement, String language, Map namespaces) throws RepositoryException {
+ return null;
+ }
+
+ public QueryInfo executeQuery(SessionInfo sessionInfo, String statement, String language, Map namespaces, long limit, long offset, Map<String, QValue> values) throws RepositoryException {
+ return null;
+ }
+
+ public EventFilter createEventFilter(SessionInfo sessionInfo, int eventTypes, Path absPath, boolean isDeep, String[] uuid, Name[] nodeTypeName, boolean noLocal) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public Subscription createSubscription(SessionInfo sessionInfo, EventFilter[] filters) throws UnsupportedRepositoryOperationException, RepositoryException {
+ return null;
+ }
+
+ public void updateEventFilters(Subscription subscription, EventFilter[] filters) throws RepositoryException {
+ }
+
+ public EventBundle[] getEvents(Subscription subscription, long timeout) throws RepositoryException, InterruptedException {
+ return new EventBundle[0];
+ }
+
+ public void dispose(Subscription subscription) throws RepositoryException {
+ }
+
+ public Map getRegisteredNamespaces(SessionInfo sessionInfo) throws RepositoryException {
+ return null;
+ }
+
+ public String getNamespaceURI(SessionInfo sessionInfo, String prefix) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ public String getNamespacePrefix(SessionInfo sessionInfo, String uri) throws NamespaceException, RepositoryException {
+ return null;
+ }
+
+ public void registerNamespace(SessionInfo sessionInfo, String prefix, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+ }
+
+ public void unregisterNamespace(SessionInfo sessionInfo, String uri) throws NamespaceException, UnsupportedRepositoryOperationException, AccessDeniedException, RepositoryException {
+ }
+
+ public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo) throws RepositoryException {
+ return null;
+ }
+
+ public Iterator getQNodeTypeDefinitions(SessionInfo sessionInfo, Name[] nodetypeNames) throws RepositoryException {
+ return null;
+ }
+
+ public void registerNodeTypes(SessionInfo sessionInfo, QNodeTypeDefinition[] nodeTypeDefinitions, boolean allowUpdate) throws InvalidNodeTypeDefinitionException, NodeTypeExistsException, UnsupportedRepositoryOperationException, RepositoryException {
+
+ }
+
+ public void unregisterNodeTypes(SessionInfo sessionInfo, Name[] nodeTypeNames) throws UnsupportedRepositoryOperationException, NoSuchNodeTypeException, RepositoryException {
+
+ }
+
+ public void createWorkspace(SessionInfo sessionInfo, String name, String srcWorkspaceName) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+
+ }
+
+ public void deleteWorkspace(SessionInfo sessionInfo, String name) throws AccessDeniedException, UnsupportedRepositoryOperationException, NoSuchWorkspaceException, RepositoryException {
+
+ }
+ }
+}
\ No newline at end of file
Added: jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java?rev=785169&view=auto
==============================================================================
--- jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java (added)
+++ jackrabbit/trunk/jackrabbit-jcr-client/src/test/java/org/apache/jackrabbit/client/RepositoryFactoryTest.java Tue Jun 16 11:52:13 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+package org.apache.jackrabbit.client;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import junit.framework.TestCase;
+
+import java.util.Iterator;
+
+import javax.jcr.RepositoryFactory;
+import javax.imageio.spi.ServiceRegistry;
+
+/**
+ * <code>RepositoryFactoryTest</code>...
+ */
+public class RepositoryFactoryTest extends TestCase {
+
+ /**
+ * logger instance
+ */
+ private static final Logger log = LoggerFactory.getLogger(RepositoryFactoryTest.class);
+
+ public void testGetFactory() {
+ Iterator it = ServiceRegistry.lookupProviders(RepositoryFactory.class);
+ if (it.hasNext()) {
+ RepositoryFactory rf = (RepositoryFactory) it.next();
+ assertTrue(rf instanceof RepositoryFactoryImpl);
+ } else {
+ fail();
+ }
+ }
+}
\ No newline at end of file
Modified: jackrabbit/trunk/pom.xml
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/pom.xml?rev=785169&r1=785168&r2=785169&view=diff
==============================================================================
--- jackrabbit/trunk/pom.xml (original)
+++ jackrabbit/trunk/pom.xml Tue Jun 16 11:52:13 2009
@@ -54,6 +54,7 @@
<module>jackrabbit-jcr2spi</module>
<module>jackrabbit-spi2jcr</module>
<module>jackrabbit-spi2dav</module>
+ <module>jackrabbit-jcr-client</module>
<module>jackrabbit-standalone</module>
</modules>