Class SessionBroker

    • Constructor Detail

      • SessionBroker

        public SessionBroker()
        PUBLIC: Create and return a session broker. Because a session broker has multiple sessions it does not used a login.
    • Method Detail

      • acquireClientSessionBroker

        public SessionBroker acquireClientSessionBroker()
        PUBLIC: Return a session broker that behaves as a client session broker. An acquire session broker is done under the covers on each session inside the session broker, and a new broker is returned. NOTE: when finished with the client broker, it should be released.
      • acquireClientSessionBroker

        public SessionBroker acquireClientSessionBroker​(Map<String,​ConnectionPolicy> connectionPolicies,
                                                        Map mapOfProperties)
        PUBLIC: Return a session broker that behaves as a client session broker. An acquire session broker is done under the covers on each session inside the session broker, and a new broker is returned. NOTE: when finished with the client broker, it should be released.
        Parameters:
        connectionPolicies - maps session name to connectionPolicy to be used for this session;
        mapOfProperties - maps session name to properties to be used for this session.
      • releaseJTSConnection

        public void releaseJTSConnection()
        INTERNAL: Called in the end of beforeCompletion of external transaction sychronization listener. Close the managed sql connection corresponding to the external transaction, if applicable releases accessor.
        Overrides:
        releaseJTSConnection in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • acquireUnitOfWork

        public org.eclipse.persistence.internal.sessions.UnitOfWorkImpl acquireUnitOfWork()
        PUBLIC: Return a unit of work for this session broker. Acquire a client session broker if is a server session broker.
        Specified by:
        acquireUnitOfWork in interface Session
        Overrides:
        acquireUnitOfWork in class org.eclipse.persistence.internal.sessions.AbstractSession
        See Also:
        UnitOfWorkImpl
      • addDescriptor

        public void addDescriptor​(ClassDescriptor descriptor)
        PUBLIC: You cannot add a descriptor to a session broker, you must add it to its session.
        Specified by:
        addDescriptor in interface DatabaseSession
        Overrides:
        addDescriptor in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        See Also:
        #addDescriptors(Vector), DatabaseSessionImpl.addDescriptors(org.eclipse.persistence.sessions.Project)
      • addSequence

        public void addSequence​(Sequence sequence)
        PUBLIC: You cannot add a sequence to a session broker, you must add it to its session.
        Specified by:
        addSequence in interface DatabaseSession
        Overrides:
        addSequence in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        See Also:
        #addSequences(Collection)
      • containsQuery

        public boolean containsQuery​(String queryName)
        PUBLIC: Return true if the pre-defined query is defined on the session.
        Specified by:
        containsQuery in interface Session
        Overrides:
        containsQuery in class org.eclipse.persistence.internal.sessions.AbstractSession
      • getAccessors

        public Collection<org.eclipse.persistence.internal.databaseaccess.Accessor> getAccessors​(Call call,
                                                                                                 org.eclipse.persistence.internal.sessions.AbstractRecord translationRow,
                                                                                                 DatabaseQuery query)
        INTERNAL: Return the low-level database accessors. The database accessor is used for direct database access. The right accessor for this broker will be returned.
        Overrides:
        getAccessors in class org.eclipse.persistence.internal.sessions.AbstractSession
      • getParent

        public SessionBroker getParent()
        INTERNAL: Gets the parent SessionBroker.
        Overrides:
        getParent in class org.eclipse.persistence.internal.sessions.AbstractSession
      • getExecutionSession

        public org.eclipse.persistence.internal.sessions.AbstractSession getExecutionSession​(DatabaseQuery query)
        INTERNAL: Gets the session which this query will be executed on. Generally will be called immediately before the call is translated, which is immediately before session.executeCall.

        Since the execution session also knows the correct datasource platform to execute on, it is often used in the mappings where the platform is needed for type conversion, or where calls are translated.

        Is also the session with the accessor. Will return a ClientSession if it is in transaction and has a write connection.

        Overrides:
        getExecutionSession in class org.eclipse.persistence.internal.sessions.AbstractSession
        Parameters:
        query - may store session name or reference class for brokers case
        Returns:
        a session with a live accessor
      • getPlatform

        public org.eclipse.persistence.internal.databaseaccess.Platform getPlatform​(Class domainClass)
        INTERNAL: Return the platform for a particular class.
        Overrides:
        getPlatform in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • getQuery

        public DatabaseQuery getQuery​(String name,
                                      Vector arguments,
                                      boolean shouldSearchParent)
        PUBLIC: Return the query from the session pre-defined queries with the given name and argument types. This allows for common queries to be pre-defined, reused and executed by name. This method should be used if the Session has multiple queries with the same name but different arguments. The search order is: for ClientSessionBroker: the broker; it's member ClientSessions (but not their parent ServerSessions); the parent SessionBroker. for ServerSession or DatabaseSession SessionBroker: the broker; it's member ServerSessions (or DatabaseSessions).
        Overrides:
        getQuery in class org.eclipse.persistence.internal.sessions.AbstractSession
        See Also:
        #getQuery(String, arguments)
      • getSessionForClass

        public org.eclipse.persistence.internal.sessions.AbstractSession getSessionForClass​(Class domainClass)
                                                                                     throws ValidationException
        INTERNAL: Return the session to be used for the class.
        Overrides:
        getSessionForClass in class org.eclipse.persistence.internal.sessions.AbstractSession
        Throws:
        ValidationException
      • getSessionForName

        public org.eclipse.persistence.internal.sessions.AbstractSession getSessionForName​(String name)
                                                                                    throws ValidationException
        INTERNAL: Return the session by name.
        Overrides:
        getSessionForName in class org.eclipse.persistence.internal.sessions.AbstractSession
        Throws:
        ValidationException
      • getSessionsByName

        public Map<String,​org.eclipse.persistence.internal.sessions.AbstractSession> getSessionsByName()
        INTERNAL: Return sessions indexed by name.
      • initializeDescriptors

        public void initializeDescriptors()
        INTERNAL: Allow each descriptor to initialize any dependencies on this session. This is done in two passes to allow the inheritance to be resolved first. Normally the descriptors are added before login, then initialized on login. Should not be called on client SessoionBroker
        Overrides:
        initializeDescriptors in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • initializeIdentityMapAccessor

        public void initializeIdentityMapAccessor()
        INTERNAL: Set up the IdentityMapManager. This method allows subclasses of Session to override the default IdentityMapManager functionality.
        Overrides:
        initializeIdentityMapAccessor in class org.eclipse.persistence.internal.sessions.AbstractSession
      • internalExecuteQuery

        public Object internalExecuteQuery​(DatabaseQuery query,
                                           org.eclipse.persistence.internal.sessions.AbstractRecord row)
                                    throws DatabaseException,
                                           QueryException
        INTERNAL: Return the results from exeucting the database query. the arguments should be a database row with raw data values. Find the correct child session to broker the query to, and return the result of the session executing the query.
        Overrides:
        internalExecuteQuery in class org.eclipse.persistence.internal.sessions.AbstractSession
        Throws:
        DatabaseException
        QueryException
      • isBroker

        public boolean isBroker()
        INTERNAL: Returns true if the session is a session Broker.
        Overrides:
        isBroker in class org.eclipse.persistence.internal.sessions.AbstractSession
      • isClientSessionBroker

        public boolean isClientSessionBroker()
        PUBLIC: Return if this session is a client session broker.
      • isConnected

        public boolean isConnected()
        PUBLIC: Return if all sessions are still connected to the database.
        Specified by:
        isConnected in interface Session
        Overrides:
        isConnected in class org.eclipse.persistence.internal.sessions.AbstractSession
      • isServerSessionBroker

        public boolean isServerSessionBroker()
        PUBLIC: Return if this session is a server session broker.
      • isSessionBroker

        public boolean isSessionBroker()
        INTERNAL: Return if this session is a session broker.
        Specified by:
        isSessionBroker in interface Session
        Overrides:
        isSessionBroker in class org.eclipse.persistence.internal.sessions.AbstractSession
      • login

        public void login()
                   throws DatabaseException
        PUBLIC: Connect to the database using the predefined login. This connects all of the child sessions and expects that they are in a valid state to be connected.
        Specified by:
        login in interface DatabaseSession
        Overrides:
        login in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        Throws:
        DatabaseException
        See Also:
        DatabaseSessionImpl.login(Login)
      • loginAndDetectDatasource

        public void loginAndDetectDatasource()
                                      throws DatabaseException
        PUBLIC: Connect to the database using the predefined login. During connection, attempt to auto detect the required database platform. This method can be used in systems where for ease of use developers have EclipseLink autodetect the platform. To be safe, however, the platform should be configured directly. The login must have been assigned when or after creating the session.
        Overrides:
        loginAndDetectDatasource in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        Throws:
        DatabaseException
      • login

        public void login​(String userName,
                          String password)
                   throws DatabaseException
        PUBLIC: Connect to the database using the predefined login. This connects all of the child sessions and expects that they are in a valid state to be connected.
        Specified by:
        login in interface DatabaseSession
        Overrides:
        login in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        Throws:
        DatabaseException
      • logout

        public void logout()
                    throws DatabaseException
        PUBLIC: Disconnect from all databases.
        Specified by:
        logout in interface DatabaseSession
        Overrides:
        logout in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
        Throws:
        EclipseLinkException - if a transaction is active, you must rollback any active transaction before logout.
        DatabaseException - the database will also raise an error if their is an active transaction, or a general error occurs.
      • postLogin

        public void postLogin()
        INTERNAL: Rise postLogin events for member sessions and the SessionBroker.
        Overrides:
        postLogin in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • registerSession

        public void registerSession​(String name,
                                    org.eclipse.persistence.internal.sessions.AbstractSession session)
        PUBLIC: Register the session under its name. All of the session's descriptors must have already been registered. DatabaseSession/ServerSession should not be connected and descriptors should not be initialized.
      • registerSession

        public void registerSession​(String name,
                                    Session session)
        PUBLIC: Register the session under its name. All of the session's descriptors must have already been registered. DatabaseSession/ServerSession should not be connected and descriptors should not be initialized.
      • release

        public void release()
        PUBLIC: Release the session. This does nothing by default, but allows for other sessions such as the ClientSession to do something.
        Specified by:
        release in interface Session
        Overrides:
        release in class org.eclipse.persistence.internal.sessions.AbstractSession
      • retryQuery

        public Object retryQuery​(DatabaseQuery query,
                                 org.eclipse.persistence.internal.sessions.AbstractRecord row,
                                 DatabaseException databaseException,
                                 int retryCount,
                                 org.eclipse.persistence.internal.sessions.AbstractSession executionSession)
        INTERNAL: A query execution failed due to an invalid query. Re-connect and retry the query.
        Overrides:
        retryQuery in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • setIntegrityChecker

        public void setIntegrityChecker​(IntegrityChecker integrityChecker)
        PUBLIC: set the integrityChecker. IntegrityChecker holds all the ClassDescriptor Exceptions.
        Specified by:
        setIntegrityChecker in interface Session
        Overrides:
        setIntegrityChecker in class org.eclipse.persistence.internal.sessions.AbstractSession
      • setSessionLog

        public void setSessionLog​(SessionLog log)
        PUBLIC: Set the session log.
        Specified by:
        setSessionLog in interface Session
        Overrides:
        setSessionLog in class org.eclipse.persistence.internal.sessions.AbstractSession
        See Also:
        AbstractSession.logMessage(java.lang.String)
      • setLog

        public void setLog​(Writer log)
        PUBLIC: Set the message log.
        Specified by:
        setLog in interface Session
        Overrides:
        setLog in class org.eclipse.persistence.internal.sessions.AbstractSession
        See Also:
        AbstractSession.logMessage(java.lang.String)
      • setProfiler

        public void setProfiler​(SessionProfiler profiler)
        PUBLIC: Set the profiler for the session. This allows for performance operations to be profiled.
        Specified by:
        setProfiler in interface Session
        Overrides:
        setProfiler in class org.eclipse.persistence.internal.sessions.AbstractSession
      • setSessionsByName

        public void setSessionsByName​(Map sessionsByName)
        INTERNAL: Set sessions indexed by name.
      • setSynchronized

        public void setSynchronized​(boolean synched)
        INTERNAL: Set isSynchronized flag to indicate that members of session broker are synchronized. This method should only be called by setSynchronized method of UnitOfWork obtained from either DatabaseSession Broker or ClientSession Broker.
        Overrides:
        setSynchronized in class org.eclipse.persistence.internal.sessions.AbstractSession
      • writesCompleted

        public void writesCompleted()
        INTERNAL: This method notifies the accessor that a particular sets of writes has completed. This notification can be used for such thing as flushing the batch mechanism
        Overrides:
        writesCompleted in class org.eclipse.persistence.internal.sessions.AbstractSession
      • initializeSequencing

        public void initializeSequencing()
        ADVANCED: Creates sequencing object for the session broker. Typically there is no need for the user to call this method - it is called by login() and acquireClientSessionBroker.
        Overrides:
        initializeSequencing in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • getSequencing

        public org.eclipse.persistence.internal.sequencing.Sequencing getSequencing()
        PUBLIC: Return the Sequencing object used by the session.
        Overrides:
        getSequencing in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • howManySequencingCallbacks

        public int howManySequencingCallbacks()
        INTERNAL: Returns a number of member sessions that require sequencing callback. Always returns 0 if sequencing is not connected.
      • isSequencingCallbackRequired

        public boolean isSequencingCallbackRequired()
        INTERNAL: Indicates whether SequencingCallback is required. Always returns false if sequencing is not connected.
        Overrides:
        isSequencingCallbackRequired in class org.eclipse.persistence.internal.sessions.DatabaseSessionImpl
      • shouldUseDescriptorAliases

        public boolean shouldUseDescriptorAliases()
        PUBLIC: Indicates whether descriptors should use aliasDescriptors map. If aliasDescriptors is used then descriptors' aliases should be unique.
      • setShouldUseDescriptorAliases

        public void setShouldUseDescriptorAliases​(boolean shouldUseDescriptorAliases)
        PUBLIC: Indicates whether descriptors should use aliasDescriptors map. If aliasDescriptors is used then descriptors' aliases should be unique.