[jboss-cvs] JBossAS SVN: r110844 - in projects/jboss-jca/trunk: core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Mon Mar 7 16:30:43 EST 2011


Author: jesper.pedersen
Date: 2011-03-07 16:30:43 -0500 (Mon, 07 Mar 2011)
New Revision: 110844

Added:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthKey.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java
Modified:
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java
   projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolStrategy.java
   projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
Log:
[JBJCA-94] First skeleton for a reauth pool

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java	2011-03-07 19:23:08 UTC (rev 110843)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolFactory.java	2011-03-07 21:30:43 UTC (rev 110844)
@@ -27,6 +27,7 @@
 import org.jboss.jca.core.connectionmanager.pool.strategy.PoolByCri;
 import org.jboss.jca.core.connectionmanager.pool.strategy.PoolBySubject;
 import org.jboss.jca.core.connectionmanager.pool.strategy.PoolBySubjectAndCri;
+import org.jboss.jca.core.connectionmanager.pool.strategy.ReauthPool;
 
 import javax.resource.spi.ManagedConnectionFactory;
 
@@ -78,6 +79,9 @@
 
          case ONE_POOL:
             return new OnePool(mcf, pc, noTxSeparatePools);
+
+         case REAUTH:
+            return new ReauthPool(mcf, pc, noTxSeparatePools);
       }
 
       throw new IllegalArgumentException("Unknown strategy " + strategy);

Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolStrategy.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolStrategy.java	2011-03-07 19:23:08 UTC (rev 110843)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/api/PoolStrategy.java	2011-03-07 21:30:43 UTC (rev 110844)
@@ -1,6 +1,6 @@
 /*
  * JBoss, Home of Professional Open Source.
- * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
  * as indicated by the @author tags. See the copyright.txt file in the
  * distribution for a full listing of individual contributors.
  *
@@ -38,5 +38,8 @@
    POOL_BY_SUBJECT_AND_CRI,
 
    /** ONE_POOL */
