[jboss-cvs] JBossAS SVN: r77380 - in projects/ejb3/trunk: proxy-clustered and 26 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sat Aug 23 10:35:33 EDT 2008


Author: bstansberry at jboss.com
Date: 2008-08-23 10:35:33 -0400 (Sat, 23 Aug 2008)
New Revision: 77380

Added:
   projects/ejb3/trunk/proxy-clustered/
   projects/ejb3/trunk/proxy-clustered/.classpath
   projects/ejb3/trunk/proxy-clustered/.project
   projects/ejb3/trunk/proxy-clustered/jboss-ejb3-proxy-clustered-client.xml
   projects/ejb3/trunk/proxy-clustered/pom.xml
   projects/ejb3/trunk/proxy-clustered/src/
   projects/ejb3/trunk/proxy-clustered/src/main/
   projects/ejb3/trunk/proxy-clustered/src/main/java/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/ClusterFamilyNamePolicy.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolClusterFamilyNamePolicy.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolPortClusterFamilyNamePolicy.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/invocation/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/invocation/InvokableContextClusteredProxyInvocationHandler.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredSessionRegistrarBase.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatefulSessionRegistrar.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatelessSessionRegistrar.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/ClusteredProxyFactoryReferenceAddressTypes.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/SessionClusteredProxyObjectFactory.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateful/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateful/StatefulSessionClusteredProxyObjectFactory.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateless/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateless/StatelessSessionClusteredProxyObjectFactory.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectstore/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectstore/ClusteredObjectStoreBindings.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringInfo.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistry.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistryListener.java
   projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/remoting/
   projects/ejb3/trunk/proxy-clustered/src/main/resources/
   projects/ejb3/trunk/proxy-clustered/src/test/
   projects/ejb3/trunk/proxy-clustered/src/test/java/
   projects/ejb3/trunk/proxy-clustered/src/test/resources/
Modified:
   projects/ejb3/trunk/pom.xml
Log:
[EJBTHREE-1469] Initial checkin of proxy-clustered

Modified: projects/ejb3/trunk/pom.xml
===================================================================
--- projects/ejb3/trunk/pom.xml	2008-08-23 14:33:33 UTC (rev 77379)
+++ projects/ejb3/trunk/pom.xml	2008-08-23 14:35:33 UTC (rev 77380)
@@ -48,6 +48,7 @@
     <module>plugin</module>
     <module>pool</module>
     <module>proxy</module>
+    <module>proxy-clustered</module>
     <!-- module>sandbox</module -->
     <module>security</module>
     <module>test</module>

Added: projects/ejb3/trunk/proxy-clustered/.classpath
===================================================================
--- projects/ejb3/trunk/proxy-clustered/.classpath	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/.classpath	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,58 @@
+<classpath>
+  <classpathentry kind="src" path="src/main/java"/>
+  <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
+  <classpathentry kind="src" path="src/test/java" output="target/tests-classes"/>
+  <classpathentry kind="src" path="src/test/resources" output="target/tests-classes" excluding="**/*.java"/>
+  <classpathentry kind="output" path="target/classes"/>
+  <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.0.2/activation-1.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/security/jacc/1.0/jacc-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.7.1.GA/javassist-3.7.1.GA.jar" sourcepath="M2_REPO/javassist/javassist/3.7.1.GA/javassist-3.7.1.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1.jar" sourcepath="M2_REPO/javax/xml/bind/jaxb-api/2.1/jaxb-api-2.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aop/jboss-aop/2.0.0.CR11/jboss-aop-2.0.0.CR11.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.5.GA/jboss-common-core-2.2.5.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA.jar" sourcepath="M2_REPO/jboss/jboss-common-logging-spi/2.0.4.GA/jboss-common-logging-spi-2.0.4.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.CR1/jboss-current-invocation-aspects-1.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-current-invocation-aspects/1.0.0.CR1/jboss-current-invocation-aspects-1.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-dependency/2.0.0.Beta14/jboss-dependency-2.0.0.Beta14.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/0.1.5/jboss-ejb3-common-0.1.5.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-common/0.1.5/jboss-ejb3-common-0.1.5-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/0.4/jboss-ejb3-ext-api-0.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/0.13.3/jboss-ejb3-interceptors-0.13.3.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-interceptors/0.13.3/jboss-ejb3-interceptors-0.13.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/0.12.2/jboss-ejb3-metadata-0.12.2.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-metadata/0.12.2/jboss-ejb3-metadata-0.12.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy/0.1.2-SNAPSHOT/jboss-ejb3-proxy-0.1.2-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-proxy/0.1.2-SNAPSHOT/jboss-ejb3-proxy-0.1.2-SNAPSHOT-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.0.CR4/jboss-ha-client-1.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-client/1.1.0.CR4/jboss-ha-client-1.1.0.CR4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.0.CR4/jboss-ha-server-api-1.1.0.CR4.jar" sourcepath="M2_REPO/org/jboss/cluster/jboss-ha-server-api/1.1.0.CR4/jboss-ha-server-api-1.1.0.CR4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.CR1/jboss-jaspi-api-1.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jaspi-api/1.0.0.CR1/jboss-jaspi-api-1.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-jaxws/2.0.1.GA/jboss-jaxws-2.0.1.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.CR1/jboss-jca-api-1.5.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jca-api/1.5.0.CR1/jboss-jca-api-1.5.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.CR1/jboss-jms-api-1.1.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/microcontainer/jboss-kernel/2.0.0.Beta14/jboss-kernel-2.0.0.Beta14.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.Beta15/jboss-mdr-2.0.0.Beta15.jar" sourcepath="M2_REPO/org/jboss/jboss-mdr/2.0.0.Beta15/jboss-mdr-2.0.0.Beta15-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.Beta35/jboss-metadata-1.0.0.Beta35.jar" sourcepath="M2_REPO/org/jboss/metadata/jboss-metadata/1.0.0.Beta35/jboss-metadata-1.0.0.Beta35-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-persistence-api/3.0.0.CR1/jboss-persistence-api-3.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-persistence-api/3.0.0.CR1/jboss-persistence-api-3.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta12/jboss-reflect-2.0.0.Beta12.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.0.Beta12/jboss-reflect-2.0.0.Beta12-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/remoting/jboss-remoting/2.4.0.CR2/jboss-remoting-2.4.0.CR2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.CR3/jboss-remoting-aspects-1.0.1.CR3.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-remoting-aspects/1.0.1.CR3/jboss-remoting-aspects-1.0.1.CR3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-security-aspects/1.0.0.Beta1/jboss-security-aspects-1.0.0.Beta1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.2.Beta5/jboss-security-spi-2.0.2.Beta5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/jboss-serialization/1.0.3.GA/jboss-serialization-1.0.3.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.Beta1/jboss-transaction-aspects-1.0.0.Beta1.jar" sourcepath="M2_REPO/org/jboss/aspects/jboss-transaction-aspects/1.0.0.Beta1/jboss-transaction-aspects-1.0.0.Beta1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-transaction-spi/5.0.0.Beta4/jboss-transaction-spi-5.0.0.Beta4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.Beta18/jboss-vfs-2.0.0.Beta18.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.0.2.Beta5/jbosssx-client-2.0.2.Beta5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.0.3.GA/jbossws-spi-1.0.3.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.0.CR12/jbossxb-2.0.0.CR12.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.0.CR12/jbossxb-2.0.0.CR12-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1.jar" sourcepath="M2_REPO/org/jboss/naming/jnpserver/5.0.0.CR1/jnpserver-5.0.0.CR1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar" sourcepath="M2_REPO/junit/junit/4.4/junit-4.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/qdox/qdox/1.6/qdox-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2.jar" sourcepath="M2_REPO/javax/xml/stream/stax-api/1.0-2/stax-api-1.0-2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/trove/trove/1.0.2/trove-1.0.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+</classpath>
\ No newline at end of file

Added: projects/ejb3/trunk/proxy-clustered/.project
===================================================================
--- projects/ejb3/trunk/proxy-clustered/.project	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/.project	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,13 @@
+<projectDescription>
+  <name>jboss-ejb3-proxy-clustered</name>
+  <comment>JBoss EJB3 Clustered Proxy Component</comment>
+  <projects/>
+  <buildSpec>
+    <buildCommand>
+      <name>org.eclipse.jdt.core.javabuilder</name>
+    </buildCommand>
+  </buildSpec>
+  <natures>
+    <nature>org.eclipse.jdt.core.javanature</nature>
+  </natures>
+</projectDescription>
\ No newline at end of file

