Class JNDIDataSourceProvider

java.lang.Object
org.jivesoftware.database.JNDIDataSourceProvider
All Implemented Interfaces:
ConnectionProvider

public class JNDIDataSourceProvider extends Object implements ConnectionProvider
An implementation of ConnectionProvider that utilizes a JDBC 2.0 DataSource made available via JNDI. This is useful for application servers where a pooled data connection is already provided so Jive can share the pool with the other applications.

The JNDI location of the DataSource stored as the Jive property database.JNDIProvider.name. This can be overridden by setting the provider's name property if required.

Author:
Joe Walnes
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String[]
    Keys of JNDI properties to query PropertyManager for.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new JNDI pool.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Tells the connection provider to destroy itself.
    Returns a database connection.
    boolean
    Returns true if this connection provider provides connections out of a connection pool.
    void
    This method should be called whenever properties have been changed so that the changes will take effect.
    void
    Starts the connection provider.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • jndiPropertyKeys

      public static final String[] jndiPropertyKeys
      Keys of JNDI properties to query PropertyManager for.
  • Constructor Details

    • JNDIDataSourceProvider

      public JNDIDataSourceProvider()
      Constructs a new JNDI pool.
  • Method Details

    • isPooled

      public boolean isPooled()
      Description copied from interface: ConnectionProvider
      Returns true if this connection provider provides connections out of a connection pool. Implementing and using connection providers that are pooled is strongly recommended, as they greatly increase the speed of Jive.
      Specified by:
      isPooled in interface ConnectionProvider
      Returns:
      true if the Connection objects returned by this provider are pooled.
    • start

      public void start()
      Description copied from interface: ConnectionProvider
      Starts the connection provider. For some connection providers, this will be a no-op. However, connection provider users should always call this method to make sure the connection provider is started.
      Specified by:
      start in interface ConnectionProvider
    • restart

      public void restart()
      Description copied from interface: ConnectionProvider
      This method should be called whenever properties have been changed so that the changes will take effect.
      Specified by:
      restart in interface ConnectionProvider
    • destroy

      public void destroy()
      Description copied from interface: ConnectionProvider
      Tells the connection provider to destroy itself. For many connection providers, this will essentially result in a no-op. However, connection provider users should always call this method when changing from one connection provider to another to ensure that there are no dangling database connections.
      Specified by:
      destroy in interface ConnectionProvider
    • getConnection

      public Connection getConnection() throws SQLException
      Description copied from interface: ConnectionProvider
      Returns a database connection. When a Jive component is done with a connection, it will call the close method of that connection. Therefore, connection pools with special release methods are not directly supported by the connection provider infrastructure. Instead, connections from those pools should be wrapped such that calling the close method on the wrapper class will release the connection from the pool.
      Specified by:
      getConnection in interface ConnectionProvider
      Returns:
      a Connection object.
      Throws:
      SQLException - is an SQL error occurred while retrieving the connection.