Template Method in Connection Template.
- By Prakash Malani
- March 24, 2001
Enterprise Java
Connection Strategies in EntityBeans
Prakash Malani
Listing 2. Template Method in Connection Template.
public final Object invokeMethod (String aDataSourceName) {
Object aReturn = null;
try {
Connection c = obtainConnection (aDataSourceName);
try {
aReturn = doMethod (c);
} finally {
releaseConnection (c);
}
} catch (Exception e) {
e.printStackTrace();
throw new EJBException (e.getMessage());
}
return aReturn;
}
About the Author
Prakash Malani is principal engineer at eBuilt Inc., Irvine, CA. Mr. Malani can be contacted at [email protected].