Index: src/main/java/org/apache/jackrabbit/api/jsr283/RepositoryFactory.java
===================================================================
--- src/main/java/org/apache/jackrabbit/api/jsr283/RepositoryFactory.java (revision 0)
+++ src/main/java/org/apache/jackrabbit/api/jsr283/RepositoryFactory.java (revision 0)
@@ -0,0 +1,183 @@
+/*
+ * 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.api.jsr283;
+
+import javax.imageio.spi.ServiceRegistry;
+import javax.jcr.Repository;
+import javax.jcr.RepositoryException;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Map;
+
+/**
+ * RepositoryFactory is a factory class for Repository
+ * implementations.
+ *
+ * Parameters are passed to the connect and
+ * getRepository methods
+ * in a Map of key/value pairs. The keys are not
+ * specified by JCR and will be implementation specific. However,
+ * vendors should use keys that are namespace qualified in the
+ * Java package style to distinguish their key names. For example
+ * an address parameter might be com.vendor.address.
+ *
+ *
+ * Map parameters = new HashMap();
+ * parameters.put("com.vendor.address", "vendor://localhost:9999/repo");
+ * Repository repo = RepositoryFactory.getRepository(parameters);
+ *
+ *
+ * Get a default repository available in this environment:
+ *
+ *
+ * Repository repo = RepositoryFactory.getRepository();
+ *
+ *
+ * Manually instantiate a specific repository factory and connect to the
+ * repository:
+ *
+ *
+ * Map parameters = new HashMap();
+ * parameters.put("com.vendor.address", "vendor://localhost:9999/repo");
+ * RepositoryFactory factory = new com.vendor.RepositoryFactory();
+ * Repository repo = factory.connect(parameters);
+ *
+ *
+ *
+ * @since JCR 2.0
+ */
+public abstract class RepositoryFactory {
+
+ /**
+ * Attempts to establish a connection to a repository described by the given
+ * parameters.
+ *
+ *
+ * Parameters are passed in a Map of key/value pairs.
+ * The keys are not specified by JCR and will be implementation specific.
+ * However, vendors should use keys that are namespace qualified in the
+ * Java package style to distinguish their key names. For example
+ * an address parameter might be com.vendor.address.
+ *
+ * The implementation should return null if it does
+ * not understand the given parameters. The implementation may also return
+ * null if a default repository instance is requested
+ * (indicated by null parameters) and this factory
+ * is not able to identify a default repository.
+ * An implementation should throw an RepositoryException if it
+ * is the right factory but has trouble connecting to the repository.
+ *
+ * An implementation of this method must be thread-safe. + *
+ * + * @param parameters map of arbitrary string key/value pairs as repository + * arguments ornull if none are provided and
+ * a client wishes to connect to a default repository.
+ * @return a repository instance or null if this implementation
+ * does not understand the passed properties.
+ * @throws RepositoryException if an error occurs while connecting to the
+ * repository.
+ * @see RepositoryFactory#getRepository(java.util.Map)
+ */
+ public abstract Repository connect(Map parameters)
+ throws RepositoryException;
+
+ /**
+ * Attempts to establish a connection to a repository using the given
+ * parameters.
+ *
+ * Parameters are passed in a Map of key/value pairs.
+ * The keys are not specified by JCR and will be implementation specific.
+ * However, vendors should use keys that are namespace qualified in the
+ * Java package style to distinguish their key names. For example
+ * an address parameter might be com.vendor.address.
+ *
null if none are provided and
+ * a client wishes to connect to a default repository.
+ * @return a repository instance.
+ * @throws RepositoryException if getRepository fails or if no suitable
+ * repository is found.
+ */
+ public static Repository getRepository(Map parameters)
+ throws RepositoryException {
+ parameters = Collections.unmodifiableMap(parameters);
+ Iterator it = ServiceRegistry.lookupProviders(RepositoryFactory.class);
+ while (it.hasNext()) {
+ RepositoryFactory factory = (RepositoryFactory) it.next();
+ Repository repo = factory.connect(parameters);
+ if (repo != null) {
+ return repo;
+ }
+ }
+ throw new RepositoryException("No suitable Repository found");
+ }
+
+ /**
+ * Returns the first default Repository returned by a RepositoryFactory.
+ *
+ * @return a default repository instance.
+ * @throws RepositoryException if no factory returned a default repository
+ * or if an error occurs.
+ */
+ public static Repository getRepository() throws RepositoryException {
+ Iterator it = ServiceRegistry.lookupProviders(RepositoryFactory.class);
+ while (it.hasNext()) {
+ RepositoryFactory factory = (RepositoryFactory) it.next();
+ Repository repo = factory.connect(null);
+ if (repo != null) {
+ return repo;
+ }
+ }
+ throw new RepositoryException("No default Repository found");
+ }
+}
\ No newline at end of file
Property changes on: src\main\java\org\apache\jackrabbit\api\jsr283\RepositoryFactory.java
___________________________________________________________________
Added: svn:eol-style
+ native