EMC Developer Network

Using DFC methods getSharedSession() and findSessionById()

September 2005Download PDF Version

Abstract

This tip discusses the usage of the DFC methods IDfClient#getSharedSession() and IDfClient#findSessionById()

getSharedSession()

Sessions obtained from IDfClient.getSharedSession() are manually managed. They have no relationship to sessions handled by IDfSessionManager. IDfClient.getSharedSession() is an old mechanism for session sharing. For new code you should use the session manager to get a sharing effect.

findSessionById()

In general you should not use IDfClient.findSessionById() to obtain a session your program. It is an old mechanism that is no longer needed in light of session managers.

Session Manager

In the session manager model each piece of your program should manage sessions in a self contained way. The piece of code that "gets" a session should release the session as soon as it has done its immediate work. If another piece of code wants to perform operations then it can get the session and release it through the session manager. It is generally not a good practice for one body of code to "get" a session and another body of code to "release" the session. The best way to manage this is to get the session in the body of the method and release it in the finally block of the method.

public void myMethod()
{
	IDfSession sess = null;
	IDfSessionManager sessMgr = null;
	try
	{
	
		.....
		sessMgr = getSessionManager();
		sess = sessMgr.getSession(repoName);
		......
	}
	finally
	{
		if(sessMgr != null && sess != null)
		{
			sessMgr.release(sess);
		}
	}
}	
	

Acknowledgements

Many thanks to Dave Buccola from the DFC Engineering Team for contributing this tip.

Bugs or Comments

If you find bugs or issues with the component/article, please contact developer_program@documentum.com with a short description of the issue, steps to reproduce it and the relevant software environment.