本文整理汇总了Java中javax.resource.cci.ConnectionSpec类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionSpec类的具体用法?Java ConnectionSpec怎么用?Java ConnectionSpec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionSpec类属于javax.resource.cci包,在下文中一共展示了ConnectionSpec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTemplateExecuteInputOutputConnectionSpec
import javax.resource.cci.ConnectionSpec; //导入依赖的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();
}
示例2: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
* Determine whether there is currently a thread-bound ConnectionSpec,
* using it if available, falling back to the statically specified
* "connectionSpec" property else.
* @see #doGetConnection
*/
@Override
public final Connection getConnection() throws ResourceException {
ConnectionSpec threadSpec = this.threadBoundSpec.get();
if (threadSpec != null) {
return doGetConnection(threadSpec);
}
else {
return doGetConnection(this.connectionSpec);
}
}
示例3: doGetConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
* This implementation delegates to the {@code getConnection(ConnectionSpec)}
* method of the target ConnectionFactory, passing in the specified user credentials.
* If the specified username is empty, it will simply delegate to the standard
* {@code getConnection()} method of the target ConnectionFactory.
* @param spec the ConnectionSpec to apply
* @return the Connection
* @see javax.resource.cci.ConnectionFactory#getConnection(javax.resource.cci.ConnectionSpec)
* @see javax.resource.cci.ConnectionFactory#getConnection()
*/
protected Connection doGetConnection(ConnectionSpec spec) throws ResourceException {
if (getTargetConnectionFactory() == null) {
throw new IllegalStateException("targetConnectionFactory is required");
}
if (spec != null) {
return getTargetConnectionFactory().getConnection(spec);
}
else {
return getTargetConnectionFactory().getConnection();
}
}
示例4: setConnectionSpec
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public AbstractOutboundProcessor setConnectionSpec(String name, Properties props) {
try {
Class<?> clazz = getApplicationClassLoader().loadClass(name);
_connectionSpec = (ConnectionSpec) clazz.newInstance();
if (!props.isEmpty()) {
PropertyEditors.mapJavaBeanProperties(_connectionSpec, props);
}
} catch (Exception e) {
throw JCAMessages.MESSAGES.couldNotInitializeConnectionSpec(e);
}
return this;
}
示例5: getConnectionSpecClass
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
* Looks up and returns the specified class. First, it will try to get the class from the
* context class loader, if not found, it will try to get it from the current class loader.
*
* @param connectionSpecClass The fully qualified class name of the ConnectionSpec
* implementation.
* @return The Class object of the ConnectionSpec implementation
* @throws ClassNotFoundException - if the class could not be found.
* @throws IllegalArgumentException - if the class does not implement
* javax.resource.cci.ConnectionSpec.
*/
protected Class<? extends ConnectionSpec> getConnectionSpecClass(final String connectionSpecClass)
throws ClassNotFoundException {
Class<?> connSpecClass = ReflectionHelper.getClassForName(connectionSpecClass);
if (!ConnectionSpec.class.isAssignableFrom(connSpecClass)) {
throw new IllegalArgumentException(
connSpecClass.getName() + " does not implement " + ConnectionSpec.class);
}
//noinspection unchecked
return (Class<? extends ConnectionSpec>) connSpecClass;
}
示例6: newConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
private Connection newConnection() {
try {
if (credentials == null) {
return connectionFactory.getConnection();
} else {
ConnectionSpec connectionSpec = newConnectionSpecFactory(connectionSpecFactoryName)
.createConnectionSpec(credentials);
return connectionFactory.getConnection(connectionSpec);
}
} catch (ResourceException e) {
throw new HibersapException("Problem creating Connection", e);
}
}
示例7: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec properties) throws ResourceException {
ConnectionImpl connection = new ConnectionImpl(this, properties);
registerConnection(connection);
log.debug("connection={}", connection);
return connection;
}
示例8: ConnectionImpl
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
public ConnectionImpl(ConnectionFactoryImpl connectionFactoryImpl, ConnectionSpec properties) {
this.connectionFactory = connectionFactoryImpl;
this.connectionSpec = properties;
init();
processConnectionSpec(properties); // we probably need to extract userName from properties
connectionMetaData = new ConnectionMetaDataImpl(Constants.PRODUCT_NAME, Constants.PRODUCT_VERSION, null);
connectionFactoryImpl.registerConnection(this);
log.debug("properties={}", properties);
}
示例9: processConnectionSpec
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
private void processConnectionSpec(ConnectionSpec properties) {
if(properties == null)
return;
if((properties instanceof EisConnectionSpec) == false)
throw new IllegalArgumentException();
EisConnectionSpec connectionSpec = (EisConnectionSpec) properties;
log.debug("connectionSpec={}", connectionSpec);
}
示例10: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
public Connection getConnection(ConnectionSpec spec) throws ResourceException {
if (!(spec instanceof WebDAVConnectionSpec)) {
throw new NotSupportedException("Need a WebDAVConnectionSpec to create a connection!");
}
System.out.println("Getting connection with spec "+spec);
return (Connection) cm.allocateConnection(mcf, (WebDAVConnectionSpec)spec);
}
示例11: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException {
return getTargetConnectionFactory().getConnection(connectionSpec);
}
示例12: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException {
throw new NotSupportedException(
"SingleConnectionFactory does not support custom ConnectionSpec");
}
示例13: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
* Obtain a Connection from the given ConnectionFactory. Translates ResourceExceptions
* into the Spring hierarchy of unchecked generic data access exceptions, simplifying
* calling code and making any exception that is thrown more meaningful.
* <p>Is aware of a corresponding Connection bound to the current thread, for example
* when using {@link CciLocalTransactionManager}. Will bind a Connection to the thread
* if transaction synchronization is active (e.g. if in a JTA transaction).
* @param cf the ConnectionFactory to obtain Connection from
* @param spec the ConnectionSpec for the desired Connection (may be {@code null}).
* Note: If this is specified, a new Connection will be obtained for every call,
* without participating in a shared transactional Connection.
* @return a CCI Connection from the given ConnectionFactory
* @throws org.springframework.jca.cci.CannotGetCciConnectionException
* if the attempt to get a Connection failed
* @see #releaseConnection
*/
public static Connection getConnection(ConnectionFactory cf, ConnectionSpec spec)
throws CannotGetCciConnectionException {
try {
if (spec != null) {
Assert.notNull(cf, "No ConnectionFactory specified");
return cf.getConnection(spec);
}
else {
return doGetConnection(cf);
}
}
catch (ResourceException ex) {
throw new CannotGetCciConnectionException("Could not get CCI Connection", ex);
}
}
示例14: getConnectionSpec
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
* Return the CCI ConnectionSpec used by this template, if any.
*/
public ConnectionSpec getConnectionSpec() {
return this.connectionSpec;
}
示例15: getConnection
import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec spec) throws ResourceException {
DemoJCAConnectionSpec connectionSpec = (DemoJCAConnectionSpec) spec;
return new DemoConnection(connectionSpec);
}