bea.com | products | dev2dev | support | askBEA |
![]() |
![]() |
|
![]() |
e-docs > WebLogic Platform > WebLogic Integration > BPM Topics > Programming BPM Client Apps > Disconnecting from the Process Engine |
Programming BPM Client Apps
|
Disconnecting from the Process Engine
This section explains how to disconnect from the WebLogic Integration process engine. It includes the following topics:
Removing Session EJB References
Once you have completed all application tasks, you can remove the session EJB references to make the system space available for use by other EJBs.
The session EJB home and remote interfaces defined in the table API Session EJB Home and Remote Interfaces inherit methods from the javax.ejb.EJBHome and javax.ejb.EJBObject interfaces, respectively.
The following table defines the inherited methods that can be used to remove EJB references.
For example, the following code excerpt from the JSP worklist example shows how to remove the Worklist EJB reference, including the session variable. In this example, worklist represents the EJBObject reference to the Worklist EJB. The session variable is an HttpSession object in which you previously stored the worklist remote object reference. For more information about the methods inherited by the home and remote interfaces, see the javax.ejb.EJBHome and javax.ejb.EJBObject Javadoc, respectively.
Worklist worklist = null;
worklist = (Worklist)session.getValue("worklist");
if (worklist != null) {
try {
worklist.remove();
} catch (Exception e) {
}
worklist = null;
session.removeValue("worklist");
}
Releasing Other Resources
In addition to removing the session EJB references, you should perform the tasks described in the following sections:
Stopping and Closing JMS Connections
Typically, a JMS Provider allocates a significant amount of resources when it creates a connection. When a connection is no longer being used, you should close it to release the resources associated with it. A connection can be closed using the following javax.jms.Connection method:
public void close(
) throws javax.jms.JMSException
For example, the following code provides an example of how to disconnect from JMS by closing the connection:
try {
tcon.close();
} catch (Exception e) {
ExceptionHandler.reportException(e, this);
}
tcon = null;
tsession = null;
tsubscriber = null;
}
Once the connection is closed, the application sets the connection, session, and topic subscriber variables to null so that the garbage collector can free the resources used by these objects.
Closing the Context
To close the JNDI context resources (instead of waiting for them to be released automatically by the garbage collector), use the following javax.naming.Context method:
public void close() throws javax.naming.NamingException
For example, the following code closes the JNDI context resources:
try {
ctx.close();
{
catch(Exception exp)
{
}
}
For more information, see the javax.naming.Context Javadoc.
![]() |
![]() |
![]() |
![]() |
||
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |