[jboss-cvs] JBossAS SVN: r61679 - trunk/ejb3/src/main/org/jboss/ejb3.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Mar 25 14:20:53 EDT 2007


Author: bstansberry at jboss.com
Date: 2007-03-25 14:20:53 -0400 (Sun, 25 Mar 2007)
New Revision: 61679

Modified:
   trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
Log:
[EJBTHREE-881] Store partition name in EJBContainer if clustered

Modified: trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java
===================================================================
--- trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-03-25 18:19:35 UTC (rev 61678)
+++ trunk/ejb3/src/main/org/jboss/ejb3/EJBContainer.java	2007-03-25 18:20:53 UTC (rev 61679)
@@ -51,6 +51,7 @@
 import javax.naming.NameNotFoundException;
 import javax.naming.NamingException;
 
+import org.jboss.annotation.ejb.Clustered;
 import org.jboss.annotation.ejb.PoolClass;
 import org.jboss.aop.AspectManager;
 import org.jboss.aop.ClassContainer;
@@ -91,6 +92,7 @@
 import org.jboss.ws.integration.UnifiedVirtualFile;
 import org.jboss.metadata.serviceref.VirtualFileAdaptor;
 import org.jboss.metadata.serviceref.ServiceRefDelegate;
+import org.jboss.util.StringPropertyReplacer;
 
 /**
  * Comment
@@ -153,7 +155,9 @@
    protected HashMap invokedMethod = new HashMap();
 
    protected InvocationStatistics invokeStats = new InvocationStatistics();
-
+   
+   private String partitionName;
+   
    /**
     * @param name                  Advisor name
     * @param manager               Domain to get interceptor bindings from
@@ -483,6 +487,19 @@
    {
       return pool;
    }
+   
+   /**
+    * Gets the name of the cluster partition with which this container is
+    * associated. Not available until <code>EJBContainer.start()</code>
+    * is completed.
+    * 
+    * @return the name of the cluster partition with which this container is
+    *         associated, or <code>null</code> if the container is not clustered
+    */
+   public String getPartitionName()
+   {
+      return partitionName;
+   }
 
    public Object construct()
    {
@@ -556,6 +573,10 @@
       createCallbackHandler();
 
       JaccHelper.configureContainer(jaccContextId, this);
+      
+      // If we're clustered, find our partition name
+      findPartitionName();
+      
       log.info("STARTED EJB: " + clazz.getName() + " ejbName: " + ejbName);
    }
 
@@ -719,6 +740,34 @@
          log.debug("All applicable interceptor classes: " + applicableInterceptors);
       }
    }
+   
+   protected void findPartitionName()
+   {
+      Clustered clustered = (Clustered) resolveAnnotation(Clustered.class);
+      if (clustered == null)
+      {
+         partitionName = null;
+         return;
+      }
+      
+      String value = clustered.partition();
+      try
+      {
+         String replacedValue = StringPropertyReplacer.replaceProperties(value);
+         if (value != replacedValue)
+         {            
+            log.debug("Replacing @Clustered partition attribute " + value + " with " + replacedValue);
+            value = replacedValue;
+         }
+      }
+      catch (Exception e)
+      {
+         log.warn("Unable to replace @Clustered partition attribute " + value + 
+                  ". Caused by " + e.getClass() + " " + e.getMessage());         
+      }
+      
+      partitionName = value;
+   }
 
    public Object getBusinessObject(BeanContext beanContext, Class businessObject) throws IllegalStateException
    {




More information about the jboss-cvs-commits mailing list