|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.jca.cci.core.CciTemplate
public class CciTemplate
This is the central class in the CCI core package.
It simplifies the use of CCI and helps to avoid common errors.
It executes core CCI workflow, leaving application code to provide parameters
to CCI and extract results. This class executes EIS queries or updates,
catching ResourceExceptions and translating them to the generic exception
hierarchy defined in the org.springframework.dao
package.
Code using this class can pass in and receive CCI Record instances, or alternatively implement callback interfaces for creating input Records and extracting result objects from output Records (or CCI ResultSets).
Can be used within a service implementation via direct instantiation with a ConnectionFactory reference, or get prepared in an application context and given to services as bean reference. Note: The ConnectionFactory should always be configured as a bean in the application context, in the first case given to the service directly, in the second case to the prepared template.
RecordCreator
,
RecordExtractor
,
org.springframework.dao
,
org.springframework.jca.cci.connection
,
org.springframework.jca.cci.object
Constructor Summary | |
---|---|
CciTemplate()
Construct a new CciTemplate for bean usage. |
|
CciTemplate(ConnectionFactory connectionFactory)
Construct a new CciTemplate, given a ConnectionFactory to obtain connections from. |
Method Summary | |
---|---|
void |
afterPropertiesSet()
Eagerly initialize the exception translator, creating a default one for the specified ConnectionFactory if none set. |
IndexedRecord |
createIndexedRecord(String name)
Create an indexed Record through the ConnectionFactory's RecordFactory. |
MappedRecord |
createMappedRecord(String name)
Create a mapped Record from the ConnectionFactory's RecordFactory. |
protected Record |
createRecord(RecordCreator recordCreator)
Invoke the given RecordCreator, converting JCA ResourceExceptions to Spring's DataAccessException hierarchy. |
protected Object |
doExecute(InteractionSpec spec,
Record inputRecord,
Record outputRecord,
RecordExtractor outputExtractor)
Execute the specified interaction on an EIS with CCI. |
Object |
execute(ConnectionCallback action)
Execute a request on an EIS with CCI, implemented as callback action working on a CCI Connection. |
Object |
execute(InteractionCallback action)
Execute a request on an EIS with CCI, implemented as callback action working on a CCI Interaction. |
Record |
execute(InteractionSpec spec,
Record inputRecord)
Execute the specified interaction on an EIS with CCI. |
Record |
execute(InteractionSpec spec,
RecordCreator inputCreator)
Execute the specified interaction on an EIS with CCI. |
Object |
execute(InteractionSpec spec,
RecordCreator inputCreator,
RecordExtractor outputExtractor)
Execute the specified interaction on an EIS with CCI. |
void |
execute(InteractionSpec spec,
Record inputRecord,
Record outputRecord)
Execute the specified interaction on an EIS with CCI. |
Object |
execute(InteractionSpec spec,
Record inputRecord,
RecordExtractor outputExtractor)
Execute the specified interaction on an EIS with CCI. |
ConnectionFactory |
getConnectionFactory()
Return the CCI ConnectionFactory used by this template. |
RecordCreator |
getOutputRecordCreator()
Return a RecordCreator that should be used for creating default output Records. |
protected RecordFactory |
getRecordFactory(ConnectionFactory connectionFactory)
Return a RecordFactory for the given ConnectionFactory. |
void |
setConnectionFactory(ConnectionFactory connectionFactory)
Set the CCI ConnectionFactory to obtain connections from. |
void |
setOutputRecordCreator(RecordCreator creator)
Set a RecordCreator that should be used for creating default output Records. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CciTemplate()
public CciTemplate(ConnectionFactory connectionFactory)
connectionFactory
- JCA ConnectionFactory to obtain connections fromMethod Detail |
---|
public void setConnectionFactory(ConnectionFactory connectionFactory)
public ConnectionFactory getConnectionFactory()
public void setOutputRecordCreator(RecordCreator creator)
Default is none: When no explicit output Record gets passed into an
execute
method, CCI's Interaction.execute
variant
that returns an output Record will be called.
Specify a RecordCreator here if you always need to call CCI's
Interaction.execute
variant with a passed-in output Record.
Unless there is an explicitly specified output Record, CciTemplate will
then invoke this RecordCreator to create a default output Record instance.
public RecordCreator getOutputRecordCreator()
public void afterPropertiesSet()
public Object execute(ConnectionCallback action) throws DataAccessException
CciOperations
The callback action can return a result object, for example a domain object or a collection of domain objects.
execute
in interface CciOperations
action
- the callback object that specifies the action
DataAccessException
- if there is any problempublic Object execute(InteractionCallback action) throws DataAccessException
CciOperations
The callback action can return a result object, for example a domain object or a collection of domain objects.
execute
in interface CciOperations
action
- the callback object that specifies the action
DataAccessException
- if there is any problempublic Record execute(InteractionSpec spec, Record inputRecord) throws DataAccessException
CciOperations
execute
in interface CciOperations
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputRecord
- the input record
DataAccessException
- if there is any problempublic void execute(InteractionSpec spec, Record inputRecord, Record outputRecord) throws DataAccessException
CciOperations
execute
in interface CciOperations
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputRecord
- the input recordoutputRecord
- the output record
DataAccessException
- if there is any problempublic Record execute(InteractionSpec spec, RecordCreator inputCreator) throws DataAccessException
CciOperations
execute
in interface CciOperations
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputCreator
- object that creates the input record to use
DataAccessException
- if there is any problempublic Object execute(InteractionSpec spec, Record inputRecord, RecordExtractor outputExtractor) throws DataAccessException
CciOperations
execute
in interface CciOperations
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputRecord
- the input recordoutputExtractor
- object to convert the output record to a result object
DataAccessException
- if there is any problempublic Object execute(InteractionSpec spec, RecordCreator inputCreator, RecordExtractor outputExtractor) throws DataAccessException
CciOperations
execute
in interface CciOperations
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputCreator
- object that creates the input record to useoutputExtractor
- object to convert the output record to a result object
DataAccessException
- if there is any problemprotected Object doExecute(InteractionSpec spec, Record inputRecord, Record outputRecord, RecordExtractor outputExtractor) throws DataAccessException
spec
- the CCI InteractionSpec instance that defines
the interaction (connector-specific)inputRecord
- the input recordoutputRecord
- output record (can be null
)outputExtractor
- object to convert the output record to a result object
DataAccessException
- if there is any problempublic IndexedRecord createIndexedRecord(String name) throws DataAccessException
name
- the name of the record
DataAccessException
- if creation of the Record failedgetRecordFactory(javax.resource.cci.ConnectionFactory)
,
RecordFactory.createIndexedRecord(String)
public MappedRecord createMappedRecord(String name) throws DataAccessException
name
- record name
DataAccessException
- if creation of the Record failedgetRecordFactory(javax.resource.cci.ConnectionFactory)
,
RecordFactory.createMappedRecord(String)
protected Record createRecord(RecordCreator recordCreator) throws DataAccessException
recordCreator
- the RecordCreator to invoke
DataAccessException
- if creation of the Record failedgetRecordFactory(javax.resource.cci.ConnectionFactory)
,
RecordCreator.createRecord(javax.resource.cci.RecordFactory)
protected RecordFactory getRecordFactory(ConnectionFactory connectionFactory) throws ResourceException
Default implementation returns the connector's RecordFactory if available, falling back to a NotSupportedRecordFactory placeholder. This allows to invoke a RecordCreator callback with a non-null RecordFactory reference in any case.
connectionFactory
- the CCI ConnectionFactory
ResourceException
- if thrown by CCI methodsNotSupportedRecordFactory
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |