org.ikasan.client
Class ConnectionTemplate

java.lang.Object
  extended by org.ikasan.client.ConnectionTemplate

public class ConnectionTemplate
extends Object

Similar in style to Spring's JMSTemplate, this code ensures that all code mean to run against a JCA connection will be supplied with a Connection from the ConnectionFactory, ensuring that that Connection is safely closed when done, regardless of the way the routine completes

Author:
Ikasan Development Team

Constructor Summary
ConnectionTemplate(javax.resource.cci.ConnectionFactory connectionFactory, javax.resource.cci.ConnectionSpec connectionSpec)
          Constructor
 
Method Summary
static void closeConnection(javax.resource.cci.Connection connection)
          Closes the connection, suppressing any exceptions
 Object execute(ConnectionCallback action)
          Execute the action specified by the given action object with a Connection.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionTemplate

public ConnectionTemplate(javax.resource.cci.ConnectionFactory connectionFactory,
                          javax.resource.cci.ConnectionSpec connectionSpec)
Constructor

Parameters:
connectionFactory - The factory for the connections
connectionSpec - The connection spec
Method Detail

execute

public Object execute(ConnectionCallback action)
               throws javax.resource.ResourceException
Execute the action specified by the given action object with a Connection.

Parameters:
action - callback object that exposes the Connection
Returns:
the result object from working with the Connection
Throws:
javax.resource.ResourceException - if there is any problem

closeConnection

public static void closeConnection(javax.resource.cci.Connection connection)
Closes the connection, suppressing any exceptions

Parameters:
connection - - possibly null, not necessarily open


Copyright © 2007-2012 Ikasan. All Rights Reserved.