What is a session?
- The key to enter the repository
- Created as soon as the user is authenticated
- Maintains Connection with the repository
- Gives access to objects in the repository for the authenticated user.
- Create Object
- Query Objects
- Manipulate Objects
- Accessed through Session Handles
How to get a session?
- Sessions can be obtained by
- IDfSession Interface
- IDfSessionManager Interface (recommended)
- Session obtained by IDfSession are Unmanaged sessions
- Session obtained by IDfSessionManager are Managed sessions
- Session manager is a factory for generating IDfSession Object
- Get Session :IDfSessionManager.newSession
- Release Session :IDfSessionManager.release()
Obtain Session: An Example
public static void demoSessionGetRelease (String repository, String userName, String password) throws DfException { IDfSession mySession = null; // Get a session manager with a single identity. DfClientX clientx = new DfClientX(); IDfClient client = clientx.getLocalClient(); mySessMgr = client.newSessionManager(); IDfLoginInfo logininfo = clientx.getLoginInfo(); loginInfo.setUser(userName); loginInfo.setPassword(password); mySessMgr.setIdentity(repository, loginInfo); // Get a session using a factory method of session manager. IDfSession mySession = mySessMgr.getSession(repository); try { // Insert code that performs tasks in the repository. } finally { mySessMgr.release(mySession); } }
Handling Sessions:An approach
- Obtaining a DFC Client object.
- Getting a new instance of Session Manager
- Registering user access credentials for accessing the repository with the Session Manager.
- Getting a DFC session to work with the repository.
- Performing business functionality with the repository.
- Releasing the session back to the Session Manager.
- Destroying or abandoning the Session Manager.