javax.resource.spi.ConnectionRequestInfo Java Examples
The following examples show how to use
javax.resource.spi.ConnectionRequestInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPrefillPool.java From lams with GNU General Public License v2.0 | 6 votes |
/** * {@inheritDoc} */ public void prefill(Subject subject, ConnectionRequestInfo cri, boolean noTxnSeperatePool) { if (shouldPrefill) { if (log.isDebugEnabled()) log.debug("Attempting to prefill pool: " + getName()); try { //Get pool key Object key = getKey(subject, cri, noTxnSeperatePool); //Get pool automatically initializes pool getManagedConnectionPool(key, subject, cri); } catch (Throwable t) { //No real need to throw here being that pool remains in the same state as before. log.error("Unable to prefill pool: " + getName(), t); } } }
Example #2
Source File: ActiveMQRAConnectionManager.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * 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 (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("allocateConnection(" + mcf + ", " + cxRequestInfo + ")"); } ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo); Object c = mc.getConnection(null, cxRequestInfo); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("Allocated connection: " + c + ", with managed connection: " + mc); } connections.add(mc); return c; }
Example #3
Source File: ManagedConnectionImpl.java From cxf with Apache License 2.0 | 6 votes |
public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (LOG.isLoggable(Level.FINER)) { LOG.finer("get handle for subject=" + subject + " cxRequestInfo=" + cxRequestInfo); } if (isClosed) { throw new ResourceException("connection has been closed"); } // check request info if (!connReqInfo.equals(cxRequestInfo)) { throw new ResourceException("connection request info: " + cxRequestInfo + " does not match " + connReqInfo); } CXFConnectionSpec spec = (CXFConnectionSpec)cxRequestInfo; Object handle = createConnectionHandle(spec); handles.put(handle, subject); associatedHandle = handle; return handle; }
Example #4
Source File: ActiveMQRAManagedConnectionFactory.java From activemq-artemis with Apache License 2.0 | 6 votes |
/** * 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 (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("createManagedConnection(" + subject + ", " + cxRequestInfo + ")"); } ActiveMQRAConnectionRequestInfo cri = getCRI((ActiveMQRAConnectionRequestInfo) cxRequestInfo); ActiveMQRACredential credential = ActiveMQRACredential.getCredential(this, subject, cri); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("jms credential: " + credential); } ActiveMQRAManagedConnection mc = new ActiveMQRAManagedConnection(this, cri, ra, credential.getUserName(), credential.getPassword()); if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("created new managed connection: " + mc); } registerRecovery(); return mc; }
Example #5
Source File: ManagedConnectionImpl.java From cxf with Apache License 2.0 | 6 votes |
public Object getConnection(Subject subject, ConnectionRequestInfo crInfo) throws ResourceException { Object connection = null; if (getCXFService() == null) { initializeCXFConnection(crInfo, subject); connection = getCXFService(); } else { if (!connectionHandleActive && this.crinfo.equals(crInfo)) { connection = getCXFService(); } else { connection = getCXFConnection(subject, crInfo); } } connectionHandleActive = true; return connection; }
Example #6
Source File: ManagedTransactionAssistanceFactory.java From genericconnector with Apache License 2.0 | 6 votes |
@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; }
Example #7
Source File: AbstractManagedConnectionFactoryImpl.java From cxf with Apache License 2.0 | 6 votes |
private boolean isMatch(final AbstractManagedConnectionImpl candidateConn, final ConnectionRequestInfo crInfo, final Subject subject) throws ResourceAdapterInternalException { boolean result = false; final ConnectionRequestInfo candidate = candidateConn.getConnectionRequestInfo(); if (candidate.equals(crInfo) && (subject == null || subject.equals(candidateConn.getSubject()))) { try { validateReference(candidateConn, subject); result = true; } catch (Exception thrown) { result = false; } } return result; }
Example #8
Source File: SemaphoreArrayListManagedConnectionPool.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Create a connection event listener * * @param subject the subject * @param cri the connection request information * @return the new listener * @throws ResourceException for any error */ private ConnectionListener createConnectionEventListener(Subject subject, ConnectionRequestInfo cri) throws ResourceException { long start = pool.getInternalStatistics().isEnabled() ? System.currentTimeMillis() : 0L; ManagedConnection mc = mcf.createManagedConnection(subject, cri); if (pool.getInternalStatistics().isEnabled()) { pool.getInternalStatistics().deltaTotalCreationTime(System.currentTimeMillis() - start); pool.getInternalStatistics().deltaCreatedCount(); } try { return cm.createConnectionListener(mc, this); } catch (ResourceException re) { if (pool.getInternalStatistics().isEnabled()) pool.getInternalStatistics().deltaDestroyedCount(); mc.destroy(); throw re; } }
Example #9
Source File: CapacityRequest.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Constructor * @param mcp The managed connection pool * @param subject The subject * @param cri The connection request info object */ CapacityRequest(ManagedConnectionPool mcp, Subject subject, ConnectionRequestInfo cri) { this.mcp = mcp; this.subject = subject; this.cri = cri; }
Example #10
Source File: LeakDumperManagedConnectionPool.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public ConnectionListener getConnection(Subject subject, ConnectionRequestInfo cri) throws ResourceException { ConnectionListener cl = super.getConnection(subject, cri); tracker.put(cl, new Throwable("ALLOCATION LEAK")); times.put(cl, Long.valueOf(System.currentTimeMillis())); return cl; }
Example #11
Source File: DefaultConnectionManager.java From cxf with Apache License 2.0 | 5 votes |
public Object allocateConnection(ManagedConnectionFactory mcf, ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("allocateConnection cxRequestInfo = " + cxRequestInfo); } ManagedConnection mc = mcf.createManagedConnection(null, cxRequestInfo); mc.addConnectionEventListener(this); return mc.getConnection(null, cxRequestInfo); }
Example #12
Source File: SemaphoreConcurrentLinkedDequeManagedConnectionPool.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a connection event listener * * @param subject * the subject * @param cri * the connection request information * @return the new listener * @throws ResourceException * for any error */ private ConnectionListener createConnectionEventListener(Subject subject, ConnectionRequestInfo cri) throws ResourceException { long start = pool.getInternalStatistics().isEnabled() ? System.currentTimeMillis() : 0L; ManagedConnection mc = mcf.createManagedConnection(subject, cri); if (pool.getInternalStatistics().isEnabled()) { pool.getInternalStatistics().deltaTotalCreationTime(System.currentTimeMillis() - start); pool.getInternalStatistics().deltaCreatedCount(); } try { ConnectionListener cl = cm.createConnectionListener(mc, this); poolSize.incrementAndGet(); return cl; } catch (ResourceException re) { if (pool.getInternalStatistics().isEnabled()) pool.getInternalStatistics().deltaDestroyedCount(); mc.destroy(); throw re; } }
Example #13
Source File: ManagedConnectionPoolFactory.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Create a managed connection pool using a specific implementation strategy * * @param strategy Fullt qualified class name for the managed connection pool strategy * @param mcf the managed connection factory * @param cm the connection manager * @param subject the subject * @param cri the connection request info * @param pc the pool configuration * @param p The pool * @return The initialized managed connection pool * @exception Throwable Thrown in case of an error */ public ManagedConnectionPool create(String strategy, ManagedConnectionFactory mcf, ConnectionManager cm, Subject subject, ConnectionRequestInfo cri, PoolConfiguration pc, Pool p) throws Throwable { Class<?> clz = Class.forName(strategy, true, SecurityActions.getClassLoader(ManagedConnectionPoolFactory.class)); ManagedConnectionPool mcp = (ManagedConnectionPool)clz.newInstance(); return init(mcp, mcf, cm, subject, cri, pc, p); }
Example #14
Source File: DummyManagedConnectionImpl.java From cxf with Apache License 2.0 | 5 votes |
public DummyManagedConnectionImpl( AbstractManagedConnectionFactoryImpl managedFactory, ConnectionRequestInfo crInfo, Subject subject) throws ResourceException { super(managedFactory, crInfo, subject); // trun off the noise error logger LOG.setLevel(Level.OFF); }
Example #15
Source File: ManagedConnectionFactoryImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testMatchConnectionDifferentConnectioRequestInfoNotBound() throws Exception { ConnectionRequestInfo cri1 = new DummyConnectionRequestInfo(); ConnectionRequestInfo cri2 = new DummyConnectionRequestInfo(); Subject subject = null; assertTrue("request info object are differnt", cri1 != cri2); Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>(); DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri1, subject); connectionSet.add(con1); ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri2); assertEquals("incorrect connection returned", con1, mcon); }
Example #16
Source File: AbstractManagedConnectionFactoryImpl.java From cxf with Apache License 2.0 | 5 votes |
@SuppressWarnings("rawtypes") public ManagedConnection matchManagedConnections( Set aMCSet, Subject subject, ConnectionRequestInfo crInfo) throws ResourceException { LOG.log(Level.FINE, "MATCHING_CONNECTIONS", new Object[] {Integer.valueOf(aMCSet.size()), crInfo, subject}); for (Iterator iterator = aMCSet.iterator(); iterator.hasNext();) { AbstractManagedConnectionImpl conn = (AbstractManagedConnectionImpl)iterator.next(); LOG.log(Level.FINE, "MATCH_CONNECTION_AGAINST", new Object[] {conn.getConnectionRequestInfo(), crInfo}); if (!conn.isBound()) { LOG.fine("Match against unbounded, con= " + conn + ", info=" + crInfo); return conn; } if (isMatch(conn, crInfo, subject)) { LOG.fine("Match against bounded, con= " + conn + ", info=" + crInfo); return conn; } } return null; }
Example #17
Source File: ManagedPoolCacheImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #18
Source File: AbstractManagedConnectionImpl.java From cxf with Apache License 2.0 | 5 votes |
public AbstractManagedConnectionImpl(AbstractManagedConnectionFactoryImpl managedFactory, ConnectionRequestInfo crInfo, Subject sj) throws ResourceException { this.managedConnectionFactory = managedFactory; this.crinfo = crInfo; this.subject = sj; }
Example #19
Source File: ActiveMQRACredential.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Get credentials * * @param mcf The managed connection factory * @param subject The subject * @param info The connection request info * @return The credentials * @throws SecurityException Thrown if the credentials can't be retrieved */ public static ActiveMQRACredential getCredential(final ManagedConnectionFactory mcf, final Subject subject, final ConnectionRequestInfo info) throws SecurityException { if (ActiveMQRALogger.LOGGER.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getCredential(" + mcf + ", " + subject + ", " + info + ")"); } ActiveMQRACredential jc = new ActiveMQRACredential(); if (subject == null && info != null) { jc.setUserName(((ActiveMQRAConnectionRequestInfo) info).getUserName()); jc.setPassword(((ActiveMQRAConnectionRequestInfo) info).getPassword()); } else if (subject != null) { PasswordCredential pwdc = GetCredentialAction.getCredential(subject, mcf); if (pwdc == null) { throw new SecurityException("No password credentials found"); } jc.setUserName(pwdc.getUserName()); jc.setPassword(new String(pwdc.getPassword())); } else { throw new SecurityException("No Subject or ConnectionRequestInfo set, could not get credentials"); } return jc; }
Example #20
Source File: ReauthPool.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected synchronized Object getKey(Subject subject, ConnectionRequestInfo cri, boolean separateNoTx) throws ResourceException { return new ReauthKey(subject, cri, separateNoTx); }
Example #21
Source File: ActiveMQRAManagedConnection.java From activemq-artemis with Apache License 2.0 | 5 votes |
/** * Get a connection * * @param subject The security subject * @param cxRequestInfo The request info * @return The connection * @throws ResourceException Thrown if an error occurs */ @Override public synchronized Object getConnection(final Subject subject, final ConnectionRequestInfo cxRequestInfo) throws ResourceException { if (logger.isTraceEnabled()) { ActiveMQRALogger.LOGGER.trace("getConnection(" + subject + ", " + cxRequestInfo + ")"); } // Check user first ActiveMQRACredential credential = ActiveMQRACredential.getCredential(mcf, subject, cxRequestInfo); // 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"); } if (isDestroyed.get()) { throw new IllegalStateException("The managed connection is already destroyed"); } ActiveMQRASession session = new ActiveMQRASession(this, (ActiveMQRAConnectionRequestInfo) cxRequestInfo); handles.add(session); return session; }
Example #22
Source File: ManagedConnectionFactoryImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testMatchConnectionSameConnectioRequestInfoBound() throws Exception { Subject subject = null; Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>(); ConnectionRequestInfo cri = new DummyConnectionRequestInfo(); DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri, subject); con1.setBound(true); connectionSet.add(con1); ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri); assertEquals(con1, mcon); }
Example #23
Source File: MiniContainer.java From genericconnector with Apache License 2.0 | 5 votes |
/** sets up the resource adapter and associated classes in the same way that the real container does it */ public MiniContainer(boolean handleRecoveryInternally, String minAgeOfTransactionBeforeRelevantForRecovery) throws ResourceException { adapter.start(null); //TODO parameters adapter.endpointActivation(null, null); //TODO parameters mtaf = new ManagedTransactionAssistanceFactory(); if(handleRecoveryInternally){ mtaf.setHandleRecoveryInternally("true"); mtaf.setRecoveryStatePersistenceDirectory(System.getProperty("java.io.tmpdir")); }else{ mtaf.setHandleRecoveryInternally("false"); } mtaf.setMinAgeOfTransactionBeforeRelevantForRecovery(minAgeOfTransactionBeforeRelevantForRecovery); mtaf.setResourceAdapter(adapter); mtaf.setId("A"); cm = new ConnectionManager() { private static final long serialVersionUID = 1L; @Override public Object allocateConnection(ManagedConnectionFactory arg0, ConnectionRequestInfo arg1) throws ResourceException { if(tx.get() == null) throw new IllegalStateException("please start a transaction before opening a connection"); ManagedTransactionAssistance mta = (ManagedTransactionAssistance) mtaf.createManagedConnection(null, null); XAResource xa = mta.getXAResource(); tx.get().xaResources.add(xa); try { xa.start(tx.get().xid, 0); } catch (XAException e) { e.printStackTrace(); throw new ResourceException(e); } return new TransactionAssistantImpl(mta); } }; }
Example #24
Source File: OnePool.java From lams with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override protected Object getKey(final Subject subject, final ConnectionRequestInfo cri, boolean separateNoTx) { if (separateNoTx) { return Boolean.TRUE; } else { return Boolean.FALSE; } }
Example #25
Source File: ManagedTransactionAssistance.java From genericconnector with Apache License 2.0 | 5 votes |
@Override public Object getConnection(Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException { //during recovery, currentTxId and executeWasSuccessful are unknown, so we cannot check them like this: //if(currentTxId == null) throw new IllegalStateException("transaction not started?"); //if(executeWasSuccessful != null) throw new IllegalStateException("did you forget to call close?"); return connection; }
Example #26
Source File: JCAManagedConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
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); } }
Example #27
Source File: ManagedPoolCacheImpl.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
/** * 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(); }
Example #28
Source File: ManagedConnectionFactoryImplTest.java From cxf with Apache License 2.0 | 5 votes |
@Test public void testMatchConnectionSameConnectioRequestInfoNotBound() throws Exception { Subject subject = null; Set<AbstractManagedConnectionImpl> connectionSet = new HashSet<>(); ConnectionRequestInfo cri = new DummyConnectionRequestInfo(); DummyManagedConnectionImpl con1 = new DummyManagedConnectionImpl(mcf, cri, subject); connectionSet.add(con1); ManagedConnection mcon = mcf.matchManagedConnections(connectionSet, subject, cri); assertEquals(con1, mcon); }
Example #29
Source File: JCAManagedConnection.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
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); } }
Example #30
Source File: XAMCF.java From dacapobench with Apache License 2.0 | 5 votes |
public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo connectionRequestInfo) throws ResourceException { CredentialExtractor credentialExtractor = new CredentialExtractor(subject, connectionRequestInfo, this); XAConnection sqlConnection = getPhysicalConnection(subject, credentialExtractor); try { return new ManagedXAConnection(this, sqlConnection, credentialExtractor, exceptionSorter); } catch (SQLException e) { throw new ResourceAdapterInternalException("Could not set up ManagedXAConnection", e); } }