Package javax.resource.spi

Examples of javax.resource.spi.ManagedConnection


            if (connectionInfo.isUnshareable()) {
                //if one is, they all are
                return;
            }
            ManagedConnectionInfo managedConnectionInfo = connectionInfo.getManagedConnectionInfo();
            ManagedConnection managedConnection = managedConnectionInfo.getManagedConnection();
            if (managedConnection instanceof DissociatableManagedConnection
                    && managedConnectionInfo.isFirstConnectionInfo(connectionInfo)) {
                int size = connectionInfos.size();
                i.remove();
                assert size - 1 == connectionInfos.size();
View Full Code Here


    public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
        ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
        if (mci.getManagedConnection() != null) {
            return;
        }
        ManagedConnection mc =
                mci.getManagedConnectionFactory().createManagedConnection(
                        mci.getSubject(),
                        mci.getConnectionRequestInfo());
        mci.setManagedConnection(mc);
        GeronimoConnectionEventListener listener = new GeronimoConnectionEventListener(stack, mci);
        mci.setConnectionEventListener(listener);
        mc.addConnectionEventListener(listener);
    }
View Full Code Here

    public void returnConnection(
            ConnectionInfo connectionInfo,
            ConnectionReturnAction connectionReturnAction) {
        ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
        ManagedConnection mc = mci.getManagedConnection();
        try {
            mc.destroy();
        } catch (ResourceException e) {
            //log and forget
        } catch (Error e) {
            throw e;
        } catch (Throwable t) {
View Full Code Here

            }
            try {
                if (!pool.isEmpty()) {
                    ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
                    ManagedConnectionFactory managedConnectionFactory = mci.getManagedConnectionFactory();
                    ManagedConnection matchedMC =
                            managedConnectionFactory
                            .matchManagedConnections(pool.keySet(),
                                    mci.getSubject(),
                                    mci.getConnectionRequestInfo());
                    if (matchedMC != null) {
View Full Code Here

        }
    }

    protected boolean internalReturn(ConnectionInfo connectionInfo, ConnectionReturnAction connectionReturnAction) {
        ManagedConnectionInfo mci = connectionInfo.getManagedConnectionInfo();
        ManagedConnection mc = mci.getManagedConnection();
        try {
            mc.cleanup();
        } catch (ResourceException e) {
            connectionReturnAction = ConnectionReturnAction.DESTROY;
        }

        boolean wasInPool = false;
        synchronized (pool) {
            // a bit redundant, but this closes a small timing hole...
            if (destroyed) {
                try {
                    mc.destroy();
                }
                catch (ResourceException re) { } // ignore
                return pool.remove(mci.getManagedConnection()) != null;
            }
            if (shrinkLater > 0) {
View Full Code Here

    }

    public ManagedConnection matchManagedConnections(Set connectionSet, Subject subject, ConnectionRequestInfo cxRequestInfo) throws ResourceException {
        if (reauthentication) {
            for (Iterator iterator = connectionSet.iterator(); iterator.hasNext();) {
                ManagedConnection managedConnection = (ManagedConnection) iterator.next();
                if (managedConnections.contains(managedConnection)) {
                    return managedConnection;
                }
            }
        } else {
            for (Iterator iterator = connectionSet.iterator(); iterator.hasNext();) {
                ManagedConnection managedConnection = (ManagedConnection) iterator.next();
//                return managedConnection;
                if (managedConnections.contains(managedConnection)) {
                    MockManagedConnection mockManagedConnection = (MockManagedConnection) managedConnection;
                    if ((subject == null ? mockManagedConnection.getSubject() == null : subject.equals(mockManagedConnection.getSubject())
                            && (cxRequestInfo == null ? mockManagedConnection.getConnectionRequestInfo() == null : cxRequestInfo.equals(mockManagedConnection.getConnectionRequestInfo())))) {
View Full Code Here

    */
   public ManagedConnection matchManagedConnections(Set connectionSet,
                                                    Subject subject, ConnectionRequestInfo cxRequestInfo)
      throws ResourceException
   {
      ManagedConnection result = null;

      Iterator it = connectionSet.iterator();
      while (result == null && it.hasNext())
      {
         ManagedConnection mc = (ManagedConnection)it.next();
         if (mc instanceof HelloWorldManagedConnection)
         {
            HelloWorldManagedConnection hwmc = (HelloWorldManagedConnection)mc;
            result = hwmc;
         }
View Full Code Here

                _logger.log(Level.FINE, "Received from RA invalid connections : "+
                        invalidManagedConnections.size());
               
                for (Iterator iter = invalidManagedConnections.iterator();
                iter.hasNext();) {
                    ManagedConnection invalidManagedConnection =
                            (ManagedConnection) iter.next();
                    for (Iterator freeResourcesIter = free.iterator();
                    freeResourcesIter.hasNext();) {
                        ResourceHandle handle =
                                (ResourceHandle) freeResourcesIter.next();
                        if (invalidManagedConnection.equals
                                (handle.getResource())) {
                            resources.remove(handle);
                            destroyResource(handle);
                            freeResourcesIter.remove();
                            incrementNumConnFailedValidation();
View Full Code Here

                      dbUser, dbPassword.toCharArray());
                pc.setManagedConnectionFactory(fac);
                Principal prin = new ResourcePrincipal(dbUser, dbPassword);
                subject.getPrincipals().add(prin);
                subject.getPrivateCredentials().add(pc);
                ManagedConnection mc = fac.createManagedConnection(subject, null);
                connList.addElement(mc);
                try {
                    XAResource xares = mc.getXAResource();
                    if (xares != null) {

                // See if a wrapper class for the vendor XADataSource is
                // specified if yes, replace the XAResouce class of database
                // vendor with our own version
View Full Code Here

                        pc.setManagedConnectionFactory(mcfs[i]);
                      Principal prin =
        new ResourcePrincipal(dbUser, dbPassword);
                      subject.getPrincipals().add(prin);
                      subject.getPrivateCredentials().add(pc);
          ManagedConnection mc = mcfs[i].
        createManagedConnection(subject, null)
                        connList.addElement(mc);
                      try {
                                XAResource xares = mc.getXAResource();
                          if (xares != null) {
                             xaresList.addElement(xares);
                           }
                      } catch (ResourceException ex) {
                        // ignored. Not at XA_TRANSACTION level
                      }
        }     

    } else {
                    ManagedConnectionFactory mcf =
                       crt.obtainManagedConnectionFactory(poolName);
                    PasswordCredential pc = new PasswordCredential(
                       dbUser, dbPassword.toCharArray());
                    pc.setManagedConnectionFactory(mcf);
                    Principal prin = new ResourcePrincipal(dbUser, dbPassword);
                    subject.getPrincipals().add(prin);
                    subject.getPrivateCredentials().add(pc);
        ManagedConnection mc = mcf.createManagedConnection(subject, null)
                    connList.addElement(mc);
                    try {
                        XAResource xares = mc.getXAResource();
                        if (xares != null) {
                         xaresList.addElement(xares);
                    }
                    } catch (ResourceException ex) {
                        // ignored. Not at XA_TRANSACTION level
View Full Code Here

TOP

Related Classes of javax.resource.spi.ManagedConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.