本文整理汇总了Java中javax.resource.cci.Interaction类的典型用法代码示例。如果您正苦于以下问题:Java Interaction类的具体用法?Java Interaction怎么用?Java Interaction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Interaction类属于javax.resource.cci包,在下文中一共展示了Interaction类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Override
public <T> T execute(final InteractionCallback<T> action) throws DataAccessException {
Assert.notNull(action, "Callback object must not be null");
return execute(new ConnectionCallback<T>() {
@Override
public T doInConnection(Connection connection, ConnectionFactory connectionFactory)
throws ResourceException, SQLException, DataAccessException {
Interaction interaction = connection.createInteraction();
try {
return action.doInInteraction(interaction, connectionFactory);
}
finally {
closeInteraction(interaction);
}
}
});
}
示例2: testSimpleRecordOperation
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testSimpleRecordOperation() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
query.execute(inputRecord);
verify(interaction).execute(interactionSpec, inputRecord);
verify(interaction).close();
verify(connection).close();
}
示例3: testSimpleRecordOperationWithExplicitOutputRecord
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testSimpleRecordOperationWithExplicitOutputRecord() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
SimpleRecordOperation operation = new SimpleRecordOperation(connectionFactory, interactionSpec);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
operation.execute(inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例4: testSimpleRecordOperationWithInputOutputRecord
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testSimpleRecordOperationWithInputOutputRecord() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
SimpleRecordOperation query = new SimpleRecordOperation(connectionFactory, interactionSpec);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
query.execute(inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例5: testTemplateExecuteInputOutput
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputOutput() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例6: testTemplateExecuteInputFalse
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputFalse() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord);
verify(interaction).execute(interactionSpec, inputRecord);
verify(interaction).close();
verify(connection).close();
}
示例7: testTemplateExecuteInputExtractorFalse
import javax.resource.cci.Interaction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInputExtractorFalse()
throws ResourceException, SQLException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordExtractor<Object> extractor = mock(RecordExtractor.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
given(extractor.extractData(outputRecord)).willReturn(new Object());
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputRecord, extractor);
verify(extractor).extractData(outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例8: testTemplateExecuteInputOutputConnectionSpec
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputOutputConnectionSpec() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
ConnectionSpec connectionSpec = mock(ConnectionSpec.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection(connectionSpec)).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord, outputRecord)).willReturn(true);
ConnectionSpecConnectionFactoryAdapter adapter = new ConnectionSpecConnectionFactoryAdapter();
adapter.setTargetConnectionFactory(connectionFactory);
adapter.setConnectionSpec(connectionSpec);
CciTemplate ct = new CciTemplate(adapter);
ct.execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).execute(interactionSpec, inputRecord, outputRecord);
verify(interaction).close();
verify(connection).close();
}
示例9: testTemplateExecuteInteractionCallback
import javax.resource.cci.Interaction; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testTemplateExecuteInteractionCallback()
throws ResourceException, SQLException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
InteractionCallback<Object> interactionCallback = mock(InteractionCallback.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interactionCallback.doInInteraction(interaction,connectionFactory)).willReturn(new Object());
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionCallback);
verify(interactionCallback).doInInteraction(interaction,connectionFactory);
verify(interaction).close();
verify(connection).close();
}
示例10: testTemplateExecuteInputTrueTrueWithCreator
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputTrueTrueWithCreator()
throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordCreator creator = mock(RecordCreator.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.setOutputRecordCreator(creator);
ct.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例11: testTemplateExecuteInputTrueTrue
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputTrueTrue() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord, inputOutputRecord)).willReturn(true);
CciTemplate ct = new CciTemplate(connectionFactory);
ct.execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例12: testTemplateExecuteInputFalseTrue
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testTemplateExecuteInputFalseTrue() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
Record inputOutputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputOutputRecord)).willReturn(null);
CciTemplate ct = new CciTemplate(connectionFactory);
Record tmpOutputRecord = ct.execute(interactionSpec,
inputOutputRecord);
assertNull(tmpOutputRecord);
verify(interaction).execute(interactionSpec, inputOutputRecord);
verify(interaction).close();
verify(connection).close();
}
示例13: doGet
import javax.resource.cci.Interaction; //导入依赖的package包/类
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
try{
Connection eciConn = cf.getConnection();
Interaction eciInt = eciConn.createInteraction();
JavaStringRecord jsr = new JavaStringRecord();
jsr.setEncoding("IBM-1047");
// Setup the interactionSpec.
ECIInteractionSpec eSpec = new ECIInteractionSpec();
eSpec.setCommareaLength(20);
eSpec.setReplyLength(20);
eSpec.setFunctionName("EC01");
eSpec.setInteractionVerb(ECIInteractionSpec.SYNC_SEND_RECEIVE);
eciInt.execute(eSpec, jsr, jsr);
response.getWriter().println(jsr.getText().trim());
} catch (Exception e){
throw new IOException(e);
}
response.flushBuffer();
}
示例14: doExecute
import javax.resource.cci.Interaction; //导入依赖的package包/类
/**
* Execute the specified interaction on an EIS with CCI.
* All other interaction execution methods go through this.
* @param spec the CCI InteractionSpec instance that defines
* the interaction (connector-specific)
* @param inputRecord the input record
* @param outputRecord output record (can be {@code null})
* @param outputExtractor object to convert the output record to a result object
* @return the output data extracted with the RecordExtractor object
* @throws DataAccessException if there is any problem
*/
protected <T> T doExecute(
final InteractionSpec spec, final Record inputRecord, final Record outputRecord,
final RecordExtractor<T> outputExtractor) throws DataAccessException {
return execute(new InteractionCallback<T>() {
@Override
public T doInInteraction(Interaction interaction, ConnectionFactory connectionFactory)
throws ResourceException, SQLException, DataAccessException {
Record outputRecordToUse = outputRecord;
try {
if (outputRecord != null || getOutputRecordCreator() != null) {
// Use the CCI execute method with output record as parameter.
if (outputRecord == null) {
RecordFactory recordFactory = getRecordFactory(connectionFactory);
outputRecordToUse = getOutputRecordCreator().createRecord(recordFactory);
}
interaction.execute(spec, inputRecord, outputRecordToUse);
}
else {
outputRecordToUse = interaction.execute(spec, inputRecord);
}
return (outputExtractor != null ? outputExtractor.extractData(outputRecordToUse) : null);
}
finally {
if (outputRecordToUse instanceof ResultSet) {
closeResultSet((ResultSet) outputRecordToUse);
}
}
}
});
}
示例15: testMappingRecordOperation
import javax.resource.cci.Interaction; //导入依赖的package包/类
@Test
public void testMappingRecordOperation() throws ResourceException {
ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
Connection connection = mock(Connection.class);
Interaction interaction = mock(Interaction.class);
RecordFactory recordFactory = mock(RecordFactory.class);
Record inputRecord = mock(Record.class);
Record outputRecord = mock(Record.class);
InteractionSpec interactionSpec = mock(InteractionSpec.class);
QueryCallDetector callDetector = mock(QueryCallDetector.class);
MappingRecordOperationImpl query = new MappingRecordOperationImpl(connectionFactory, interactionSpec);
query.setCallDetector(callDetector);
Object inObj = new Object();
Object outObj = new Object();
given(connectionFactory.getRecordFactory()).willReturn(recordFactory);
given(callDetector.callCreateInputRecord(recordFactory, inObj)).willReturn(inputRecord);
given(connectionFactory.getConnection()).willReturn(connection);
given(connection.createInteraction()).willReturn(interaction);
given(interaction.execute(interactionSpec, inputRecord)).willReturn(outputRecord);
given(callDetector.callExtractOutputData(outputRecord)).willReturn(outObj);
assertSame(outObj, query.execute(inObj));
verify(interaction).close();
verify(connection).close();
}