Class ConnectionFactoryImpl

  • All Implemented Interfaces:
    org.datanucleus.store.connection.ConnectionFactory

    public class ConnectionFactoryImpl
    extends org.datanucleus.store.connection.AbstractConnectionFactory
    Implementation of a ConnectionFactory for MongoDB. Accepts a URL of the form
    mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database.collection][?options]]
    Defaults to a DB name of "DataNucleus" if nothing specified. Defaults to a DB name for authentication of "admin" if nothing specified and username supplied. Has a DB object per PM/EM. TODO Allow the option of having DB per PMF/EMF.
    • Constructor Detail

      • ConnectionFactoryImpl

        public ConnectionFactoryImpl​(org.datanucleus.store.StoreManager storeMgr,
                                     String resourceType)
        Constructor.
        Parameters:
        storeMgr - Store Manager
        resourceType - Type of resource (tx, nontx)
    • Method Detail

      • close

        public void close()
        Specified by:
        close in interface org.datanucleus.store.connection.ConnectionFactory
        Overrides:
        close in class org.datanucleus.store.connection.AbstractConnectionFactory
      • createManagedConnection

        public org.datanucleus.store.connection.ManagedConnection createManagedConnection​(org.datanucleus.ExecutionContext ec,
                                                                                          Map options)
        Obtain a connection from the Factory. The connection will be enlisted within the transaction associated to the ExecutionContext. Note that MongoDB doesn't have a "transaction" as such, so commit/rollback don't apply.
        Parameters:
        ec - the pool that is bound the connection during its lifecycle (or null)
        options - Options for creating the connection
        Returns:
        the ManagedConnection