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,107 @@ +/* + * 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 java.util.Map; + +import javax.jcr.RepositoryException; +import javax.jcr.Repository; + +/** + * RepositoryFactory is a factory class for Repository + * implementations. + *

+ * A concrete implementation of this class must have a zero-argument public + * constructor. Repository factories may be installed in an instance of the Java + * platform as extensions, that is, jar files placed into any of the usual + * extension directories. Factories may also be made available by adding them to + * the applet or application class path or by some other platform-specific + * means. + *

+ * A repository factory implementation should support the Java Standard Edition + * Service Provider mechanism, that is, an implementation should include the + * file META-INF/services/javax.jcr.RepositoryFactory. This file + * contains the fully qualified name of the class that implements + * RepositoryFactory. + *

+ * Examples how to obtain repository instances + *

+ * Explicitly specifying the repository factory implementation: + * + *

+ *   Map parameters = new HashMap();
+ *   parameters.put("com.vendor.address", "vendor://localhost:9999/repo");
+ *   RepositoryFactory factory = (RepositoryFactory) Class.forName("com.vendor.RepositoryFactoryImpl");
+ *   Repository repo = factory.getRepository(parameters);
+ * 
+ * + *

+ * Using ServiceLoader from Java SE 6: + * + *

+ *   Map parameters = new HashMap();
+ *   parameters.put("com.vendor.address", "vendor://localhost:9999/repo");
+ *   Repository repo = null;
+ *   for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
+ *     repo = factory.getRepository(parameters);
+ *     if (repo != null) {
+ *       // factory accepted parameters
+ *       break;
+ *     }
+ *   }
+ * 
+ * Note: on Java SE prior to version 6, one may use the + * {@link javax.imageio.spi.ServiceRegistry ServiceRegistry} class to look up + * the available RepositoryFactory implementations. + * + * @since JCR 2.0 + */ +public interface RepositoryFactory { + + /** + * Attempts to establish a connection to a repository using the given + * parameters. + *

+ * Parameters are passed in a Map of String + * key/value pairs. The keys are not specified by JCR and are 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 must 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 or null 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 parameters. + * @throws RepositoryException if getRepository fails or if no suitable + * repository is found. + */ + public Repository getRepository(Map parameters) throws RepositoryException; +} \ No newline at end of file Property changes on: src\main\java\org\apache\jackrabbit\api\jsr283\RepositoryFactory.java ___________________________________________________________________ Added: svn:eol-style + native