当前位置: 首页>>代码示例>>Java>>正文


Java ConnectionSpec类代码示例

本文整理汇总了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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:27,代码来源:CciTemplateTests.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:17,代码来源:ConnectionSpecConnectionFactoryAdapter.java

示例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();
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:ConnectionSpecConnectionFactoryAdapter.java

示例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;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:15,代码来源:CCIProcessor.java

示例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;
}
 
开发者ID:hibersap,项目名称:hibersap,代码行数:24,代码来源:AbstractConnectionSpecFactory.java

示例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);
    }
}
 
开发者ID:hibersap,项目名称:hibersap,代码行数:14,代码来源:ConnectionProvider.java

示例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;
}
 
开发者ID:dlmiles,项目名称:full-example-ee7-jca-eis,代码行数:8,代码来源:ConnectionFactoryImpl.java

示例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);
}
 
开发者ID:dlmiles,项目名称:full-example-ee7-jca-eis,代码行数:12,代码来源:ConnectionImpl.java

示例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);
}
 
开发者ID:dlmiles,项目名称:full-example-ee7-jca-eis,代码行数:9,代码来源:ConnectionImpl.java

示例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);
}
 
开发者ID:integrated,项目名称:jakarta-slide-webdavclient,代码行数:8,代码来源:WebDAVConnectionFactory.java

示例11: getConnection

import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec connectionSpec) throws ResourceException {
	return getTargetConnectionFactory().getConnection(connectionSpec);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:5,代码来源:DelegatingConnectionFactory.java

示例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");
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:6,代码来源:SingleConnectionFactory.java

示例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);
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:ConnectionFactoryUtils.java

示例14: getConnectionSpec

import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
/**
 * Return the CCI ConnectionSpec used by this template, if any.
 */
public ConnectionSpec getConnectionSpec() {
	return this.connectionSpec;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:7,代码来源:CciTemplate.java

示例15: getConnection

import javax.resource.cci.ConnectionSpec; //导入依赖的package包/类
@Override
public Connection getConnection(ConnectionSpec spec) throws ResourceException {
	DemoJCAConnectionSpec connectionSpec = (DemoJCAConnectionSpec) spec;
	return new DemoConnection(connectionSpec);
}
 
开发者ID:rhulha,项目名称:EclipseLinkNoSQLDemoPlugin,代码行数:6,代码来源:DemoConnectionFactory.java


注:本文中的javax.resource.cci.ConnectionSpec类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。