Template Method in Connection Template.

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 pmalani@ebuilt.com.

Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.