本文整理汇总了Java中javax.resource.spi.ConnectionRequestInfo类的典型用法代码示例。如果您正苦于以下问题:Java ConnectionRequestInfo类的具体用法?Java ConnectionRequestInfo怎么用?Java ConnectionRequestInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConnectionRequestInfo类属于javax.resource.spi包,在下文中一共展示了ConnectionRequestInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getJmsCred
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的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: CredentialExtractor
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
public CredentialExtractor(Subject subject, ConnectionRequestInfo connectionRequestInfo, UserPasswordManagedConnectionFactory managedConnectionFactory) throws ResourceAdapterInternalException {
assert managedConnectionFactory != null;
if (connectionRequestInfo != null && !(connectionRequestInfo instanceof UserPasswordConnectionRequestInfo)) {
throw new ResourceAdapterInternalException("ConnectionRequestInfo must be a UserPasswordConnectionRequestInfo, not a " + connectionRequestInfo.getClass().getName());
}
if (subject != null) {
Set<PasswordCredential> credentials = subject.getPrivateCredentials(PasswordCredential.class);
for (PasswordCredential passwordCredential : credentials) {
if (managedConnectionFactory.equals(passwordCredential.getManagedConnectionFactory())) {
userName = passwordCredential.getUserName();
password = new String(passwordCredential.getPassword());
return;
}
}
throw new ResourceAdapterInternalException("No credential found for this ManagedConnectionFactory: " + managedConnectionFactory);
}
if (connectionRequestInfo != null && ((UserPasswordConnectionRequestInfo) connectionRequestInfo).getUserName() != null) {
userName = ((UserPasswordConnectionRequestInfo) connectionRequestInfo).getUserName();
password = ((UserPasswordConnectionRequestInfo) connectionRequestInfo).getPassword();
return;
}
userName = managedConnectionFactory.getUserName();
password = managedConnectionFactory.getPassword();
}
示例3: getConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
public Object getConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException {
// Check user first
String userName = credentialExtractor.getUserName();
CredentialExtractor credential = new CredentialExtractor(subject, connectionRequestInfo, mcf);
// Null users are allowed!
if (userName != null && !userName.equals(credential.getUserName())) {
throw new SecurityException("Password credentials not the same, reauthentication not allowed");
}
if (userName == null && credential.getUserName() != null) {
throw new SecurityException("Password credentials not the same, reauthentication not allowed");
}
CI handle = mcf.createConnectionHandle(connectionRequestInfo, (MC) this);
if (this.handle == null) {
this.handle = handle;
} else {
if (handles == null) {
handles = new LinkedList<>();
}
handles.add(handle);
}
this.subject = subject;
this.cri = connectionRequestInfo;
return handle;
}
示例4: getConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
public Object getConnection(Subject arg0, ConnectionRequestInfo arg1) throws ResourceException {
if (DEBUG) {
try {
throw new NullPointerException("Asif:JCAManagedConnection:getConnection");
} catch (NullPointerException npe) {
npe.printStackTrace();
}
}
try {
if (!this.initDone || this.cache.isClosed()) {
init();
}
LogWriter logger = this.cache.getLogger();
if (logger.fineEnabled()) {
logger.fine("JCAManagedConnection:getConnection. Returning new Connection");
}
GFConnectionImpl conn = new GFConnectionImpl(this);
this.connections.add(conn);
return conn;
} catch (SystemException e) {
this.onError(e);
throw new ResourceException("GemFire Resource unavailable", e);
}
}
示例5: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
/**
* Returns a matched connection from the candidate set of connections.
*
* @param connectionSet
* Candidate connection set
* @param subject
* Caller's security information
* @param cxRequestInfo
* Additional resource adapter specific connection request
* information
* @throws ResourceException
* generic exception
* @return ManagedConnection if resource adapter finds an acceptable match
* otherwise null
*/
public ManagedConnection matchManagedConnections(Set connectionSet,
Subject subject, ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
log.tracef("matchManagedConnections(%s, %s, %s)", connectionSet, subject,
cxRequestInfo);
ManagedConnection result = null;
Iterator it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = (ManagedConnection) it.next();
if (mc instanceof RabbitmqManagedConnection) {
result = mc;
}
}
return result;
}
示例6: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject,
ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
logger.debug("matching a managed connection");
logger.debug("connectionSet.size: " + connectionSet.size());
logger.debug("Subject: " + subject);
for (ManagedConnection mc : (Set<ManagedConnection>) connectionSet) {
logger.debug("trying to match: " + mc);
if (mc instanceof SftpOneDataStorageManagedConnection) {
logger.debug("match found: " + mc);
return mc;
}
}
logger.debug("match not found");
return null;
}
示例7: createManagedConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
@Override
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
logger.debug("creating a managed connection");
logger.debug("Subject: " + subject);
logger.debug("ConnectionRequestInfo: " + cxRequestInfo);
DataStorageManagedConnection managedConnection = null;
if (roots.size() > 1) {
managedConnection = new FSMultiDataStorageManagedConnection(roots, redundancy,
(FSDataStorageConnectionRequestInfo) cxRequestInfo);
} else {
managedConnection = new FSOneDataStorageManagedConnection(roots.iterator().next(),
(FSDataStorageConnectionRequestInfo) cxRequestInfo);
}
logger.debug("cerated: " + managedConnection);
return managedConnection;
}
示例8: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject,
ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
logger.debug("matching a managed connection");
logger.debug("connectionSet.size: " + connectionSet.size());
logger.debug("Subject: " + subject);
for (ManagedConnection mc : (Set<ManagedConnection>) connectionSet) {
logger.debug("trying to match: " + mc);
if (mc instanceof FSOneDataStorageManagedConnection || mc instanceof FSMultiDataStorageManagedConnection) {
logger.debug("match found: " + mc);
return mc;
}
}
logger.debug("match not found");
return null;
}
示例9: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
@Override
@SuppressWarnings({ "rawtypes", "unchecked" })
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject,
ConnectionRequestInfo cxRequestInfo)
throws ResourceException {
logger.debug("matching a managed connection");
logger.debug("connectionSet.size: " + connectionSet.size());
logger.debug("Subject: " + subject);
for (ManagedConnection mc : (Set<ManagedConnection>) connectionSet) {
logger.debug("trying to match: " + mc);
if (mc instanceof OwlimSemanticRepositoryManagedConnection) {
logger.debug("match found: " + mc);
return mc;
}
}
logger.debug("match not found");
return null;
}
示例10: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
lazyInit();
ManagedConnection result = null;
Iterator<ManagedConnection> it = connectionSet.iterator();
while (result == null && it.hasNext()) {
ManagedConnection mc = it.next();
if (mc instanceof ManagedTransactionAssistance) {
if(cxRequestInfo != null /*&& TODO future: it contains the ID*/){
ManagedTransactionAssistance mta = (ManagedTransactionAssistance)mc;
/*
if(cxRequestInfo.requiredMCFId().equals(mta.getManagedConnectionFactoryId()){
result = mc;
}
*/
}
}
}
return result;
}
示例11: allocateConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的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;
}
示例12: createManagedConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
/**
* Creates a new physical connection to the underlying EIS resource manager.
*
* @param subject Caller's security information
* @param cxRequestInfo Additional resource adapter specific connection request information
* @return The managed connection
* @throws ResourceException Thrown if a managed connection can't be created
*/
@Override
public ManagedConnection createManagedConnection(final Subject subject,
final ConnectionRequestInfo cxRequestInfo) throws ResourceException {
if (ActiveMQRAManagedConnectionFactory.trace) {
ActiveMQRALogger.LOGGER.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")");
}
ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo);
ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri);
if (ActiveMQRAManagedConnectionFactory.trace) {
ActiveMQRALogger.LOGGER.trace("jms credential: " + credential);
}
ActiveMQRAManagedConnection mc = new ActiveMQRAManagedConnection(this, cri, ra, credential.getUserName(), credential.getPassword());
if (ActiveMQRAManagedConnectionFactory.trace) {
ActiveMQRALogger.LOGGER.trace("created new managed connection: " + mc);
}
registerRecovery();
return mc;
}
示例13: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
public ManagedConnection
matchManagedConnections(Set connectionSet,
Subject subject,
ConnectionRequestInfo info)
throws ResourceException {
JERequestInfo jeInfo = (JERequestInfo) info;
Iterator iter = connectionSet.iterator();
while (iter.hasNext()) {
Object next = iter.next();
if (next instanceof JEManagedConnection) {
JEManagedConnection mc = (JEManagedConnection) next;
EnvironmentImpl nextEnvImpl =
DbInternal.envGetEnvironmentImpl(mc.getEnvironment());
/* Do we need to match on more than root dir and r/o? */
if (nextEnvImpl.getEnvironmentHome().
equals(jeInfo.getJERootDir()) &&
nextEnvImpl.isReadOnly() ==
jeInfo.getEnvConfig().getReadOnly()) {
return mc;
}
}
}
return null;
}
示例14: createManagedConnection
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
/**
* return a new managed connection. This connection is wrapped around the real connection and delegates to it
* to get work done.
* @param subject
* @param info
* @return
*/
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo info)
{
Util.log("In OTMJCAManagedConnectionFactory.createManagedConnection");
try
{
Kit kit = getKit();
PBKey key = ((OTMConnectionRequestInfo) info).getPbKey();
OTMConnection connection = kit.acquireConnection(key);
return new OTMJCAManagedConnection(this, connection, key);
}
catch (ResourceException e)
{
throw new OTMConnectionRuntimeException(e.getMessage());
}
}
示例15: matchManagedConnections
import javax.resource.spi.ConnectionRequestInfo; //导入依赖的package包/类
public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo info)
throws ResourceException
{
Util.log("OTMJCAManagedConnectionFactory::matchManagedConnections called with " + connectionSet.size() + " connections.");
for (Iterator i = connectionSet.iterator(); i.hasNext();)
{
Object o = i.next();
if (o instanceof OTMJCAManagedConnection)
{
// all idle connections are identical
return (OTMJCAManagedConnection) o;
}
}
Util.log("OTMJCAManagedConnectionFactory::No matched connections");
return null;
}