-   ONE_POOL
+   ONE_POOL,
+
+   /** REAUTH */
+   REAUTH
 }

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthKey.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthKey.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthKey.java	2011-03-07 21:30:43 UTC (rev 110844)
@@ -0,0 +1,103 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2011, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.connectionmanager.pool.strategy;
+
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.security.auth.Subject;
+
+/**
+ * Pool key based on {@link Subject} and {@link ConnectionRequestInfo}.
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a> 
+ * @version $Rev: $
+ */
+class ReauthKey
+{
+   /** Identifies no subject */
+   private static final Subject NOSUBJECT = new Subject();
+   
+   /** Identifies no connection request information */
+   private static final Object NOCRI = new Object();
+
+   /** The subject */
+   private final Subject subject;
+   
+   /** The connection request information */
+   private final Object cri;
+   
+   /** The cached hashCode */
+   private int hashCode = Integer.MAX_VALUE;
+
+   /** Separate no tx */
+   private boolean separateNoTx;
+
+   /**
+    * Constructor
+    * @param subject subject instance
+    * @param cri connection request info
+    * @param separateNoTx seperateNoTx
+    */
+   ReauthKey(Subject subject, ConnectionRequestInfo cri, boolean separateNoTx)
+   {
+      this.subject = (subject == null) ? NOSUBJECT : subject;
+      this.cri = (cri == null) ? NOCRI : cri;
+      this.separateNoTx = separateNoTx;
+   }
+   
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public int hashCode()
+   {
+      if (hashCode == Integer.MAX_VALUE)
+      {
+         hashCode = SecurityActions.hashCode(subject) ^ cri.hashCode();  
+      }
+      
+      return hashCode;
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   public boolean equals(Object obj)
+   {
+      if (this == obj)
+      {
+         return true;  
+      }
+      
+      if (obj == null || !(obj instanceof ReauthKey))
+      {
+         return false;  
+      }
+      
+      ReauthKey other = (ReauthKey)obj;
+      
+      return SecurityActions.equals(subject, other.subject) &&
+         cri.equals(other.cri) &&
+         separateNoTx == other.separateNoTx;
+   }
+}

Added: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java	                        (rev 0)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/connectionmanager/pool/strategy/ReauthPool.java	2011-03-07 21:30:43 UTC (rev 110844)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008-2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.jca.core.connectionmanager.pool.strategy;
+
+import org.jboss.jca.core.api.connectionmanager.pool.PoolConfiguration;
+import org.jboss.jca.core.connectionmanager.pool.AbstractPool;
+
+import javax.resource.ResourceException;
+import javax.resource.spi.ConnectionRequestInfo;
+import javax.resource.spi.ManagedConnectionFactory;
+import javax.security.auth.Subject;
+
+/**
+ * Pool implementation that supports reauthentication
+ * 
+ * @author <a href="mailto:jesper.pedersen at jboss.org">Jesper Pedersen</a>
+ */
+public class ReauthPool extends AbstractPool
+{
+   /**
+    * Creates a new instance.
+    * @param mcf managed connection factory
+    * @param pc pool configuration
+    * @param noTxSeparatePools notx seperate pool
+    */
+   public ReauthPool(final ManagedConnectionFactory mcf,
+                     final PoolConfiguration pc,
+                     final boolean noTxSeparatePools)
+   {
+      super(mcf, pc, noTxSeparatePools);
+   }
+
+   /**
+    * {@inheritDoc}
+    */
+   @Override
+   protected Object getKey(Subject subject, ConnectionRequestInfo cri, boolean separateNoTx)
+      throws ResourceException
+   {
+      return new ReauthKey(subject, cri, separateNoTx);
+   }
+}

Modified: projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java
===================================================================
--- projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-07 19:23:08 UTC (rev 110843)
+++ projects/jboss-jca/trunk/deployers/src/main/java/org/jboss/jca/deployers/common/AbstractResourceAdapterDeployer.java	2011-03-07 21:30:43 UTC (rev 110844)
@@ -839,8 +839,7 @@
                      ijCD = findConnectionDefinition(ra10.getManagedConnectionFactoryClass().getValue(),
                         ijmd.getConnectionDefinitions());
                   }
-                  //
-                  //                  if (ijmd == null || ijCD == null || ijCD.isEnabled())
+
                   if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
                   {
                      ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(ra10
@@ -917,6 +916,12 @@
 
                      }
 
+                     if (ra10 != null && ra10.getReauthenticationSupport() != null &&
+                         ra10.getReauthenticationSupport().booleanValue())
+                     {
+                        strategy = PoolStrategy.REAUTH;
+                     }
+
                      Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
 
                      // Add a connection manager
@@ -1138,9 +1143,6 @@
                   List<ConnectionDefinition> cdMetas = ra.getOutboundResourceadapter().getConnectionDefinitions();
                   if (cdMetas.size() > 0)
                   {
-                     //                     if (cdMetas.size() == 1)
-                     //                     {
-                     //                        ConnectionDefinition cdMeta = cdMetas.get(0);
                      cfs = new Object[cdMetas.size()];
                      cfJndiNames = new String[cdMetas.size()];
 
@@ -1173,8 +1175,6 @@
                                     ijmd.getConnectionDefinitions());
                               }
 
-                              //                              if (ijmd == null || ijCD == null || ijCD.isEnabled())
-                              //                              {
                               if (ijCD == null || ijCD.isEnabled() || (cdRaXml != null && cdRaXml.isEnabled()))
                               {
                                  ManagedConnectionFactory mcf = (ManagedConnectionFactory) initAndInject(cdMeta
@@ -1253,6 +1253,12 @@
                                     }
 
                                  }
+
+                                 if (ra.getOutboundResourceadapter().getReauthenticationSupport())
+                                 {
+                                    strategy = PoolStrategy.REAUTH;
+                                 }
+
                                  Pool pool = pf.create(strategy, mcf, pc, noTxSeparatePool.booleanValue());
 
                                  // Add a connection manager



More information about the jboss-cvs-commits mailing list