Added: projects/ejb3/trunk/proxy-clustered/jboss-ejb3-proxy-clustered-client.xml
===================================================================
--- projects/ejb3/trunk/proxy-clustered/jboss-ejb3-proxy-clustered-client.xml	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/jboss-ejb3-proxy-clustered-client.xml	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  vi:ts=2:sw=2:expandtab:
+-->
+<assembly xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/assembly-1.0.0.xsd"
+>
+  <id>client</id>
+  <formats>
+    <format>jar</format>
+  </formats>
+  <includeBaseDirectory>false</includeBaseDirectory>
+  <fileSets>
+    <fileSet>
+      <directory>target/classes</directory>
+      <outputDirectory></outputDirectory>
+      
+      <!-- 
+      
+      Most of the classes in the Proxy-Clustered Component are
+      required on the Client CP, so we'll stick with 
+      exclude patterns to hide internals
+      
+       -->
+       
+      <excludes>
+        <exclude>org/jboss/ejb3/proxy/clustered/registry/**</exclude>
+        <exclude>org/jboss/ejb3/proxy/clustered/factory/**</exclude>
+        <exclude>org/jboss/ejb3/proxy/clustered/familyname/**</exclude>
+        <exclude>org/jboss/ejb3/proxy/clustered/jndiregistrar/**</exclude>
+        <exclude>org/jboss/ejb3/proxy/clustered/objectstore/**</exclude>
+      </excludes>
+    </fileSet>
+
+  </fileSets>
+</assembly>

Added: projects/ejb3/trunk/proxy-clustered/pom.xml
===================================================================
--- projects/ejb3/trunk/proxy-clustered/pom.xml	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/pom.xml	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,145 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <!-- Parent -->
+  <parent>
+    <groupId>org.jboss.ejb3</groupId>
+    <artifactId>jboss-ejb3-build</artifactId>
+    <version>0.13.13</version>
+  </parent>
+
+  <!-- Model Version -->
+  <modelVersion>4.0.0</modelVersion>
+
+  <!-- Artifact Configuration -->
+  <groupId>org.jboss.ejb3</groupId>
+  <artifactId>jboss-ejb3-proxy-clustered</artifactId>
+  <version>0.1.3-SNAPSHOT</version>
+  <name>JBoss EJB 3.0 Clustered Proxy</name>
+  <description>JBoss EJB3 Clustered Proxy Component</description>
+  <url>http://www.jboss.org/jbossejb3</url>
+
+  <!-- Build Configuration -->
+  <build>
+
+    <plugins>
+
+      <!-- Build a CP File for use by MockServer -->     
+      <plugin>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>build-cp-file</id>
+            <phase>validate</phase>
+            <goals>
+              <goal>build-classpath</goal>
+            </goals>
+            <configuration>
+              <outputFile>target/cp.txt</outputFile>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+
+      <!-- Assembly Plugin (Proxy Client) -->
+      <plugin>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <version>2.2-beta-1</version>
+        <executions>
+          <execution>
+            <id>make-assembly</id>
+            <phase>package</phase>
+            <goals>
+              <goal>attached</goal>
+            </goals>
+          </execution>
+        </executions>
+        <configuration>
+          <descriptors>
+            <descriptor>jboss-ejb3-proxy-clustered-client.xml</descriptor>
+          </descriptors>
+          <attach>true</attach>
+        </configuration>
+        <inherited>false</inherited>
+      </plugin>
+
+    </plugins>
+
+  </build>
+
+  <dependencyManagement>
+    <dependencies>
+      <!-- Because of a bug in m2eclipse the version of reflect must be explicitly defined 
+      <dependency>
+        <groupId>org.jboss</groupId>
+        <artifactId>jboss-reflect</artifactId>
+        <version>2.0.0.Beta12</version>
+      </dependency> -->
+    </dependencies>
+  </dependencyManagement>
+  
+  <!-- Dependencies -->
+  <dependencies>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- We pull in most things via the proxy component we are extending -->
+    <dependency>
+      <groupId>org.jboss.ejb3</groupId>
+      <artifactId>jboss-ejb3-proxy</artifactId>
+      <version>0.1.3-SNAPSHOT</version>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.cluster</groupId>
+      <artifactId>jboss-ha-client</artifactId>
+      <version>1.1.0.CR4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss.aspects</groupId>
+          <artifactId>jboss-remoting-aspects</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>jboss.remoting</groupId>
+          <artifactId>jboss-remoting</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.aop</groupId>
+          <artifactId>jboss-aop</artifactId>            
+        </exclusion>
+      </exclusions>
+    </dependency>
+    
+    <dependency>
+      <groupId>org.jboss.cluster</groupId>
+      <artifactId>jboss-ha-server-api</artifactId>
+      <version>1.1.0.CR4</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.jboss</groupId>
+          <artifactId>jboss-common-core</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.logging</groupId>
+          <artifactId>jboss-logging-spi</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.cache</groupId>
+          <artifactId>jbosscache-core</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>org.jboss.cache</groupId>
+          <artifactId>jbosscache-pojo</artifactId>            
+        </exclusion>
+        <exclusion>
+          <groupId>jgroups</groupId>
+          <artifactId>jgroups</artifactId>            
+        </exclusion>
+      </exclusions>
+    </dependency> 
+
+  </dependencies>
+</project>

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateful/StatefulSessionClusteredProxyFactory.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,196 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.factory.session.stateful;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.clustered.factory.session.stateless.StatelessSessionClusteredProxyFactory;
+import org.jboss.ejb3.proxy.clustered.handler.session.stateful.StatefulClusteredProxyInvocationHandler;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringInfo;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionRemoteProxyFactory;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * A SFSB Proxy Factory for Clustered Remote Views
+ *
+ * @author Brian Stansberry
+ * 
+ * @version $Revision: $
+ */
+public class StatefulSessionClusteredProxyFactory extends StatefulSessionRemoteProxyFactory
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final String STACK_NAME_CLUSTERED_STATEFUL_SESSION_CLIENT_INTERCEPTORS = "ClusteredStatefulSessionClientInterceptors";
+
+   private static final Logger log = Logger.getLogger(StatelessSessionClusteredProxyFactory.class);
+   
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private final ProxyClusteringRegistry registry;
+   private ProxyClusteringInfo beanClusteringInfo;
+   
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param name The unique name for this ProxyFactory
+    * @param containerName The name of the InvokableContext (container)
+    *   upon which Proxies will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param metadata The metadata representing this SFSB
+    * @param classloader The ClassLoader associated with the StatelessContainer
+    *       for which this ProxyFactory is to generate Proxies
+    * @param url The URL to use for remoting
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   public StatefulSessionClusteredProxyFactory(final String name, final String containerName, final String containerGuid,
+         final JBossSessionBeanMetaData metadata, final ClassLoader classloader, final String url, final Advisor advisor,
+         ProxyClusteringRegistry registry)
+   {
+      // Call Super
+      super(name, containerName, containerGuid, metadata, classloader, url, advisor);
+      
+      assert registry != null : "registry is null";
+      
+      this.registry = registry;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Functional Methods -------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Return the name of the interceptor stack to apply to 
+    * proxies created by this proxy factory
+    * 
+    * @return
+    */
+   @Override
+   protected String getInterceptorStackName()
+   {
+      return STACK_NAME_CLUSTERED_STATEFUL_SESSION_CLIENT_INTERCEPTORS;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   @Override
+   public void start() throws Exception
+   {
+      super.start();
+      
+      this.beanClusteringInfo = this.registry.registerClusteredBean(getContainerName(), getName(), getMetadata(), new InvokerLocator(getUrl()));
+      
+      // FIXME move to superclass
+      // Register with Remoting
+      log.debug("Registering with Remoting Dispatcher under name \"" + getName() + "\": " + this);
+      Dispatcher.singleton.registerTarget(getName(), this);
+   }
+
+   @Override
+   public void stop() throws Exception
+   {
+      this.registry.unregisterClusteredBean(this.beanClusteringInfo);
+      
+      // FIXME move to superclass
+      // Register with Remoting
+      log.debug("Unregistering name \"" + getName() + "\" from Remoting Dispatcher");
+      Dispatcher.singleton.unregisterTarget(getName());      
+      
+      super.stop();
+   }
+   
+   
+   @Override
+   protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+   {
+      return createInvocationHandler(null, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+   {
+      return createInvocationHandler(businessInterfaceName, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+   {
+      return createInvocationHandler(null, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createHomeInvocationHandler()
+   {
+      return createInvocationHandler(null, true);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Private ------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private SessionProxyInvocationHandler createInvocationHandler(String businessInterfaceName, boolean isOnlyHome)   
+   {
+      // Obtain target properties
+      String containerName = this.getContainerName();
+      String url = this.getUrl();
+      String containerGuid = this.getContainerGuid();
+
+      // Get Interceptors
+      Interceptor[] interceptors = this.getInterceptors();
+
+      Class<? extends LoadBalancePolicy> policyClass = isOnlyHome ? beanClusteringInfo.getHomeLoadBalancePolicy() : beanClusteringInfo.getLoadBalancePolicy();
+      LoadBalancePolicy lbp;
+      try
+      {
+         lbp = policyClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Cannot instantiate LoadBalancePolicy class " + policyClass);
+      }
+      
+      // Create
+      SessionProxyInvocationHandler handler = new StatefulClusteredProxyInvocationHandler(containerName, containerGuid,
+            interceptors, businessInterfaceName, url, beanClusteringInfo.getFamilyWrapper(), 
+            lbp, beanClusteringInfo.getPartitionName());
+
+      // Return
+      return handler;
+   }
+   
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/factory/session/stateless/StatelessSessionClusteredProxyFactory.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,195 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.factory.session.stateless;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Dispatcher;
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.ejb3.proxy.clustered.handler.session.stateless.StatelessClusteredProxyInvocationHandler;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringInfo;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionRemoteProxyFactory;
+import org.jboss.ejb3.proxy.handler.session.SessionProxyInvocationHandler;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * An SLSB Proxy Factory for Clustered Remote Views
+ *
+ * @author Brian Stansberry
+ * 
+ * @version $Revision: $
+ */
+public class StatelessSessionClusteredProxyFactory extends StatelessSessionRemoteProxyFactory
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final String STACK_NAME_CLUSTERED_STATELESS_SESSION_CLIENT_INTERCEPTORS = "ClusteredStatelessSessionClientInterceptors";
+
+   private static final Logger log = Logger.getLogger(StatelessSessionClusteredProxyFactory.class);
+   
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private final ProxyClusteringRegistry registry;
+   private ProxyClusteringInfo beanClusteringInfo;
+   
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param name The unique name for this ProxyFactory
+    * @param containerName The name of the InvokableContext (container)
+    *   upon which Proxies will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param metadata The metadata representing this SLSB
+    * @param classloader The ClassLoader associated with the StatelessContainer
+    *       for which this ProxyFactory is to generate Proxies
+    * @param url The URL to use for remoting
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   public StatelessSessionClusteredProxyFactory(final String name, final String containerName, final String containerGuid,
+         final JBossSessionBeanMetaData metadata, final ClassLoader classloader, final String url, final Advisor advisor, 
+         final ProxyClusteringRegistry registry)
+   {
+      // Call Super
+      super(name, containerName, containerGuid, metadata, classloader, url, advisor);
+      
+      assert registry != null : "registry is null";
+      
+      this.registry = registry;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Functional Methods -------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Return the name of the interceptor stack to apply to 
+    * proxies created by this proxy factory
+    * 
+    * @return
+    */
+   @Override
+   protected String getInterceptorStackName()
+   {
+      return STACK_NAME_CLUSTERED_STATELESS_SESSION_CLIENT_INTERCEPTORS;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   @Override
+   public void start() throws Exception
+   {
+      super.start();
+      
+      this.beanClusteringInfo = this.registry.registerClusteredBean(getContainerName(), getName(), getMetadata(), new InvokerLocator(getUrl()));
+      
+      // FIXME move to superclass
+      // Register with Remoting
+      log.debug("Registering with Remoting Dispatcher under name \"" + getName() + "\": " + this);
+      Dispatcher.singleton.registerTarget(getName(), this);
+   }
+
+   @Override
+   public void stop() throws Exception
+   {
+      this.registry.unregisterClusteredBean(this.beanClusteringInfo);
+      
+      // FIXME move to superclass
+      // Register with Remoting
+      log.debug("Unregistering name \"" + getName() + "\" from Remoting Dispatcher");
+      Dispatcher.singleton.unregisterTarget(getName());
+      
+      super.stop();
+   }
+   
+   
+   @Override
+   protected SessionProxyInvocationHandler createBusinessDefaultInvocationHandler()
+   {
+      return createInvocationHandler(null, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createBusinessInterfaceSpecificInvocationHandler(String businessInterfaceName)
+   {
+      return createInvocationHandler(businessInterfaceName, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createEjb2xComponentInterfaceInvocationHandler()
+   {
+      return createInvocationHandler(null, false);
+   }
+
+   @Override
+   protected SessionProxyInvocationHandler createHomeInvocationHandler()
+   {
+      return createInvocationHandler(null, true);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Private ------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private SessionProxyInvocationHandler createInvocationHandler(String businessInterfaceName, boolean isOnlyHome)   
+   {
+      // Obtain properties
+      String containerName = this.getContainerName();
+      String containerGuid = this.getContainerGuid();
+      String url = this.getUrl();
+
+      // Get Interceptors
+      Interceptor[] interceptors = this.getInterceptors();
+
+      Class<? extends LoadBalancePolicy> policyClass = isOnlyHome ? beanClusteringInfo.getHomeLoadBalancePolicy() : beanClusteringInfo.getLoadBalancePolicy();
+      LoadBalancePolicy lbp;
+      try
+      {
+         lbp = policyClass.newInstance();
+      }
+      catch (Exception e)
+      {
+         throw new RuntimeException("Cannot instantiate LoadBalancePolicy class " + policyClass);
+      }
+      
+      // Create
+      SessionProxyInvocationHandler handler = new StatelessClusteredProxyInvocationHandler(containerName, containerGuid,
+            interceptors, businessInterfaceName, url, beanClusteringInfo.getFamilyWrapper(), 
+            lbp, beanClusteringInfo.getPartitionName());
+
+      // Return
+      return handler;
+   }
+   
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/ClusterFamilyNamePolicy.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/ClusterFamilyNamePolicy.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/ClusterFamilyNamePolicy.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,57 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.familyname;
+
+
+/**
+ * Pluggable policy for creating a cross-cluster consistent but cross-deployment
+ * unique name for the clustering information associated with a service. The
+ * fundamental purpose of this policy is to create strings that can be passed
+ * to {@link org.jboss.aspects.remoting.FamilyWrapper#FamilyWrapper(String, java.util.List)} and
+ * {@link org.jboss.ha.framework.interfaces.ClusteringTargetsRepository#initTarget(String, java.util.List)}.
+ * <p>
+ * The design intent of this interface is that different implementations will
+ * handle the <code>localTarget</code> param passed to 
+ * {@link #getClusterFamilyName(String, Object, String)} differently.
+ * </p>
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public interface ClusterFamilyNamePolicy<T>
+{
+   /**
+    * Gets a name for the clustering information identified by the given
+    * parameters. Invoking this method on different nodes in the cluster, with
+    * the same <code>serviceName</code> and the same <code>partitionName</code>
+    * but different but logically related <code>localTarget</code> values 
+    * must result in the same return value.
+    * 
+    * @param serviceName the name of the service
+    * @param localTarget this node's cluster target for the service
+    * @param partitionName the name of the HAPartition
+    * 
+    * @return the cluster family name.
+    */
+   String getClusterFamilyName(String serviceName, T localTarget, String partitionName);
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolClusterFamilyNamePolicy.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolClusterFamilyNamePolicy.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolClusterFamilyNamePolicy.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.familyname;
+
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @{link {@link ClusterFamilyNamePolicy} impl that constructs its family
+ * name by extracting the {@link InvokerLocator#getProtocol() protocol} from 
+ * the passed <code>localTarget</code>.
+ * <p>
+ * This policy will not produce unique values if multiple InvokerLocators that 
+ * use the same protocol are associated with the target service.
+ * {@link InvokerLocatorProtocolPortClusterFamilyNamePolicy} will produce
+ * unique values, but doesn't handle the scenario where logically related
+ * targets are configured to use different ports on different nodes. 
+ * </p>
+ *  
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class InvokerLocatorProtocolClusterFamilyNamePolicy implements ClusterFamilyNamePolicy<InvokerLocator>
+{
+
+   public String getClusterFamilyName(String serviceName, InvokerLocator localTarget, String partitionName)
+   {
+      return serviceName + localTarget.getProtocol() + partitionName;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolPortClusterFamilyNamePolicy.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolPortClusterFamilyNamePolicy.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/familyname/InvokerLocatorProtocolPortClusterFamilyNamePolicy.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,50 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.familyname;
+
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * @{link {@link ClusterFamilyNamePolicy} impl that constructs its family
+ * name by extracting the {@link InvokerLocator#getProtocol() protocol} and
+ * {@link InvokerLocator#getPort() port} from the passed <code>localTarget</code>.
+ * <p>
+ * This policy will produce unique values if multiple InvokerLocators that 
+ * use the same protocol are associated with the target service.
+ * {@link InvokerLocatorProtocolClusterFamilyNamePolicy} will not produce
+ * unique values, but does handle the scenario where logically related
+ * targets use different ports on different nodes. 
+ * </p>
+ *  
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class InvokerLocatorProtocolPortClusterFamilyNamePolicy implements ClusterFamilyNamePolicy<InvokerLocator>
+{
+
+   public String getClusterFamilyName(String serviceName, InvokerLocator localTarget, String partitionName)
+   {
+      return serviceName + localTarget.getProtocol() + localTarget.getPort() + partitionName;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateful/StatefulClusteredProxyInvocationHandler.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,151 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.handler.session.stateful;
+
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.aspects.remoting.PojiProxy;
+import org.jboss.ejb3.proxy.clustered.invocation.InvokableContextClusteredProxyInvocationHandler;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.handler.session.stateful.StatefulRemoteProxyInvocationHandler;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * InvocationHandler for remote proxies to clustered SFSBs.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class StatefulClusteredProxyInvocationHandler extends StatefulRemoteProxyInvocationHandler
+{  
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 8941906289390905059L;
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private FamilyWrapper family;
+   private LoadBalancePolicy lbPolicy;
+   private String partitionName;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Create a new StatefulClusteredRemoteProxyInvocationHandler.
+    * 
+    * @param family clustering target information. Cannot be <code>null</code>.
+    * @param lb LoadBalancePolicy implementation. Cannot be <code>null</code>.
+    * @param partitionName  name of the cluster partition. Cannot be <code>null</code>.
+    */
+   public StatefulClusteredProxyInvocationHandler(String containerName, String containerGuid,
+         Interceptor[] interceptors, String businessInterfaceType, String url, FamilyWrapper family,
+         LoadBalancePolicy lb, String partitionName)
+   {
+      super(containerName, containerGuid, interceptors, businessInterfaceType, url);
+      
+      assert family != null        : "family is null";
+      assert lb != null            : "lb is null";
+      assert partitionName != null : "partitionName is null";
+      
+      this.family = family;
+      this.lbPolicy = lb;
+      this.partitionName = partitionName;  
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   @Override
+   protected InvokableContext createRemoteProxyToContainer(String url)
+   {
+      // Create an InvokerLocator
+      InvokerLocator locator = null;
+      try
+      {
+         locator = new InvokerLocator(url);
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException("Could not create " + InvokerLocator.class.getSimpleName() + " to url \"" + url
+               + "\"", e);
+      }
+
+      /*
+       * Define interceptors
+       */
+
+      // Get interceptors from the stack
+      Interceptor[] interceptors = this.getInterceptors();
+
+      /*
+       * Create Proxy
+       */
+
+      // Create a POJI Proxy to the Container
+      String containerName = this.getContainerName();
+      assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
+      PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(), 
+            this.getContainerGuid(), locator, interceptors, this.getSessionId(), 
+            this.getFamilyWrapper(), this.getLoadBalancePolicy(), this.getPartitionName(), true);
+      Class<?>[] interfaces = new Class<?>[]
+      {InvokableContext.class};
+      InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
+            interfaces, handler);
+
+      // Return
+      return container;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public FamilyWrapper getFamilyWrapper()
+   {
+      return family;
+   }
+
+   public LoadBalancePolicy getLoadBalancePolicy()
+   {
+      return lbPolicy;
+   }
+
+   public String getPartitionName()
+   {
+      return partitionName;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/handler/session/stateless/StatelessClusteredProxyInvocationHandler.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,158 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.handler.session.stateless;
+
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.aspects.remoting.PojiProxy;
+import org.jboss.ejb3.proxy.clustered.invocation.InvokableContextClusteredProxyInvocationHandler;
+import org.jboss.ejb3.proxy.container.InvokableContext;
+import org.jboss.ejb3.proxy.handler.session.stateless.StatelessRemoteProxyInvocationHandler;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * StatelessRemoteProxyInvocationHandler
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public class StatelessClusteredProxyInvocationHandler extends StatelessRemoteProxyInvocationHandler
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 2380301898566457305L;
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private FamilyWrapper family;
+   private LoadBalancePolicy lbPolicy;
+   private String partitionName;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Constructor
+    * 
+    * @param family clustering target information. Cannot be <code>null</code>.
+    * @param lb LoadBalancePolicy implementation. Cannot be <code>null</code>.
+    * @param partitionName  name of the cluster partition. Cannot be <code>null</code>.
+    */
+   public StatelessClusteredProxyInvocationHandler(final String containerName, final String containerGuid,
+         final Interceptor[] interceptors, final String businessInterfaceType, final String url, 
+         FamilyWrapper family, LoadBalancePolicy lb, String partitionName)
+   {
+      super(containerName, containerGuid, interceptors, businessInterfaceType, url);
+      
+      assert family != null        : "family is null";
+      assert lb != null            : "lb is null";
+      assert partitionName != null : "partitionName is null";
+      
+      this.family = family;
+      this.lbPolicy = lb;
+      this.partitionName = partitionName;  
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Functional Methods -------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates and returns a Remoting Proxy to invoke upon the container
+    * 
+    * @param url The location of the remote host holding the Container
+    * @return
+    */
+   //FIXME Mostly a copy of the SFSB Remote Handler, but passing null 
+   // as a SessionID.  Should be using more intelligent design, SLSB's have 
+   // no Sessions.  To be reworked in InvokableContextStatefulRemoteProxyInvocationHack, 
+   // as this implementation is @deprecated
+   protected InvokableContext createRemoteProxyToContainer(String url)
+   { // Create an InvokerLocator
+      InvokerLocator locator = null;
+      try
+      {
+         locator = new InvokerLocator(url);
+      }
+      catch (MalformedURLException e)
+      {
+         throw new RuntimeException("Could not create " + InvokerLocator.class.getSimpleName() + " to url \"" + url
+               + "\"", e);
+      }
+
+      /*
+       * Define interceptors
+       */
+
+      // Get interceptors from the stack
+      Interceptor[] interceptors = this.getInterceptors();
+
+      /*
+       * Create Proxy
+       */
+
+      // Create a POJI Proxy to the Container
+      String containerName = this.getContainerName();
+      assert containerName != null && containerName.trim().length() > 0 : "Container Name must be set";
+      PojiProxy handler = new InvokableContextClusteredProxyInvocationHandler(this.getContainerName(), 
+            this.getContainerGuid(), locator, interceptors, null, this.getFamilyWrapper(), 
+            this.getLoadBalancePolicy(), this.getPartitionName(), false);
+      Class<?>[] interfaces = new Class<?>[]
+      {InvokableContext.class};
+      InvokableContext container = (InvokableContext) Proxy.newProxyInstance(InvokableContext.class.getClassLoader(),
+            interfaces, handler);
+
+      // Return
+      return container;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public FamilyWrapper getFamilyWrapper()
+   {
+      return family;
+   }
+
+   public LoadBalancePolicy getLoadBalancePolicy()
+   {
+      return lbPolicy;
+   }
+
+   public String getPartitionName()
+   {
+      return partitionName;
+   }
+
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/invocation/InvokableContextClusteredProxyInvocationHandler.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/invocation/InvokableContextClusteredProxyInvocationHandler.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/invocation/InvokableContextClusteredProxyInvocationHandler.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.invocation;
+
+import java.io.Serializable;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aop.joinpoint.MethodInvocation;
+import org.jboss.aop.metadata.SimpleMetaData;
+import org.jboss.aop.util.PayloadKey;
+import org.jboss.aspects.remoting.ClusterConstants;
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.ejb3.proxy.invocation.InvokableContextStatefulRemoteProxyInvocationHack;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.remoting.InvokerLocator;
+
+/**
+ * Extends the superclass to add additional clustering metadata to each
+ * invocation.
+ * 
+ * @author Brian Stansberry
+ *
+ */
+public class InvokableContextClusteredProxyInvocationHandler extends InvokableContextStatefulRemoteProxyInvocationHack
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = -3220073092992088020L;
+
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private FamilyWrapper family;
+   private LoadBalancePolicy lbPolicy;
+   private String partitionName;
+   private boolean usePreferredTarget;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Create a new InvokableContextClusteredRemoteProxy.
+    * 
+    * @param family clustering target information. Cannot be <code>null</code>.
+    * @param lb LoadBalancePolicy implementation. Cannot be <code>null</code>.
+    * @param partitionName  name of the cluster partition. Cannot be <code>null</code>.
+    * @param usePreferredTarget should <code>uri</code> be added to the metadata under key
+    *                           {@link ClusterConstants.HA_TARGET}? Should be
+    *                           <code>true</code> for SFSB proxies.
+    */
+   public InvokableContextClusteredProxyInvocationHandler(Object oid, String containerGuid, InvokerLocator uri,
+         Interceptor[] interceptors, Serializable sessionId, FamilyWrapper family,
+         LoadBalancePolicy lb, String partitionName, boolean usePreferredTarget)
+   {
+      super(oid, containerGuid, uri, interceptors, sessionId);
+      
+      assert family != null        : "family is null";
+      assert lb != null            : "lb is null";
+      assert partitionName != null : "partitionName is null";
+      
+      this.family = family;
+      this.lbPolicy = lb;
+      this.partitionName = partitionName;  
+      this.usePreferredTarget = usePreferredTarget;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Overrides the superclass to add
+    */
+   @Override
+   protected void addMetadataToInvocation(MethodInvocation methodInvocation)
+   {
+      super.addMetadataToInvocation(methodInvocation);
+      
+      SimpleMetaData metadata = methodInvocation.getMetaData();
+      metadata.addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.CLUSTER_FAMILY_WRAPPER, family, PayloadKey.TRANSIENT);
+      metadata.addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.LOADBALANCE_POLICY, lbPolicy, PayloadKey.TRANSIENT);
+      metadata.addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.PARTITION_NAME, partitionName, PayloadKey.TRANSIENT);
+      
+      if (this.usePreferredTarget)
+      {
+         metadata.addMetaData(ClusterConstants.CLUSTERED_REMOTING, ClusterConstants.HA_TARGET, getUri(), PayloadKey.TRANSIENT);
+      }
+   }
+   
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredSessionRegistrarBase.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredSessionRegistrarBase.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredSessionRegistrarBase.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,395 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.jndiregistrar;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.naming.Context;
+import javax.naming.RefAddr;
+import javax.naming.Reference;
+import javax.naming.StringRefAddr;
+
+import org.jboss.aop.Advisor;
+import org.jboss.ejb3.proxy.clustered.objectfactory.ClusteredProxyFactoryReferenceAddressTypes;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringInfo;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistryListener;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiReferenceBinding;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiReferenceBindingSet;
+import org.jboss.ejb3.proxy.jndiregistrar.JndiSessionRegistrarBase;
+import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
+import org.jboss.ha.framework.interfaces.FamilyClusterInfo;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.ClusterConfigMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.remoting.InvokerLocator;
+
+
+
+/**
+ * Responsible for binding of ObjectFactories and creation/registration of 
+ * associated ProxyFactories, centralizing operations common to that of all 
+ * clustered Session EJB Implementations.
+ * 
+ * @author Brian Stansberry
+ */
+public abstract class JndiClusteredSessionRegistrarBase 
+   extends JndiSessionRegistrarBase
+   implements ProxyClusteringRegistryListener
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private static final Logger log = Logger.getLogger(JndiClusteredSessionRegistrarBase.class);
+   
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private final ProxyClusteringRegistry registry;
+   private final Map<String, BeanClusteringRegistryInfo> bindingsByContainer = new ConcurrentHashMap<String, BeanClusteringRegistryInfo>(); 
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Create a new JndiClusteredSessionRegistrarBase.
+    * 
+    * @param sessionProxyObjectFactoryType
+    * @param registry registry of clustering information about deployed containers
+    */
+   public JndiClusteredSessionRegistrarBase(String sessionProxyObjectFactoryType, 
+                                            ProxyClusteringRegistry registry)
+   {
+      super(sessionProxyObjectFactoryType);
+      
+      assert registry != null : "registry is null";
+      this.registry = registry;
+      this.registry.registerListener(this);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // ProxyClusteringRegistryListener -------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Finds any {@link JndiReferenceBindingSet} associated with the 
+    * <code>beanClusteringInfo</code>'s container, updates any <code>Reference</code>s
+    * associated with the <code>beanClusteringInfo</code>'s <code>FamilyWrapper</code> to
+    * reflect the new cluster topoloyg, and rebinds the reference in JNDI.
+    */
+   public void clusterTopologyChanged(ProxyClusteringInfo beanClusteringInfo)
+   {
+      JndiReferenceBindingSet bindings = null;
+      BeanClusteringRegistryInfo registryEntry = bindingsByContainer.get(beanClusteringInfo.getContainerName());
+      if (registryEntry != null)
+      {
+         bindings= registryEntry.bindings;
+      }
+      
+      if (bindings == null)
+      {
+         // We aren't handling this bean
+         return;
+      }
+      
+      Context context = bindings.getContext();
+      
+      FamilyClusterInfo fci = beanClusteringInfo.getFamilyWrapper().get();     
+      String familyName = fci.getFamilyName();
+      
+      for (JndiReferenceBinding binding : bindings.getDefaultRemoteBindings())
+      {
+         RefAddr refAddr = getFirstRefAddr(binding.getReference(), ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME);
+         if (refAddr != null && familyName.equals(refAddr.getContent()))
+         {
+            redecorateReferenceForClusteringTargets(binding.getReference(), fci);
+            rebind(context, binding.getJndiName(), binding.getReference());
+         }
+      }
+      
+      for (JndiReferenceBinding binding : bindings.getHomeRemoteBindings())
+      {
+         RefAddr refAddr = getFirstRefAddr(binding.getReference(), ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME);
+         if (refAddr != null && familyName.equals(refAddr.getContent()))
+         {
+            redecorateReferenceForClusteringTargets(binding.getReference(), fci);
+            rebind(context, binding.getJndiName(), binding.getReference());
+         }
+      }
+      
+      for (Set<JndiReferenceBinding> businessBindings : bindings.getBusinessRemoteBindings().values())
+      {         
+         for (JndiReferenceBinding binding : businessBindings)
+         {
+            RefAddr refAddr = getFirstRefAddr(binding.getReference(), ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME);
+            if (refAddr != null && familyName.equals(refAddr.getContent()))
+            {
+               redecorateReferenceForClusteringTargets(binding.getReference(), fci);
+               rebind(context, binding.getJndiName(), binding.getReference());
+            }
+         }
+      }
+   }
+
+   public void beanClusteringInfoAdded(ProxyClusteringInfo beanClusteringInfo)
+   {
+      BeanClusteringRegistryInfo info = getBeanClusteringRegistryInfo(beanClusteringInfo.getContainerName());
+      info.familyCount.incrementAndGet();
+   }
+
+   public void beanClusteringInfoRemoved(ProxyClusteringInfo beanClusteringInfo)
+   {
+      String containerName = beanClusteringInfo.getContainerName();
+      BeanClusteringRegistryInfo info = getBeanClusteringRegistryInfo(containerName);
+      if (info.familyCount.decrementAndGet() == 0)
+      {
+         bindingsByContainer.remove(containerName);
+      }
+   }   
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   public ProxyClusteringRegistry getRegistry()
+   {
+      return registry;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Overrides ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   @Override
+   public String getProxyFactoryRegistryKey(JBossSessionBeanMetaData md, boolean isLocal)
+   {
+      String key = super.getProxyFactoryRegistryKey(md, isLocal);
+      if (!isLocal)
+      {
+         ClusterConfigMetaData ccmd = md.getClusterConfig();
+         assert ccmd != null : ClusterConfigMetaData.class.getSimpleName() + " not found in metadata";
+         key += "/" + ProxyClusteringRegistry.getPartitionName(md.getClusterConfig());
+      }
+      return key;
+   }
+   
+   /**
+    * Overrides the superclass version to add clustering related {@link RefAddr}s
+    * to the binding references.
+    */
+   @Override
+   protected JndiReferenceBindingSet createJndiReferenceBindingSet(final Context context, 
+         final JBossSessionBeanMetaData smd, final ClassLoader cl,
+         final String containerName, final String containerGuid, final Advisor advisor)
+   {
+      JndiReferenceBindingSet bindings = super.createJndiReferenceBindingSet(context, smd, cl, containerName, containerGuid, advisor);
+      
+      decorateReferencesForClustering(bindings);
+      
+      // Store ref to bindings so we can rebind upon topology changes
+      BeanClusteringRegistryInfo registryInfo = getBeanClusteringRegistryInfo(containerName);      
+      registryInfo.bindings = bindings;
+      
+      return bindings;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Private ------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private BeanClusteringRegistryInfo getBeanClusteringRegistryInfo(final String containerName)
+   {
+      BeanClusteringRegistryInfo registryInfo = this.bindingsByContainer.get(containerName);
+      if (registryInfo == null)
+      {
+         registryInfo = new BeanClusteringRegistryInfo();
+         this.bindingsByContainer.put(containerName, registryInfo);
+      }
+      return registryInfo;
+   }
+
+   /**
+    * Add clustering related <code>RefAddr</code>s to the <code>Reference</code>s
+    * in the given binding set.
+    * 
+    * @param bindings the binding set
+    */
+   private void decorateReferencesForClustering(JndiReferenceBindingSet bindings)
+   {
+      for (JndiReferenceBinding binding : bindings.getDefaultRemoteBindings())
+      {
+         decorateReferenceForClustering(binding.getReference());
+      }
+      
+      for (JndiReferenceBinding binding : bindings.getHomeRemoteBindings())
+      {
+         decorateReferenceForClustering(binding.getReference());
+      }
+      
+      for (Set<JndiReferenceBinding> businessBindings : bindings.getBusinessRemoteBindings().values())
+      {
+         for (JndiReferenceBinding binding : businessBindings)
+         {
+            decorateReferenceForClustering(binding.getReference());
+         }
+      }
+   }
+   
+   /**
+    * Add clustering related <code>RefAddr</code>s to <code>Reference</code>
+    * 
+    * @param ref           the reference
+    */
+   private void decorateReferenceForClustering(Reference ref)
+   {
+      String proxyFactoryKey = getSingleRequiredRefAddr(ref, ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_PROXY_FACTORY_REGISTRY_KEY);
+      ProxyClusteringInfo bci = registry.getBeanClusteringInfo(proxyFactoryKey);
+      
+      if (bci == null)
+      {
+         throw new IllegalStateException("Cannot find " + ProxyClusteringInfo.class.getSimpleName() + 
+                                         " for proxyFactoryKey " + proxyFactoryKey);
+      }
+      
+      RefAddr partitionRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PARTITION_NAME, bci.getPartitionName());
+      addRefAddrToReference(ref, partitionRef);
+      RefAddr lbpRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PROXY_FACTORY_LOAD_BALANCE_POLICY, bci.getHomeLoadBalancePolicy().getName());
+      addRefAddrToReference(ref, lbpRef);
+      FamilyClusterInfo fci = bci.getFamilyWrapper().get();
+      RefAddr familyNameRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME, 
+                                                fci.getFamilyName());
+      addRefAddrToReference(ref, familyNameRef);
+      
+      decorateReferenceForClusteringTargets(ref, fci);
+   }
+
+   /**
+    * Removes from <code>ref</code> all existing <code>RefAddr</code>s of type 
+    * {@link ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL},
+    * and then calls {@link #decorateReferenceForClusteringTargets(Reference, FamilyClusterInfo).
+    *   
+    * @param ref the Reference
+    * @param fci the source of the targets
+    */
+   private void redecorateReferenceForClusteringTargets(Reference ref, FamilyClusterInfo fci)
+   {
+      for (int i = 0; i < ref.size(); i++)
+      {
+         RefAddr refAddr = ref.get(i);
+         if (ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL.equals(refAddr.getType()))
+         {
+            ref.remove(i);
+            i--;
+         }
+      }
+      decorateReferenceForClusteringTargets(ref, fci);
+   }
+   
+   /**
+    * Adds a <code>RefAddr</code> of type {@link ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL}
+    * to <code>ref</code> for each target associated with <code>fci</code>.
+    * 
+    * @param ref the Reference
+    * @param fci the source of the targets
+    */
+   @SuppressWarnings("unchecked")
+   private void decorateReferenceForClusteringTargets(Reference ref, FamilyClusterInfo fci)
+   {
+      List<Object> targets = fci.getTargets();
+      for (Object target : targets)
+      {
+         // Assert correct target type. Fail with assertion error if enabled,
+         // otherwise with an ISE
+         boolean correctType = (target instanceof InvokerLocator);
+         assert correctType : target + " is not an instance of InvokerLocator";
+         if (!correctType)
+            throw new IllegalStateException(target + " is not an instance of InvokerLocator");
+         
+         String url = ((InvokerLocator) target).getOriginalURI();
+         RefAddr targetRef = new StringRefAddr(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL, url);
+         addRefAddrToReference(ref, targetRef);
+      }
+   }
+   
+   private void addRefAddrToReference(Reference ref, RefAddr refAddr)
+   {
+      log.debug("Adding " + RefAddr.class.getSimpleName() + " to "
+            + Reference.class.getSimpleName() + ": Type \"" + refAddr.getType() + "\", Content \""
+            + refAddr.getContent() + "\"");
+      ref.add(refAddr);
+   }
+
+   private String getSingleRequiredRefAddr(Reference ref, String refAddrType)
+   {
+      RefAddr result = null;
+      for (int i = 0; i < ref.size(); i++)
+      {
+         RefAddr refAddr = ref.get(i);
+         if (refAddr.getType().equals(refAddrType))
+         {
+            if (result == null)
+            {
+               result = refAddr;
+            }
+            else
+            {
+               throw new IllegalStateException(ref + " has multiple RefAddr objects of type " + refAddrType);
+            }
+         }
+      }
+      
+      if (result == null)
+      {
+         throw new IllegalStateException(ref + " has no RefAddr object of type " + refAddrType);
+      }
+      
+      return (String) result.getContent();
+   }
+
+   private RefAddr getFirstRefAddr(Reference ref, String refAddrType)
+   {
+      for (int i = 0; i < ref.size(); i++)
+      {
+         RefAddr refAddr = ref.get(i);
+         if (refAddr.getType().equals(refAddrType))
+         {
+            return refAddr;
+         }
+      }
+      return null;
+   }
+   
+   private static class BeanClusteringRegistryInfo
+   {
+      private final AtomicInteger familyCount = new AtomicInteger();
+      private JndiReferenceBindingSet bindings;
+   }   
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatefulSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatefulSessionRegistrar.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatefulSessionRegistrar.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.jndiregistrar;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Dispatcher;
+import org.jboss.ejb3.proxy.clustered.factory.session.stateful.StatefulSessionClusteredProxyFactory;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.stateful.StatefulSessionLocalProxyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * Responsible for binding of ObjectFactories and
+ * creation/registration of associated ProxyFactories, 
+ * centralizing operations for clustered SFSB Implementations
+ *
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class JndiClusteredStatefulSessionRegistrar extends JndiClusteredSessionRegistrarBase
+{
+
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(JndiClusteredStatefulSessionRegistrar.class);
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates a JNDI Registrar from the specified configuration properties, none of
+    * which may be null.
+    * 
+    * @param statelessSessionProxyObjectFactoryType String representation of the JNDI Object Factory to use for SLSBs
+    * @param registry registry of clustering information about deployed containers
+    */
+   public JndiClusteredStatefulSessionRegistrar(String statelessSessionProxyObjectFactoryType, 
+         ProxyClusteringRegistry registry)
+   {
+      super(statelessSessionProxyObjectFactoryType, registry);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates and returns a new local proxy factory for this SFSB
+    * 
+    * @param name The unique name for the ProxyFactory
+    * @param containerName The name of the Container upon which Proxies 
+    *   from the returned ProxyFactory will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param smd The metadata representing this SFSB
+    * @param cl The ClassLoader for this EJB Container
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   @Override
+   protected SessionProxyFactory createLocalProxyFactory(final String name, final String containerName,
+         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
+   {
+      return new StatefulSessionLocalProxyFactory(name, containerName, containerGuid, smd, cl, advisor);
+   }
+
+   /**
+    * Creates and returns a new remote proxy factory for this SFSB
+    * 
+    * @param name The unique name for the ProxyFactory
+    * @param containerName The name of the Container upon which Proxies 
+    *   from the returned ProxyFactory will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param smd The metadata representing this SFSB
+    * @param cl The ClassLoader for this EJB Container
+    * @param url The URL to use for Remoting
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   @Override
+   protected SessionProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
+         final Advisor advisor)
+   {
+      // Create
+      SessionProxyFactory factory = new StatefulSessionClusteredProxyFactory(name, containerName, containerGuid, smd, cl,
+            url, advisor, getRegistry());
+
+      // Register with Remoting
+      log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
+      Dispatcher.singleton.registerTarget(factory.getName(), factory);
+
+      // Return
+      return factory;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatelessSessionRegistrar.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatelessSessionRegistrar.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/jndiregistrar/JndiClusteredStatelessSessionRegistrar.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.jndiregistrar;
+
+import org.jboss.aop.Advisor;
+import org.jboss.aop.Dispatcher;
+import org.jboss.ejb3.proxy.clustered.factory.session.stateless.StatelessSessionClusteredProxyFactory;
+import org.jboss.ejb3.proxy.clustered.registry.ProxyClusteringRegistry;
+import org.jboss.ejb3.proxy.factory.session.SessionProxyFactory;
+import org.jboss.ejb3.proxy.factory.session.stateless.StatelessSessionLocalProxyFactory;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+
+/**
+ * Responsible for binding of ObjectFactories and
+ * creation/registration of associated ProxyFactories, 
+ * centralizing operations for clustered SLSB Implementations
+ *
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class JndiClusteredStatelessSessionRegistrar extends JndiClusteredSessionRegistrarBase
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final Logger log = Logger.getLogger(JndiClusteredStatelessSessionRegistrar.class);
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates a JNDI Registrar from the specified configuration properties, none of
+    * which may be null.
+    * 
+    * @param statelessSessionProxyObjectFactoryType String representation of the JNDI Object Factory to use for SLSBs
+    * @param registry registry of clustering information about deployed containers
+    */
+   public JndiClusteredStatelessSessionRegistrar(String statelessSessionProxyObjectFactoryType, 
+         ProxyClusteringRegistry registry)
+   {
+      super(statelessSessionProxyObjectFactoryType, registry);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Creates and returns a new local proxy factory for this SLSB
+    * 
+    * @param name The unique name for the ProxyFactory
+    * @param containerName The name of the Container upon which Proxies 
+    *   from the returned ProxyFactory will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param containerGuid The globally-unique name of the container
+    * @param smd The metadata representing this SLSB
+    * @param cl The ClassLoader for this EJB Container
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   @Override
+   protected SessionProxyFactory createLocalProxyFactory(final String name, final String containerName,
+         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final Advisor advisor)
+   {
+      return new StatelessSessionLocalProxyFactory(name, containerName, containerGuid, smd, cl, advisor);
+   }
+
+   /**
+    * Creates and returns a new remote proxy factory for this Session Bean
+    * 
+    * @param name The unique name for the ProxyFactory
+    * @param containerName The name of the Container upon which Proxies 
+    *   from the returned ProxyFactory will invoke
+    * @param containerGuid The globally-unique name of the container
+    * @param smd The metadata representing this Session EJB
+    * @param cl The ClassLoader for this EJB Container
+    * @param url The URL to use for Remoting
+    * @param advisor The Advisor for proxies created by this factory
+    */
+   @Override
+   protected SessionProxyFactory createRemoteProxyFactory(final String name, final String containerName,
+         final String containerGuid, final JBossSessionBeanMetaData smd, final ClassLoader cl, final String url,
+         final Advisor advisor)
+   {
+      // Create
+      SessionProxyFactory factory = new StatelessSessionClusteredProxyFactory(name, containerName, containerGuid, smd, cl,
+            url, advisor, getRegistry());
+
+      // Register with Remoting
+      log.debug("Registering with Remoting Dispatcher under name \"" + factory.getName() + "\": " + factory);
+      Dispatcher.singleton.registerTarget(factory.getName(), factory);
+
+      // Return
+      return factory;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/ClusteredProxyFactoryReferenceAddressTypes.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/ClusteredProxyFactoryReferenceAddressTypes.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/ClusteredProxyFactoryReferenceAddressTypes.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.objectfactory;
+
+/**
+ * This interface defines the key constants used as 
+ * valid factory reference address types expected by a cluster-aware 
+ * ProxyObjectFactory
+ *
+ * @author <a href="mailto:andrew.rubinger at jboss.org">ALR</a>
+ * @version $Revision: $
+ */
+public interface ClusteredProxyFactoryReferenceAddressTypes
+{
+   // --------------------------------------------------------------------------------||
+   // Constants ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /*
+    * The following are Reference Address Types used in Remoting
+    */
+   
+   String REF_ADDR_TYPE_CLUSTER_PARTITION_NAME = "Cluster Partition Name";
+   
+   String REF_ADDR_TYPE_CLUSTER_PROXY_FACTORY_LOAD_BALANCE_POLICY = "Cluster Proxy Factory Load Balance Policy";
+   
+   String REF_ADDR_TYPE_CLUSTER_TARGET_ID = "Cluster Target ID";
+   
+   String REF_ADDR_TYPE_CLUSTER_FAMILY_NAME = "Cluster Family Name";
+   
+   String REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL = "Cluster Target Remoting Host URL";
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/SessionClusteredProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/SessionClusteredProxyObjectFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/SessionClusteredProxyObjectFactory.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,162 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.objectfactory.session;
+
+import java.lang.reflect.Proxy;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+
+import org.jboss.aop.advice.Interceptor;
+import org.jboss.aspects.remoting.ClusterChooserInterceptor;
+import org.jboss.aspects.remoting.ClusteredPojiProxy;
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
+import org.jboss.ejb3.proxy.clustered.objectfactory.ClusteredProxyFactoryReferenceAddressTypes;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.objectfactory.ProxyFactoryReferenceAddressTypes;
+import org.jboss.ejb3.proxy.objectfactory.session.SessionProxyObjectFactory;
+import org.jboss.ejb3.proxy.remoting.IsLocalProxyFactoryInterceptor;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.logging.Logger;
+import org.jboss.remoting.InvokerLocator;
+
+
+/**
+ * A JNDI Object Factory responsible for parsing metadata obtained from 
+ * Reference Address information and returning the appropriate clustered 
+ * Session Proxy.
+ * <p>
+ * Extends the superclass by ensuring that any remote calls to a proxy factory
+ * that are needed to create the Session Proxy are properly load balanced.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: $
+ *
+ */
+public class SessionClusteredProxyObjectFactory extends SessionProxyObjectFactory
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members  -----------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /** The serialVersionUID */
+   private static final long serialVersionUID = 2550630984434261500L;
+   
+   private static final Logger log = Logger.getLogger(SessionClusteredProxyObjectFactory.class.getName());
+   
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Clustered Session Bean Object Factories always create a new Proxy in order
+    * to get the latest target list for the bean from the server.
+    * 
+    * @param proxyFactory The ProxyFactory to use
+    * @param name The JNDI name looked up
+    * @param referenceAddresses
+    */
+   @Override
+   protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+   {
+      // We don't want any caching, as the target list can get out of date
+      return this.createProxy(proxyFactory, name, referenceAddresses);
+   }
+
+   /**
+    * Here we replace the superclass implementation to create a cluster aware
+    * proxy that will load balance requests to the server-side proxy factory.
+    * 
+    * {@inheritDoc}
+    */
+   @Override
+   protected ProxyFactory createProxyFactoryProxy(Name name, Map<String, List<String>> refAddrs,
+         String proxyFactoryRegistryKey) throws Exception
+   {
+      // Obtain the URL for invoking upon the Registry
+      String url = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+            ProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_INVOKER_LOCATOR_URL);
+
+      // Create an InvokerLocator
+      assert url != null && !url.trim().equals("") : InvokerLocator.class.getSimpleName()
+            + " URL is required, but is not specified; improperly bound reference in JNDI";
+      InvokerLocator locator = new InvokerLocator(url);
+      
+      String partitionName = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+            ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PARTITION_NAME);
+      
+      assert partitionName != null && !partitionName.trim().equals("") : " Partition name is required, but is not specified; improperly bound reference in JNDI";
+      
+      String lbpClass = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+            ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_PROXY_FACTORY_LOAD_BALANCE_POLICY);
+      
+      assert lbpClass != null && !lbpClass.trim().equals("") : LoadBalancePolicy.class.getSimpleName() 
+            + " class name is required, but is not specified; improperly bound reference in JNDI";
+      
+      ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+      LoadBalancePolicy loadBalancePolicy = (LoadBalancePolicy) tccl.loadClass(lbpClass).newInstance();
+      
+      FamilyWrapper wrapper = getFamilyWrapper(name, refAddrs);
+      
+      Class<?>[] interfaces = {this.getProxyFactoryClass()};
+      Interceptor[] interceptors = { IsLocalProxyFactoryInterceptor.singleton, 
+                                     ClusterChooserInterceptor.singleton, 
+                                     InvokeRemoteInterceptor.singleton };
+      
+      ClusteredPojiProxy proxy = new ClusteredPojiProxy(proxyFactoryRegistryKey, locator, interceptors, wrapper, 
+                                                        loadBalancePolicy, partitionName, null);
+      
+      return  (ProxyFactory) Proxy.newProxyInstance(interfaces[0].getClassLoader(), interfaces, proxy);
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Private ------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private FamilyWrapper getFamilyWrapper(Name name, Map<String, List<String>> refAddrs) throws MalformedURLException
+   {
+      String familyName = this.getSingleRequiredReferenceAddressValue(name, refAddrs,
+            ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_FAMILY_NAME);
+      
+      assert familyName != null && !familyName.trim().equals("") : " Cluster family name is required, but is not specified; improperly bound reference in JNDI";
+      
+      List<InvokerLocator> targets = new ArrayList<InvokerLocator>();
+      List<String> targetRefAddrs = refAddrs.get(ClusteredProxyFactoryReferenceAddressTypes.REF_ADDR_TYPE_CLUSTER_TARGET_INVOKER_LOCATOR_URL);
+      if (targetRefAddrs != null)
+      {
+         for (String url : targetRefAddrs)
+         {
+            targets.add(new InvokerLocator(url));
+         }
+      }
+      
+      log.debug("Creating " + FamilyWrapper.class.getSimpleName() + " for family " + 
+                familyName + " using targets " + targets);
+      return new FamilyWrapper(familyName, targets);
+   }
+   
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateful/StatefulSessionClusteredProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateful/StatefulSessionClusteredProxyObjectFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateful/StatefulSessionClusteredProxyObjectFactory.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.objectfactory.session.stateful;
+
+import java.util.List;
+import java.util.Map;
+
+import javax.naming.Name;
+
+import org.jboss.ejb3.proxy.clustered.objectfactory.session.SessionClusteredProxyObjectFactory;
+import org.jboss.ejb3.proxy.factory.ProxyFactory;
+import org.jboss.ejb3.proxy.objectfactory.session.stateful.StatefulSessionProxyObjectFactory;
+
+
+/**
+ * ClusteredStatefulSessionProxyObjectFactory
+ * 
+ * A JNDI ObjectFactory responsible for returning the appropriate clustered 
+ * SFSB Proxy upon lookup.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class StatefulSessionClusteredProxyObjectFactory extends SessionClusteredProxyObjectFactory
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members  -----------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * SFSB Object Factories must always create a new SFSB Proxy
+    * 
+    * @param proxyFactory The ProxyFactory to use
+    * @param name The JNDI name looked up
+    * @param referenceAddresses
+    */
+   @Override
+   protected Object getProxy(ProxyFactory proxyFactory, Name name, Map<String, List<String>> referenceAddresses)
+   {
+      // Create a new Proxy Instance
+      Object proxy = this.createProxy(proxyFactory, name, referenceAddresses);
+
+      // Return the Proxy
+      return proxy;
+   }
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateless/StatelessSessionClusteredProxyObjectFactory.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateless/StatelessSessionClusteredProxyObjectFactory.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectfactory/session/stateless/StatelessSessionClusteredProxyObjectFactory.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.objectfactory.session.stateless;
+
+import org.jboss.ejb3.proxy.clustered.objectfactory.session.SessionClusteredProxyObjectFactory;
+
+
+/**
+ * ClusteredStatelessSessionProxyObjectFactory
+ * 
+ * A JNDI ObjectFactory responsible for returning the appropriate clustered 
+ * SLSB Proxy upon lookup.
+ *
+ * @author Brian Stansberry
+ * @version $Revision: $
+ */
+public class StatelessSessionClusteredProxyObjectFactory extends SessionClusteredProxyObjectFactory
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members  -----------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private static final long serialVersionUID = 1L;
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectstore/ClusteredObjectStoreBindings.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectstore/ClusteredObjectStoreBindings.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/objectstore/ClusteredObjectStoreBindings.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.objectstore;
+
+import org.jboss.ejb3.proxy.objectstore.ObjectStoreBindings;
+
+/**
+ * Defines constants used in binding POJOs to the Object Store.
+ * 
+ * These values must match those either used to Register beans programmatically 
+ * or via XML Configuration
+ *
+ * @author Brian Stansberry 
+ * @version $Revision: $
+ */
+public interface ClusteredObjectStoreBindings extends ObjectStoreBindings
+{
+   // --------------------------------------------------------------------------------||
+   // Constants ----------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /**
+    * Bind name for ProxyClusteringRegistry
+    */
+   String CLUSTERED_OBJECTSTORE_BEAN_NAME_PROXY_CLUSTERING_REGISTRY = ObjectStoreBindings.OBJECTSTORE_NAMESPACE_EJB3
+         + "ProxyClusteringRegistry";
+   /**
+    * Bind name for SLSB JNDI Registrar
+    */
+   String CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SLSB = ObjectStoreBindings.OBJECTSTORE_NAMESPACE_JNDI_REGISTRAR_SESSION
+         + "ClusteredSLSBJndiRegistrar";
+
+   /**
+    * Bind name for SFSB JNDI Registrar
+    */
+   String CLUSTERED_OBJECTSTORE_BEAN_NAME_JNDI_REGISTRAR_SFSB = ObjectStoreBindings.OBJECTSTORE_NAMESPACE_JNDI_REGISTRAR_SESSION
+         + "ClusteredSFSBJndiRegistrar";
+
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringInfo.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringInfo.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringInfo.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.registry;
+
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.ha.framework.server.HATarget;
+
+/**
+ * Encapsulates clustering information about a particular container's
+ * cluster family.
+ * <p>
+ * There will be one instance of this class for each combination of container
+ * and InvokerLocator. So, a container that has two @RemoteBinding 
+ * annotations with different <code>clientBindUrl</code> values will generate
+ * two ProxyClusteringInfo objects.
+ * 
+ * @author Brian Stansberry
+ *
+ * @version $Revision: $
+ */
+public class ProxyClusteringInfo
+{
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   private final String containerName;
+   private final String proxyFactoryName;
+   private final FamilyWrapper familyWrapper;
+   private final String partitionName;
+   private final Class<? extends LoadBalancePolicy> loadBalancePolicy;
+   private final Class<? extends LoadBalancePolicy> homeLoadBalancePolicy;
+   private final HATarget haTarget;
+
+   // --------------------------------------------------------------------------------||
+   // Constructor --------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   public ProxyClusteringInfo(String containerName, String proxyFactoryName, 
+                             String partitionName, FamilyWrapper wrapper,
+                             Class<? extends LoadBalancePolicy> loadBalancePolicy,
+                             Class<? extends LoadBalancePolicy> homeLoadBalancePolicy, 
+                             HATarget haTarget)
+   {
+      assert containerName != null : "containerName is null";
+      assert proxyFactoryName != null : "proxyFactoryName is null";
+      assert partitionName != null : "partitionName is null";
+      assert wrapper != null : "wrapper is null";
+      assert loadBalancePolicy != null : "loadBalancePolicy is null";
+      assert homeLoadBalancePolicy != null : "homeLoadBalancePolicy is null";
+      assert haTarget != null : "haTarget is null";
+      
+      this.containerName = containerName;
+      this.proxyFactoryName = proxyFactoryName;
+      this.partitionName = partitionName;
+      this.familyWrapper = wrapper;
+      this.loadBalancePolicy = loadBalancePolicy;
+      this.homeLoadBalancePolicy = homeLoadBalancePolicy;
+      this.haTarget = haTarget;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||   
+
+   public String getContainerName()
+   {
+      return containerName;
+   }
+
+   public String getProxyFactoryName()
+   {
+      return proxyFactoryName;
+   }
+
+   public String getPartitionName()
+   {
+      return partitionName;
+   }
+
+   public FamilyWrapper getFamilyWrapper()
+   {
+      return familyWrapper;
+   }  
+
+   public Class<? extends LoadBalancePolicy> getLoadBalancePolicy()
+   {
+      return loadBalancePolicy;
+   }
+
+   public Class<? extends LoadBalancePolicy> getHomeLoadBalancePolicy()
+   {
+      return homeLoadBalancePolicy;
+   }
+
+   public HATarget getHaTarget()
+   {
+      return haTarget;
+   }   
+   
+}
\ No newline at end of file

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistry.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistry.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistry.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,373 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.registry;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
+import org.jboss.aspects.remoting.FamilyWrapper;
+import org.jboss.ejb3.annotation.defaults.ClusteredDefaults;
+import org.jboss.ejb3.proxy.clustered.familyname.ClusterFamilyNamePolicy;
+import org.jboss.ejb3.proxy.clustered.familyname.InvokerLocatorProtocolClusterFamilyNamePolicy;
+import org.jboss.ha.client.loadbalance.LoadBalancePolicy;
+import org.jboss.ha.client.loadbalance.RoundRobin;
+import org.jboss.ha.client.loadbalance.aop.FirstAvailable;
+import org.jboss.ha.framework.interfaces.DistributedReplicantManager;
+import org.jboss.ha.framework.interfaces.HAPartition;
+import org.jboss.ha.framework.interfaces.DistributedReplicantManager.ReplicantListener;
+import org.jboss.ha.framework.server.HAPartitionLocator;
+import org.jboss.ha.framework.server.HATarget;
+import org.jboss.logging.Logger;
+import org.jboss.metadata.ejb.jboss.ClusterConfigMetaData;
+import org.jboss.metadata.ejb.jboss.JBossSessionBeanMetaData;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.StringPropertyReplacer;
+
+/**
+ * Registry for clustering information about clustered containers.
+ * 
+ * @author Brian Stansberry
+ * @version $Revision: $
+ *
+ */
+public class ProxyClusteringRegistry implements ReplicantListener
+{
+   // --------------------------------------------------------------------------------||
+   // Class Members ------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   private static final Logger log = Logger.getLogger(ProxyClusteringRegistry.class);
+   
+   // --------------------------------------------------------------------------------||
+   // Instance Members ---------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+
+   /** Event listeners */
+   private List<ProxyClusteringRegistryListener> listeners = new ArrayList<ProxyClusteringRegistryListener>();
+   
+   /** Policy for creating names for FamilyClusterInfo */
+   private ClusterFamilyNamePolicy<InvokerLocator> clusterFamilyNamePolicy;
+   
+   /** Map of String annotation values to classes */
+   private Map<String, Class<LoadBalancePolicy>> loadBalancePolicies;
+   
+   /** Clustering data for each family */
+   private Map<String, ProxyClusteringInfo> beanInfosByFamilyName = new ConcurrentHashMap<String, ProxyClusteringInfo>();
+   /** Clustering data for each ProxyFactory */
+   private Map<String, ProxyClusteringInfo> beanInfosByProxyFactory = new ConcurrentHashMap<String, ProxyClusteringInfo>();
+   /** HATargets for each container, stored in a map keyed by family name */
+   private ConcurrentMap<String, Map<String, HATarget>> haTargetsByContainerName = new ConcurrentHashMap<String, Map<String, HATarget>>();
+   
+   // --------------------------------------------------------------------------------||
+   // Required Implementations -------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   public void registerListener(ProxyClusteringRegistryListener listener)
+   {
+      synchronized (listeners)
+      {
+         listeners.add(listener);
+      }
+   }
+   
+   public void unregisterListener(ProxyClusteringRegistryListener listener)
+   {
+      synchronized (listeners)
+      {
+         listeners.remove(listener);
+      }      
+   }
+   
+   public ProxyClusteringInfo registerClusteredBean(String containerName, String proxyFactoryName, 
+         JBossSessionBeanMetaData metadata, InvokerLocator locator)
+      throws Exception
+   {
+      ClusterConfigMetaData clusterMetadata = metadata.getClusterConfig();
+      String partitionName = getPartitionName(clusterMetadata);
+      
+      String familyInfoName = getClusterFamilyNamePolicy().getClusterFamilyName(containerName, locator, partitionName);
+      
+      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(partitionName, null);
+      HATarget hatarget = new HATarget(partition, familyInfoName, locator, HATarget.ENABLE_INVOCATIONS);
+      
+      FamilyWrapper wrapper = new FamilyWrapper(familyInfoName, hatarget.getReplicants());
+      
+      String lbpClassKey = clusterMetadata.getLoadBalancePolicy();
+      Class<? extends LoadBalancePolicy> lbPolicyClass = getLoadBalancePolicyClass(lbpClassKey, metadata.isStateful());         
+     
+      lbpClassKey = clusterMetadata.getHomeLoadBalancePolicy();
+      Class<? extends LoadBalancePolicy> homeLBPolicyClass = getLoadBalancePolicyClass(lbpClassKey, false);
+      
+      ProxyClusteringInfo info = new ProxyClusteringInfo(containerName, proxyFactoryName, partitionName, wrapper, lbPolicyClass, homeLBPolicyClass, hatarget);
+      
+      // Place this data in the various maps
+      registerBeanClusteringInfo(info);
+      
+      // IMPORTANT: This must be done after the HATarget is instantiated above
+      // or we will get a notification from our own work instantiating the HATarget
+      DistributedReplicantManager drm = partition.getDistributedReplicantManager();
+      drm.registerListener(familyInfoName, this);
+      
+      // Notify listeners of the addition. We do this after we register
+      // with the DRM so the listener won't know about the bean until our
+      // locally initiated DRM events have finished
+      List<ProxyClusteringRegistryListener> toNotify = null;
+      synchronized (listeners)
+      {
+         toNotify = new ArrayList<ProxyClusteringRegistryListener>(listeners);
+      }
+      
+      for (ProxyClusteringRegistryListener listener : toNotify)
+      {
+         listener.beanClusteringInfoAdded(info);
+      }
+      
+      return info;
+   }
+   
+   public void unregisterClusteredBean(ProxyClusteringInfo info)
+   {
+      String familyName = info.getFamilyWrapper().get().getFamilyName();
+      
+      // Destroy the HATarget and stop listening to DRM
+      info.getHaTarget().destroy();
+      HAPartition partition = HAPartitionLocator.getHAPartitionLocator().getHAPartition(info.getPartitionName(), null);
+      partition.getDistributedReplicantManager().unregisterListener(familyName, this);
+      
+      String containerName = info.getContainerName();
+      
+      beanInfosByFamilyName.remove(familyName);
+      beanInfosByProxyFactory.remove(info.getProxyFactoryName());
+      
+      Map<String, HATarget> haTargets = haTargetsByContainerName.get(containerName);
+      if (haTargets != null)
+      {
+         haTargets.remove(familyName);
+         if (haTargets.size() == 0)
+         {
+            haTargetsByContainerName.remove(containerName);
+         }
+      }
+      
+      /** Notify listeners of the removal */
+      List<ProxyClusteringRegistryListener> toNotify = null;
+      synchronized (listeners)
+      {
+         toNotify = new ArrayList<ProxyClusteringRegistryListener>(listeners);
+      }
+      
+      for (ProxyClusteringRegistryListener listener : toNotify)
+      {
+         listener.beanClusteringInfoRemoved(info);
+      }
+   }
+   
+   public ProxyClusteringInfo getBeanClusteringInfo(String proxyFactoryKey)
+   {
+      return beanInfosByProxyFactory.get(proxyFactoryKey);
+   }
+   
+   /**
+    * Gets a map of all <code>HATarget</code>s associated with the given
+    * container, keyed by the cluster family name associated with the 
+    * target.
+    * <p>
+    * This method is exposed for use by ReplicantsManagerInterceptorFactory
+    * in ejb3-core.
+    * </p>
+    * 
+    * @param containerName the name of the container
+    * @return Map<familyName, haTarget> or <code>null</code> if none are registered
+    */
+   public Map<String, HATarget> getHATargets(String containerName)
+   {
+      Map<String, HATarget> containerMap = new HashMap<String, HATarget>();
+      Map<String, HATarget> existing = haTargetsByContainerName.putIfAbsent(containerName, containerMap);
+      if (existing != null)
+      {
+         containerMap = existing;
+      }
+      return containerMap;
+   }
+   
+   // --------------------------------------------------------------------------------||
+   // ReplicantListener --------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /**
+    * Updates the FamilyWrapper identified by <code>key</code> and notifies
+    * any {@link ProxyClusteringRegistryListener}s of a topology change.
+    */
+   @SuppressWarnings("unchecked")
+   public void replicantsChanged(String key, List newReplicants, int newReplicantsViewId, boolean merge)
+   {
+      ProxyClusteringInfo info = beanInfosByFamilyName.get(key);
+      if (info != null)
+      {
+         info.getFamilyWrapper().get().updateClusterInfo(newReplicants, newReplicantsViewId);
+         
+         List<ProxyClusteringRegistryListener> toNotify = null;
+         synchronized (listeners)
+         {
+            toNotify = new ArrayList<ProxyClusteringRegistryListener>(listeners);
+         }
+         
+         for (ProxyClusteringRegistryListener listener : toNotify)
+         {
+            listener.clusterTopologyChanged(info);
+         }
+      }
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Accessors / Mutators -----------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   public synchronized ClusterFamilyNamePolicy<InvokerLocator> getClusterFamilyNamePolicy()
+   {
+      if (clusterFamilyNamePolicy == null)
+      {
+         clusterFamilyNamePolicy = new InvokerLocatorProtocolClusterFamilyNamePolicy();
+      }
+      return clusterFamilyNamePolicy;
+   }
+
+   public void setClusterFamilyNamePolicy(ClusterFamilyNamePolicy<InvokerLocator> clusterFamilyNamePolicy)
+   {
+      this.clusterFamilyNamePolicy = clusterFamilyNamePolicy;
+   }
+
+   public Map<String, Class<LoadBalancePolicy>> getLoadBalancePolicies()
+   {
+      return loadBalancePolicies;
+   }
+
+   public void setLoadBalancePolicies(Map<String, Class<LoadBalancePolicy>> loadBalancePolicies)
+   {
+      this.loadBalancePolicies = loadBalancePolicies;
+   }
+
+   // --------------------------------------------------------------------------------||
+   // Private ------------------------------------------------------------------------||
+   // --------------------------------------------------------------------------------||
+   
+   /**
+    * Gets the <code>Class</code> that corresponds to the given key.
+    * 
+    * @param lbpClassKey   the key
+    * @param defaultSticky if the key is <code>null</code>, empty or
+    *                      {@link ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT},
+    *                      should the default value returned implement 
+    *                      sticky-session behavior?
+    *                      
+    * @return the load balancy policy class
+    */
+   @SuppressWarnings("unchecked")
+   private Class<? extends LoadBalancePolicy> getLoadBalancePolicyClass(String lbpClassKey, boolean defaultSticky)
+   {
+      if (lbpClassKey == null || lbpClassKey.length() == 0 || lbpClassKey.equals(ClusteredDefaults.LOAD_BALANCE_POLICY_DEFAULT))
+      {
+         return defaultSticky ? FirstAvailable.class : RoundRobin.class;
+      }
+      else
+      {
+         Class<LoadBalancePolicy> lbPolicyClass = loadBalancePolicies == null ? null : loadBalancePolicies.get(lbpClassKey);
+         if (lbPolicyClass == null)
+         {
+            // Try to use the string as a classname
+            String className = lbpClassKey;
+            
+            // If it's a simple string, prepend a standard package
+            if (lbpClassKey.indexOf('.') < 0)
+            {
+               className = RoundRobin.class.getPackage().getName() + "." + lbpClassKey;
+            }
+            
+            try
+            {
+               lbPolicyClass = (Class<LoadBalancePolicy>) Thread.currentThread().getContextClassLoader().loadClass(className);
+            }
+            catch (ClassNotFoundException e)
+            {
+               // If it's a simple string, prepend a different standard package
+               if (lbpClassKey.indexOf('.') < 0)
+               {
+                  className = FirstAvailable.class.getPackage().getName() + "." + lbpClassKey;
+                  try
+                  {
+                     lbPolicyClass = (Class<LoadBalancePolicy>) Thread.currentThread().getContextClassLoader().loadClass(className);
+                  }
+                  catch (ClassNotFoundException ignored) {}
+               }
+               
+               if (lbPolicyClass == null)
+               {
+                  throw new IllegalStateException("Cannot determine LoadBalancePolicy class for key " + lbpClassKey);
+               }
+            }
+         }
+         
+         return lbPolicyClass;
+      }      
+   }
+   
+   private void registerBeanClusteringInfo(ProxyClusteringInfo info)
+   {
+      String containerName = info.getContainerName();
+      String familyName = info.getFamilyWrapper().get().getFamilyName();
+      
+      beanInfosByFamilyName.put(familyName, info);
+      
+      beanInfosByProxyFactory.put(info.getProxyFactoryName(), info);
+      
+      Map<String, HATarget> containerMap = getHATargets(containerName);      
+      containerMap.put(familyName, info.getHaTarget());
+   }
+   
+   public static String getPartitionName(ClusterConfigMetaData metadata)
+   {
+      String value = metadata.getPartitionName();
+      try
+      {
+         String replacedValue = StringPropertyReplacer.replaceProperties(value);
+         if (value != replacedValue)
+         {            
+            log.debug("Replacing " + ClusterConfigMetaData.class.getSimpleName() + 
+                  " partitionName property " + value + " with " + replacedValue);
+            value = replacedValue;
+         }
+      }
+      catch (Exception e)
+      {
+         log.warn("Unable to replace @Clustered partition attribute " + value + 
+                  ". Caused by " + e.getClass() + " " + e.getMessage());         
+      }
+      
+      return value;
+   }
+   
+}

Added: projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistryListener.java
===================================================================
--- projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistryListener.java	                        (rev 0)
+++ projects/ejb3/trunk/proxy-clustered/src/main/java/org/jboss/ejb3/proxy/clustered/registry/ProxyClusteringRegistryListener.java	2008-08-23 14:35:33 UTC (rev 77380)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.ejb3.proxy.clustered.registry;
+
+
+/**
+ * @author Brian Stansberry
+ *
+ */
+public interface ProxyClusteringRegistryListener
+{
+   /**
+    * Notification that a {@link ProxyClusteringInfo} has been registered.
+    * 
+    * @param beanClusteringInfo the item that was registered.
+    */
+   void beanClusteringInfoAdded(ProxyClusteringInfo beanClusteringInfo);
+   
+   /**
+    * Notification that a {@link ProxyClusteringInfo} has been unregistered.
+    * 
+    * @param beanClusteringInfo the item that was unregistered.
+    */
+   void beanClusteringInfoRemoved(ProxyClusteringInfo beanClusteringInfo);
+   
+   /**
+    * Notification that the cluster topology has changed for one of the
+    * cluster families associated with a container.
+    * 
+    * @param beanClusteringInfo the affected ProxyClusteringInfo
+    */
+   void clusterTopologyChanged(ProxyClusteringInfo beanClusteringInfo);
+}




More information about the jboss-cvs-commits mailing list