本文整理汇总了Java中javax.resource.spi.ManagedConnectionFactory类的典型用法代码示例。如果您正苦于以下问题:Java ManagedConnectionFactory类的具体用法?Java ManagedConnectionFactory怎么用?Java ManagedConnectionFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ManagedConnectionFactory类属于javax.resource.spi包,在下文中一共展示了ManagedConnectionFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJmsCred
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Get our own simple cred
*/
public static JmsCred getJmsCred(ManagedConnectionFactory mcf, Subject subject, ConnectionRequestInfo info) throws SecurityException {
JmsCred jc = new JmsCred();
if (subject == null && info != null) {
// Credentials specifyed on connection request
jc.name = ((JmsConnectionRequestInfo) info).getUserName();
jc.pwd = ((JmsConnectionRequestInfo) info).getPassword();
} else if (subject != null) {
// Credentials from appserver
PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf);
if (pwdc == null) {
// No hit - we do need creds
throw new SecurityException("No Password credentials found");
}
jc.name = pwdc.getUserName();
jc.pwd = new String(pwdc.getPassword());
} else {
throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials");
}
return jc;
}
示例2: allocateConnection
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Allocates a connection
*
* @param mcf The managed connection factory
* @param cxRequestInfo The connection request information
* @return The connection
* @throws ResourceException Thrown if there is a problem obtaining the connection
*/
@Override
public Object allocateConnection(final ManagedConnectionFactory mcf,
final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
if (ActiveMQRAConnectionManager.trace) {
ActiveMQRALogger.LOGGER.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")");
}
ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
Object c = mc.getConnection(null, cxRequestInfo);
if (ActiveMQRAConnectionManager.trace) {
ActiveMQRALogger.LOGGER.trace("Allocated connection: " + c + ", with managed connection: " + mc);
}
connections.add(mc);
return c;
}
示例3: validate
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Validate
* @param v The validate object
* @param rb The resource bundle
* @return The list of failures found; <code>null</code> if none
*/
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate v, ResourceBundle rb)
{
if (v != null &&
Key.MANAGED_CONNECTION_FACTORY == v.getKey() &&
v.getClazz() != null &&
ManagedConnectionFactory.class.isAssignableFrom(v.getClazz()))
{
ValidateClass vo = (ValidateClass)v;
if (vo.getConfigProperties() != null && !vo.getConfigProperties().isEmpty())
{
return ConfigPropertiesHelper.validateConfigPropertiesType(vo, SECTION,
rb.getString("mcf.MCFConfigProperties"));
}
}
return null;
}
示例4: validate
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Validate
* @param vo The validate object
* @param rb The resource bundle
* @return The list of failures found; <code>null</code> if none
*/
@SuppressWarnings("unchecked")
public List<Failure> validate(Validate vo, ResourceBundle rb)
{
if (vo != null && Key.MANAGED_CONNECTION_FACTORY == vo.getKey())
{
if (vo.getClazz() != null)
{
if (!ManagedConnectionFactory.class.isAssignableFrom(vo.getClazz()))
{
List<Failure> failures = new ArrayList<Failure>(1);
Failure failure = new Failure(Severity.ERROR,
SECTION,
rb.getString("mcf.MCF"),
vo.getClazz().getName());
failures.add(failure);
return failures;
}
}
}
return null;
}
示例5: hasMcfTransactionSupport
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* hasMcfTransactionSupport
*
* @param out output stream
* @param error output stream
* @param classname classname
* @param cl classloader
*/
private static void hasMcfTransactionSupport(PrintStream out, PrintStream error, String classname, URLClassLoader cl)
{
try
{
out.print(" TransactionSupport: ");
Class<?> mcfClz = Class.forName(classname, true, cl);
ManagedConnectionFactory mcf = (ManagedConnectionFactory)mcfClz.newInstance();
if (hasInterface(mcf.getClass(), "javax.resource.spi.TransactionSupport"))
{
out.println("Yes");
}
else
{
out.println("No");
}
}
catch (Throwable t)
{
// Nothing we can do
t.printStackTrace(error);
out.println("Unknown");
}
}
示例6: allocateConnection
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cri) throws ResourceException
{
if (shutdown.get())
throw new ResourceException();
Credential credential;
if (subjectFactory == null || cmConfiguration.getSecurityDomain() == null)
{
credential = new Credential(null, cri);
}
else
{
credential = new Credential(SecurityActions.createSubject(subjectFactory,
cmConfiguration.getSecurityDomain(),
mcf),
cri);
}
org.ironjacamar.core.connectionmanager.listener.ConnectionListener cl = getConnectionListener(credential);
Object connection = cl.getConnection();
if (ccm != null)
ccm.registerConnection(this, cl, connection);
return connection;
}
示例7: createConnectionManager
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Create a connection manager
* @param tse The transaction support level
* @param mcf The managed connection factory
* @param ccm The cached connection manager
* @param cmc The connection manager configuration
* @param ti The transaction integration
* @return The connection manager
*/
public static ConnectionManager createConnectionManager(TransactionSupportEnum tse,
ManagedConnectionFactory mcf,
CachedConnectionManager ccm,
ConnectionManagerConfiguration cmc,
TransactionIntegration ti)
{
if (tse == TransactionSupportEnum.NoTransaction)
{
return new NoTransactionConnectionManager(mcf, ccm, cmc);
}
else if (tse == TransactionSupportEnum.LocalTransaction)
{
return new LocalTransactionConnectionManager(mcf, ccm, cmc, ti);
}
else
{
return new XATransactionConnectionManager(mcf, ccm, cmc, ti);
}
}
示例8: allocateConnection
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Allocate a new connection.
*
* @param mcf
* @param cxRequestInfo
* @return A new connection
* @throws ResourceException Failed to create connection.
*/
public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
boolean trace = log.isTraceEnabled();
if (trace) {
log.trace("Allocating connection; mcf=" + mcf + ", cxRequestInfo=" + cxRequestInfo);
}
ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo);
Object c = mc.getConnection(null, cxRequestInfo);
if (trace) {
log.trace("Allocated connection: " + c + ", with managed connection: " + mc);
}
return c;
}
示例9: JmsConnectionFactoryImpl
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
public JmsConnectionFactoryImpl(final ManagedConnectionFactory mcf, final ConnectionManager cm) {
this.mcf = mcf;
boolean trace = log.isTraceEnabled();
if (cm == null) {
// This is standalone usage, no appserver
this.cm = new JmsConnectionManager();
if (trace) {
log.trace("Created new connection manager");
}
} else {
this.cm = cm;
}
if (trace) {
log.trace("Using ManagedConnectionFactory=" + mcf + ", ConnectionManager=" + cm);
}
}
示例10: JmsSessionFactoryImpl
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
public JmsSessionFactoryImpl(final ManagedConnectionFactory mcf,
final ConnectionManager cm,
final int type) {
this.mcf = (JmsManagedConnectionFactory) mcf;
this.cm = cm;
if (cm == null)
// This is standalone usage, no appserver
this.cm = new JmsConnectionManager();
else
this.cm = cm;
this.type = type;
if (trace)
log.trace("mcf=" + mcf + ", cm=" + cm + ", type=" + type);
}
示例11: allocateConnection
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* in: jms != null, is a deployed jms
* out: useable connection object.
*/
public Object allocateConnection(ManagedConnectionFactory managedConnectionFactory,
ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
assert managedConnectionFactory == this.managedConnectionFactory;
Subject subject = subjectSource != null ? subjectSource.getSubject() : null;
return allocateConnection(subject, connectionRequestInfo);
}
示例12: JCAConnectionManagerImpl
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
public JCAConnectionManagerImpl(ManagedConnectionFactory mcf,
ConfiguredDataSourceProperties configs) {
// Get the security info and form the Subject
// Initialize the Pool.
try {
isActive = true;
mannPoolCache = new ManagedPoolCacheImpl(mcf, null, null, this, configs);
} catch (Exception ex) {
logger.fatal(LocalizedMessage.create(
LocalizedStrings.JCAConnectionManagerImpl_EXCEPTION_CAUGHT_WHILE_INITIALIZING,
ex.getLocalizedMessage()), ex);
}
}
示例13: FacetsJCAConnectionManagerImpl
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
public FacetsJCAConnectionManagerImpl(ManagedConnectionFactory mcf,
ConfiguredDataSourceProperties configs) {
// Get the security info and form the Subject
// Initialize the Pool.
try {
isActive = true;
mannPoolCache = new ManagedPoolCacheImpl(mcf, null, null, this, configs);
} catch (Exception ex) {
logger.fatal(LocalizedMessage.create(
LocalizedStrings.FacetsJCAConnectionManagerImpl_FACETSJCACONNECTIONMANAGERIMPL_CONSTRUCTOR_AN_EXCEPTION_WAS_CAUGHT_WHILE_INITIALIZING_DUE_TO_0,
ex.getMessage()), ex);
}
}
示例14: ManagedPoolCacheImpl
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
/**
* Constructor initializes the ConnectionPoolCacheImpl properties.
*/
public ManagedPoolCacheImpl(ManagedConnectionFactory connFac, Subject subject,
ConnectionRequestInfo connReq, javax.resource.spi.ConnectionEventListener eventListner,
ConfiguredDataSourceProperties configs) throws PoolException {
super(eventListner, configs);
connFactory = connFac;
sub = subject;
connReqInfo = connReq;
initializePool();
}
示例15: testCreatesVanillaConnectionFactoryIfNoConnectionManagerHasBeenConfigured
import javax.resource.spi.ManagedConnectionFactory; //导入依赖的package包/类
@Test
public void testCreatesVanillaConnectionFactoryIfNoConnectionManagerHasBeenConfigured() throws Exception {
final Object CONNECTION_FACTORY = new Object();
ManagedConnectionFactory managedConnectionFactory = mock(ManagedConnectionFactory.class);
given(managedConnectionFactory.createConnectionFactory()).willReturn(CONNECTION_FACTORY);
LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean();
factory.setManagedConnectionFactory(managedConnectionFactory);
factory.afterPropertiesSet();
assertEquals(CONNECTION_FACTORY, factory.getObject());
}