From commits-return-9423-apmail-jackrabbit-commits-archive=jackrabbit.apache.org@jackrabbit.apache.org Mon Jan 11 16:51:23 2010 Return-Path: Delivered-To: apmail-jackrabbit-commits-archive@www.apache.org Received: (qmail 12272 invoked from network); 11 Jan 2010 16:51:23 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Jan 2010 16:51:23 -0000 Received: (qmail 56580 invoked by uid 500); 11 Jan 2010 16:51:23 -0000 Delivered-To: apmail-jackrabbit-commits-archive@jackrabbit.apache.org Received: (qmail 56521 invoked by uid 500); 11 Jan 2010 16:51:23 -0000 Mailing-List: contact commits-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list commits@jackrabbit.apache.org Received: (qmail 56507 invoked by uid 99); 11 Jan 2010 16:51:23 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 16:51:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 11 Jan 2010 16:51:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id F09402388906; Mon, 11 Jan 2010 16:51:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r897935 - in /jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons: GenericRepositoryFactory.java JcrUtils.java JndiRepositoryFactory.java Date: Mon, 11 Jan 2010 16:51:01 -0000 To: commits@jackrabbit.apache.org From: jukka@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100111165101.F09402388906@eris.apache.org> Author: jukka Date: Mon Jan 11 16:51:01 2010 New Revision: 897935 URL: http://svn.apache.org/viewvc?rev=897935&view=rev Log: JCR-2460: Rename GenericRepositoryFactory to JndiRepositoryFactory Added: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JndiRepositoryFactory.java - copied, changed from r897874, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java?rev=897935&r1=897934&r2=897935&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java Mon Jan 11 16:51:01 2010 @@ -16,107 +16,17 @@ */ package org.apache.jackrabbit.commons; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Hashtable; -import java.util.Map; - -import javax.jcr.Repository; -import javax.jcr.RepositoryException; -import javax.jcr.RepositoryFactory; -import javax.naming.InitialContext; -import javax.naming.NamingException; - /** - * Generic JCR repository factory. This factory knows how to handle - * parameter maps containing the following keys: - *
- *
{@link #JNDI_NAME org.apache.jackrabbit.repository.jndi.name}
- *
- * The repository instance is looked up from JNDI. - * An {@link InitialContext initial JNDI context} is constructed using - * all the other parameters, and a repository at the given name is - * looked up from the instantiated context. - *
- *
{@link #URI org.apache.jackrabbit.repository.uri}
- *
- * Connects to the repository at the given jndi: URI. - * All the other parameters except the repository URI from the original - * invocation are also passed on to these recursive calls. - *
- *
- * Clients should normally only use this class through the Java Service - * Provider mechanism. See the getRepository utility methods in - * {@link JcrUtils} for an easy way to do that. - * - * @since Apache Jackrabbit 2.0 + * Renamed to {@link JndiRepositoryFactory}. This class will be removed + * in Jackrabbit 2.0. Please use the {@link JcrUtils#REPOSITORY_URI} constant + * instead of the {@link #URI} constant in this class. */ -@SuppressWarnings("unchecked") -public class GenericRepositoryFactory implements RepositoryFactory { +@Deprecated +public class GenericRepositoryFactory extends JndiRepositoryFactory { /** - * The repository URI parameter name. + * Please use {@link JcrUtils#REPOSITORY_URI} instead. */ - @Deprecated public static final String URI = JcrUtils.REPOSITORY_URI; - /** - * The JNDI name parameter name. - */ - public static final String JNDI_NAME = - "org.apache.jackrabbit.repository.jndi.name"; - - /** - * Handles the generic repository parameters mentioned in the - * description of this class. Returns null if none of - * the described parameters are given or if the given parameter map is - * null. - */ - public Repository getRepository(Map parameters) - throws RepositoryException { - if (parameters == null) { - return null; // no default JNDI repository - } else { - Hashtable environment = new Hashtable(parameters); - if (environment.containsKey(JNDI_NAME)) { - String name = environment.remove(JNDI_NAME).toString(); - return getRepository(name, environment); - } else if (environment.containsKey(JcrUtils.REPOSITORY_URI)) { - Object parameter = environment.remove(JcrUtils.REPOSITORY_URI); - try { - URI uri = new URI(parameter.toString().trim()); - if ("jndi".equalsIgnoreCase(uri.getScheme())) { - String name = uri.getSchemeSpecificPart(); - return getRepository(name, environment); - } else { - return null; // not a jndi: URI - } - } catch (URISyntaxException e) { - return null; // not a valid URI - } - } else { - return null; // unknown parameters - } - } - } - - private Repository getRepository(String name, Hashtable environment) - throws RepositoryException { - try { - Object value = new InitialContext(environment).lookup(name); - if (value instanceof Repository) { - return (Repository) value; - } else { - throw new RepositoryException( - "Invalid repository object " + value - + " found at " + name + " in JNDI environment " - + environment); - } - } catch (NamingException e) { - throw new RepositoryException( - "Failed to look up " + name - + " from JNDI environment " + environment, e); - } - } - } Modified: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java?rev=897935&r1=897934&r2=897935&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JcrUtils.java Mon Jan 11 16:51:01 2010 @@ -55,6 +55,12 @@ * {@link #getRepository(String)} method. All {@link RepositoryFactory} * implementations that want to support this repository access convention * should implement processing of this parameter. + *

+ * Client applications are recommended to use the + * {@link #getRepository(String)} method instead of directly referencing + * this constant unless they explicitly want to pass also other + * {@link RepositoryFactory} parameters through the + * {@link #getRepository(Map)} method. */ public static final String REPOSITORY_URI = "org.apache.jackrabbit.repository.uri"; @@ -144,21 +150,26 @@ } /** - * Returns the repository identified by the given URI. The following - * URI types are currently supported: + * Returns the repository identified by the given URI. See the + * documentation of the repository implementation you want to use for + * whether it supports this repository URI convention and for what + * the repository URI should look like. For example, Jackrabbit 2.0 + * supports the following types of repository URIs: *

*
http(s)://...
*
* A remote repository connection using SPI2DAVex with the given URL. + * See the jackrabbit-jcr2dav component for more details. *
*
file://...
*
* An embedded Jackrabbit repository located in the given directory. + * See the jackrabbit-core component for more details. *
*
jndi:...
*
- * JNDI lookup for the named repository. See the JNDI support - * described above. + * JNDI lookup for the named repository. See the + * {@link JndiRepositoryFactory} class for more details. *
*
* Copied: jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JndiRepositoryFactory.java (from r897874, jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java) URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JndiRepositoryFactory.java?p2=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JndiRepositoryFactory.java&p1=jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java&r1=897874&r2=897935&rev=897935&view=diff ============================================================================== --- jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/GenericRepositoryFactory.java (original) +++ jackrabbit/trunk/jackrabbit-jcr-commons/src/main/java/org/apache/jackrabbit/commons/JndiRepositoryFactory.java Mon Jan 11 16:51:01 2010 @@ -28,23 +28,24 @@ import javax.naming.NamingException; /** - * Generic JCR repository factory. This factory knows how to handle - * parameter maps containing the following keys: + * JNDI-based JCR repository factory. This factory looks up {@link Repository} + * instances from JNDI directories based on the following parameters: *
*
{@link #JNDI_NAME org.apache.jackrabbit.repository.jndi.name}
*
- * The repository instance is looked up from JNDI. - * An {@link InitialContext initial JNDI context} is constructed using - * all the other parameters, and a repository at the given name is - * looked up from the instantiated context. + * The value of this parameter is used as a JNDI name for looking + * up the repository. *
- *
{@link #URI org.apache.jackrabbit.repository.uri}
+ *
{@link JcrUtils#REPOSITORY_URI org.apache.jackrabbit.repository.uri}
*
- * Connects to the repository at the given jndi: URI. - * All the other parameters except the repository URI from the original - * invocation are also passed on to these recursive calls. + * If the URI scheme is "jndi", then the remainder of the URI is used + * as a JNDI name for looking up the repository. *
*
+ *

+ * All the other repository parameters are passed as the environment of the + * {@link InitialContext initial JNDI context}. + *

* Clients should normally only use this class through the Java Service * Provider mechanism. See the getRepository utility methods in * {@link JcrUtils} for an easy way to do that. @@ -52,13 +53,7 @@ * @since Apache Jackrabbit 2.0 */ @SuppressWarnings("unchecked") -public class GenericRepositoryFactory implements RepositoryFactory { - - /** - * The repository URI parameter name. - */ - @Deprecated - public static final String URI = JcrUtils.REPOSITORY_URI; +public class JndiRepositoryFactory implements RepositoryFactory { /** * The JNDI name parameter name. @@ -66,12 +61,6 @@ public static final String JNDI_NAME = "org.apache.jackrabbit.repository.jndi.name"; - /** - * Handles the generic repository parameters mentioned in the - * description of this class. Returns null if none of - * the described parameters are given or if the given parameter map is - * null. - */ public Repository getRepository(Map parameters) throws RepositoryException { if (parameters == null) {