Interface BrokerFactory

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addLifecycleListener​(java.lang.Object listener, java.lang.Class<?>[] classes)
      Register a listener for lifecycle-related events on the specified classes.
      void addTransactionListener​(java.lang.Object listener)
      Register a listener for transaction-related events on the specified classes.
      void assertOpen()
      assert that this broker is open.
      void close()
      Close the factory.
      OpenJPAConfiguration getConfiguration()
      Return the configuration for this factory.
      java.util.Map<java.lang.String,​java.lang.Object> getProperties()
      Return properties describing this runtime.
      java.util.Set<java.lang.String> getSupportedProperties()
      Return all of the supported properties as a set of keys.
      java.lang.Object getUserObject​(java.lang.Object key)
      Get the value for the specified key from the map of user objects.
      boolean isClosed()
      Returns true if this broker factory is closed.
      void lock()
      Synchronizes on an internal lock.
      Broker newBroker()
      Return a broker with default settings.
      Broker newBroker​(java.lang.String user, java.lang.String pass, boolean managed, int connRetainMode, boolean findExisting)
      Return a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.
      Broker newBroker​(java.lang.String user, java.lang.String pass, boolean managed, int connRetainMode, boolean findExisting, java.lang.String cfName, java.lang.String cf2Name)
      Return a new broker using the supplied credentials transaction management mode connectionRetainMode connectionFactories
      void postCreationCallback()
      This method is invoked AFTER a BrokerFactory has been instantiated.
      java.lang.Object putUserObject​(java.lang.Object key, java.lang.Object val)
      Put the specified key-value pair into the map of user objects.
      void removeLifecycleListener​(java.lang.Object listener)
      Remove a listener for lifecycle-related events.
      void removeTransactionListener​(java.lang.Object listener)
      Remove a listener for transaction-related events.
      void unlock()
      Release the internal lock.
    • Method Detail

      • getConfiguration

        OpenJPAConfiguration getConfiguration()
        Return the configuration for this factory.
      • getProperties

        java.util.Map<java.lang.String,​java.lang.Object> getProperties()
        Return properties describing this runtime.
      • getSupportedProperties

        java.util.Set<java.lang.String> getSupportedProperties()
        Return all of the supported properties as a set of keys. If a property has multiple keys, all keys will be returned.
        Since:
        2.0.0
      • putUserObject

        java.lang.Object putUserObject​(java.lang.Object key,
                                       java.lang.Object val)
        Put the specified key-value pair into the map of user objects.
      • getUserObject

        java.lang.Object getUserObject​(java.lang.Object key)
        Get the value for the specified key from the map of user objects.
      • newBroker

        Broker newBroker()
        Return a broker with default settings.
      • newBroker

        Broker newBroker​(java.lang.String user,
                         java.lang.String pass,
                         boolean managed,
                         int connRetainMode,
                         boolean findExisting)
        Return a broker using the given credentials and in the given transaction and connection retain mode, optionally finding existing broker in the global transaction.
      • newBroker

        Broker newBroker​(java.lang.String user,
                         java.lang.String pass,
                         boolean managed,
                         int connRetainMode,
                         boolean findExisting,
                         java.lang.String cfName,
                         java.lang.String cf2Name)
        Return a new broker using the supplied
        • credentials
        • transaction management mode
        • connectionRetainMode
        • connectionFactories
        Parameters:
        user - Username to use when obtaining a connection. Will be ignored if a connection factory is obtained from JNDI.
        pass - Password to use when obtaining a connection. Will be ignored if a connection factory is obtained from JNDI.
        managed - Whether managed transactions will be used by this Broker
        connRetainMode - ConnectionRetainMode
        findExisting - Whether the internal pool of brokers should be used.
        cfName - JTA ConnectionFactory to use
        cf2Name - Non-JTA ConnectionFactory to use.
        Returns:
        A Broker which matches the provided criteria.
      • addLifecycleListener

        void addLifecycleListener​(java.lang.Object listener,
                                  java.lang.Class<?>[] classes)
        Register a listener for lifecycle-related events on the specified classes. If the classes are null, all events will be propagated to the listener. The listener will be passed on to all new brokers.
        Since:
        0.3.3
      • removeLifecycleListener

        void removeLifecycleListener​(java.lang.Object listener)
        Remove a listener for lifecycle-related events.
        Since:
        0.3.3
      • addTransactionListener

        void addTransactionListener​(java.lang.Object listener)
        Register a listener for transaction-related events on the specified classes. It will be registered with all Brokers created from this instance moving forward.
        Since:
        1.0.0
      • removeTransactionListener

        void removeTransactionListener​(java.lang.Object listener)
        Remove a listener for transaction-related events. It will no longer be registered with new Brokers created from this instance.
        Since:
        1.0.0
      • close

        void close()
        Close the factory.
        Specified by:
        close in interface Closeable
      • isClosed

        boolean isClosed()
        Returns true if this broker factory is closed.
      • lock

        void lock()
        Synchronizes on an internal lock.
      • unlock

        void unlock()
        Release the internal lock.
      • assertOpen

        void assertOpen()
        assert that this broker is open. If the broker has been closed an IllegalStateException will be thrown with information on when the broker was closed.
      • postCreationCallback

        void postCreationCallback()
        This method is invoked AFTER a BrokerFactory has been instantiated.