org.modeshape.jdbc
Class JcrDriver

java.lang.Object
  extended by org.modeshape.jdbc.JcrDriver
All Implemented Interfaces:
Driver

public class JcrDriver
extends Object
implements Driver

A JDBC driver implementation that is able to access a JCR repository to query its contents using JCR-SQL2.

Connection URLs

The driver accepts several URL formats based on how the repository is configured:

  1. configured for local access using JNDI
         jdbc:jcr:jndi:{jndiName}
     
    or
         jdbc:jcr:jndi:{jndiName}?{firstProperty}&{secondProperty}&...
     
    where Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used.

    Here's an example of a URL that defines a Repository instance located at "jcr/local" with a repository name of "repository" and a user, password of "secret", and workspace name of "My Workspace":

         jdbc:jcr:jndi:jcr/local?repositoryName=repository&user=jsmith&password=secret&workspace=My%20Workspace
     
    The "repository" property is required only if the object in JNDI is a org.modeshape.jcr.api.Repositories object.

  2. configured for remote access using REST interface.
         jdbc:jcr:http://{hostname}:{port}?{firstProperty}&{secondProperty}&...
     
    where Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used.

    Note that any use of URL encoding ('%' followed by a two-digit hexadecimal value) will be decoded before being used.


    Nested Class Summary
    static interface JcrDriver.JcrContextFactory
               
     
    Field Summary
    protected static Set<String> ALL_PROPERTY_NAMES
               
     JcrDriver.JcrContextFactory contextFactory
               
    static String HTTP_URL_PREFIX
               
    static String JNDI_URL_PREFIX
               
    protected static Logger logger
               
    static String PASSWORD_PROPERTY_NAME
               
    static String REPOSITORY_PROPERTY_NAME
               
    static String USERNAME_PROPERTY_NAME
               
    static String WORKSPACE_PROPERTY_NAME
               
     
    Constructor Summary
    JcrDriver()
              No-arg constructor, required by the DriverManager.
     
    Method Summary
     boolean acceptsURL(String url)
              
     Connection connect(String url, Properties info)
               Note that if the supplied properties and URL contain properties with the same name, the value from the supplied Properties object will take precedence.
    protected  ConnectionInfo createConnectionInfo(String url, Properties info)
              Get the information describing the connection.
    static JcrDriver getInstance()
               
     int getMajorVersion()
              
     int getMinorVersion()
              
     DriverPropertyInfo[] getPropertyInfo(String url, Properties info)
              
     String getVendorName()
               
     String getVendorUrl()
               
     String getVersion()
               
     boolean jdbcCompliant()
              
     void setContextFactory(JcrDriver.JcrContextFactory factory)
               
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Field Detail

    logger

    protected static Logger logger

    WORKSPACE_PROPERTY_NAME

    public static final String WORKSPACE_PROPERTY_NAME
    See Also:
    Constant Field Values

    REPOSITORY_PROPERTY_NAME

    public static final String REPOSITORY_PROPERTY_NAME
    See Also:
    Constant Field Values

    USERNAME_PROPERTY_NAME

    public static final String USERNAME_PROPERTY_NAME
    See Also:
    Constant Field Values

    PASSWORD_PROPERTY_NAME

    public static final String PASSWORD_PROPERTY_NAME
    See Also:
    Constant Field Values

    ALL_PROPERTY_NAMES

    protected static final Set<String> ALL_PROPERTY_NAMES

    JNDI_URL_PREFIX

    public static final String JNDI_URL_PREFIX
    See Also:
    Constant Field Values

    HTTP_URL_PREFIX

    public static final String HTTP_URL_PREFIX
    See Also:
    Constant Field Values

    contextFactory

    public JcrDriver.JcrContextFactory contextFactory
    Constructor Detail

    JcrDriver

    public JcrDriver()
    No-arg constructor, required by the DriverManager.

    Method Detail

    getInstance

    public static JcrDriver getInstance()

    acceptsURL

    public boolean acceptsURL(String url)

    Specified by:
    acceptsURL in interface Driver
    See Also:
    Driver.acceptsURL(java.lang.String)

    getPropertyInfo

    public DriverPropertyInfo[] getPropertyInfo(String url,
                                                Properties info)
                                         throws SQLException

    Specified by:
    getPropertyInfo in interface Driver
    Throws:
    SQLException
    See Also:
    Driver.getPropertyInfo(java.lang.String, java.util.Properties)

    createConnectionInfo

    protected ConnectionInfo createConnectionInfo(String url,
                                                  Properties info)
                                           throws SQLException
    Get the information describing the connection. This method can be overridden to return a subclass of ConnectionInfo that implements ConnectionInfo.getCredentials() for a specific JCR implementation.

    Parameters:
    url - the JDBC URL
    info - the JDBC connection properties
    Returns:
    the connection information, or null if the URL is null or not of the proper format
    Throws:
    SQLException

    connect

    public Connection connect(String url,
                              Properties info)
                       throws SQLException

    Note that if the supplied properties and URL contain properties with the same name, the value from the supplied Properties object will take precedence.

    Specified by:
    connect in interface Driver
    Throws:
    SQLException
    See Also:
    Driver.connect(java.lang.String, java.util.Properties)

    getMajorVersion

    public int getMajorVersion()

    Specified by:
    getMajorVersion in interface Driver
    See Also:
    Driver.getMajorVersion()

    getMinorVersion

    public int getMinorVersion()

    Specified by:
    getMinorVersion in interface Driver
    See Also:
    Driver.getMinorVersion()

    getVendorName

    public String getVendorName()

    getVendorUrl

    public String getVendorUrl()

    getVersion

    public String getVersion()

    jdbcCompliant

    public boolean jdbcCompliant()

    Specified by:
    jdbcCompliant in interface Driver
    See Also:
    Driver.jdbcCompliant()

    setContextFactory

    public void setContextFactory(JcrDriver.JcrContextFactory factory)


    Copyright © 2008-2010 JBoss, a division of Red Hat. All Rights Reserved.