geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject svn commit: r630370 [1/4] - in /geronimo/server/trunk: ./ assemblies/geronimo-jetty6-javaee5/ framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/ plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geroni...
Date Sat, 23 Feb 2008 01:03:09 GMT
Author: gdamour
Date: Fri Feb 22 17:02:57 2008
New Revision: 630370

URL: http://svn.apache.org/viewvc?rev=630370&view=rev
Log:
1. Add SessionManagerListener to the clustering API. This allows clients
of local SessionManagers to receive callbacks when corresponding
remote SessionManagers join or leave the cluster.

2. Arbitrary WADI clustered services can now be registered: distributed
services are wrapped within ClusteredServiceHolder GBeans which are injected
to BasicWADISessionManager and registered with the underlying WADI 
ServiceRegistry.

3. Add support for clustering of SFSBs.

The structure mirrors the one applied for the clustering of Jetty and
Tomcat, i.e. two modules and two configurations are added:

- geronimo-openejb-clustering-wadi: defines a ClusteredRPCContainer
implementation for SFSBs and infrastructure components maintaining a 
bookkeeping of the connection addresses a clustered SFSB client can connect
to. The monitoring components, i.e. NetworkConnectorMonitor and 
NetworkConnectTracker, works as follows:
o When an OpenEJB NetworkConnector service starts, NetworkConnectMonitor
registers the address of this NC with the clustered service 
NetworkConnectorTracker and this for all the locally running clustered SFBS 
deployments.
o When an OpenEJB NC services stops, NCM executes an unregisteration reverting
the effects of a NC service start.
o When a clustered SFSB deployments starts, NCM registers its  deployment id
with the clustered service NCT for all the locally running NCs addresses.
o When a clustered SFSB deployment stops, NCM executes an unregisters reverting
the effects of a deployement start.
o When a node hosting an EJB module having clustered SFSBs stops or fails, NCM
updates the local NCT so that all the connection addresses registered for
all the clustered SFSB deployments of this node are removed.

- geronimo-openejb-clustering-builder-wadi: defines a builder to handle the
new substitution group element 'clustering' added to geronimo-openejb-2.0.xsd.
The clustering builder works nearly the same than for Jetty and Tomcat except
for the following specificities:
o A (WADI) clustered NCT service is registered.
o The container id for the clustered SFSBs is set to the Geronimo provided
clustered SFSB container implementation.

- openejb-clustering-wadi: declares Geronimo provided clustered SFSB
container implementation.

- openejb-clustering-builder-wadi: declares clustering builder.

Added:
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ClusteredServiceHolder.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptorTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManagerListener.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/BasicEjbDeploymentGBeanNameBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentGBeanNameBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/pom.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/cluster/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/cluster/MapSFSBToContainerIDDeployer.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/cluster/OpenEJBClusteringWADIConverter.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/java/org/apache/geronimo/openejb/deployment/cluster/WADIOpenEJBClusteringBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/xsd/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/xsd/geronimo-openejb-clustering-wadi-1.2.xsd
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/xsdconfig/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/main/xsdconfig/xmlconfig.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/geronimo/openejb/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/geronimo/openejb/deployment/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/geronimo/openejb/deployment/cluster/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-builder-wadi/src/test/java/org/apache/geronimo/openejb/deployment/cluster/MapSFSBToContainerIDDeployerTest.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/pom.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/Launcher.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/BasicNetworkConnectorTracker.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/BasicNetworkConnectorTrackerServiceHolder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/NetworkConnectorMonitor.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/NetworkConnectorTracker.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/NetworkConnectorTrackerException.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/infra/SessionManagerTracker.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/container/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/container/ClusteredBeanEntry.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/container/ClusteredStatefulContainer.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/container/ClusteredStatefulInstanceManager.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/java/org/apache/geronimo/openejb/cluster/stateful/deployment/ClusteredStatefulDeployment.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/resources/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/resources/META-INF/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/resources/META-INF/org.apache.geronimo.openejb.cluster/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/main/resources/META-INF/org.apache.geronimo.openejb.cluster/service-jar.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/infra/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/infra/BasicNetworkConnectorTrackerTest.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/infra/NetworkConnectorMonitorTest.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/stateful/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/stateful/container/
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/stateful/container/ClusteredStatefulContainerTest.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-clustering-wadi/src/test/java/org/apache/geronimo/openejb/cluster/stateful/container/ClusteredStatefulInstanceManagerTest.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentIdAccessor.java
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/pom.xml
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/src/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/src/main/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/src/main/plan/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-builder-wadi/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/LICENSE.txt
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/NOTICE.txt
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/pom.xml
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/src/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/src/main/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/src/main/plan/
    geronimo/server/trunk/plugins/openejb/openejb-clustering-wadi/src/main/plan/plan.xml
Modified:
    geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml
    geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManagerTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionManager.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManager.java
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationControllerTest.java
    geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStoreClientTest.java
    geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilderExtension.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbDeploymentBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModule.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/EjbModuleBuilder.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/xsd/geronimo-openejb-2.0.xsd
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/pom.xml
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeployment.java
    geronimo/server/trunk/plugins/openejb/geronimo-openejb/src/main/java/org/apache/geronimo/openejb/EjbDeploymentGBean.java
    geronimo/server/trunk/plugins/openejb/openejb-deployer/src/main/plan/plan.xml
    geronimo/server/trunk/plugins/openejb/pom.xml
    geronimo/server/trunk/pom.xml

Modified: geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml (original)
+++ geronimo/server/trunk/assemblies/geronimo-jetty6-javaee5/pom.xml Fri Feb 22 17:02:57 2008
@@ -133,6 +133,27 @@
         
         <dependency>
             <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>openejb-clustering-wadi</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>openejb-clustering-builder-wadi</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
+            <artifactId>transaction</artifactId>
+            <version>${version}</version>
+            <type>car</type>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.geronimo.configs</groupId>
             <artifactId>farming</artifactId>
             <version>${version}</version>
             <type>car</type>

Modified: geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManagerTest.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManagerTest.java (original)
+++ geronimo/server/trunk/framework/modules/geronimo-kernel/src/test/java/org/apache/geronimo/kernel/config/EditableKernelConfigurationManagerTest.java Fri Feb 22 17:02:57 2008
@@ -56,8 +56,8 @@
         ArtifactManager artifactManager = (ArtifactManager) mock(ArtifactManager.class);
         ArtifactResolver artifactResolver = (ArtifactResolver) mock(ArtifactResolver.class);
         
-        storeA = (ConfigurationStore) mock(ConfigurationStore.class);
-        storeB = (ConfigurationStore) mock(ConfigurationStore.class);
+        storeA = (ConfigurationStore) mock(ConfigurationStore.class, "ConfigurationStoreA");
+        storeB = (ConfigurationStore) mock(ConfigurationStore.class, "ConfigurationStoreB");
         
         stores = new ArrayList<ConfigurationStore>();
         

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADICluster.java Fri Feb 22 17:02:57 2008
@@ -38,8 +38,8 @@
     private final Node node;
     private final DispatcherHolder dispatcherHolder;
     private final NodeFactory nodeFactory;
-    private final IdentityHashMap<Peer, Node> peerToNode;
     private final IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener> listenerToWADIListener;
+    private final org.codehaus.wadi.group.ClusterListener wrapNodeAsPeerListener;
     
     private org.codehaus.wadi.group.Cluster cluster;
     
@@ -57,19 +57,34 @@
         this.dispatcherHolder = dispatcherHolder;
         this.nodeFactory = nodeFactory;
         
-        peerToNode = new IdentityHashMap<Peer, Node>();
         listenerToWADIListener = new IdentityHashMap<ClusterListener, org.codehaus.wadi.group.ClusterListener>();
+        
+        wrapNodeAsPeerListener = new org.codehaus.wadi.group.ClusterListener() {
+            public void onListenerRegistration(org.codehaus.wadi.group.Cluster cluster, Set existing) {
+                wrapAsNode(existing);
+            }
+            
+            public void onMembershipChanged(org.codehaus.wadi.group.Cluster cluster, Set joiners, Set leavers) {
+                wrapAsNode(joiners);
+            }
+        };
     }
     
     public void doStart() throws Exception {
         cluster = dispatcherHolder.getDispatcher().getCluster();
+        
+        cluster.addClusterListener(wrapNodeAsPeerListener);
     }
     
     public void doStop() throws Exception {
+        cluster.removeClusterListener(wrapNodeAsPeerListener);
+        
         clearListeners();
     }
 
     public void doFail() {
+        cluster.removeClusterListener(wrapNodeAsPeerListener);
+
         clearListeners();
     }
 
@@ -87,7 +102,7 @@
     
     public Set<Node> getRemoteNodes() {
         Collection<Peer> peers = cluster.getRemotePeers().values();
-        Set<Node> nodes = wrapAsNode(peers, false);
+        Set<Node> nodes = wrapAsNode(peers);
         return nodes;
     }
 
@@ -116,30 +131,19 @@
         listenerToWADIListener.clear();
     }
     
-    protected Set<Node> wrapAsNode(Collection<Peer> peers, boolean remove) {
+    protected Set<Node> wrapAsNode(Collection<Peer> peers) {
         Set<Node> nodes = new HashSet<Node>();
         for (Peer peer : peers) {
-            Node node = wrapAsNode(peer, remove);
+            Node node = wrapAsNode(peer);
             nodes.add(node);
         }
         return nodes;
     }
 
-    protected Node wrapAsNode(Peer peer, boolean remove) {
-        Node node;
-        synchronized (peerToNode) {
-            if (remove) {
-                node = peerToNode.remove(peer);
-                if (null == node) {
-                    throw new AssertionError("no node mapped to peer");
-                }
-            } else {
-                node = peerToNode.get(peer);
-                if (null == node) {
-                    node = newRemoteNode(peer);
-                    peerToNode.put(peer, node);
-                }
-            }
+    protected Node wrapAsNode(Peer peer) {
+        Node node = RemoteNode.retrieveOptionalAdaptor(peer);
+        if (null == node) {
+            node = newRemoteNode(peer);
         }
         return node;
     }
@@ -156,13 +160,13 @@
         }
 
         public void onListenerRegistration(org.codehaus.wadi.group.Cluster cluster, Set existing) {
-            Set<Node> existingNodes = wrapAsNode(existing, false);
+            Set<Node> existingNodes = wrapAsNode(existing);
             listener.onListenerRegistration(BasicWADICluster.this, existingNodes);
         }
         
         public void onMembershipChanged(org.codehaus.wadi.group.Cluster cluster, Set joiners, Set leavers) {
-            Set<Node> joinerNodes = wrapAsNode(joiners, false);
-            Set<Node> leaverNodes = wrapAsNode(leavers, true);
+            Set<Node> joinerNodes = wrapAsNode(joiners);
+            Set<Node> leaverNodes = wrapAsNode(leavers);
             listener.onMembershipChanged(BasicWADICluster.this, joinerNodes, leaverNodes);
         }
         

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManager.java Fri Feb 22 17:02:57 2008
@@ -16,20 +16,22 @@
  */
 package org.apache.geronimo.clustering.wadi;
 
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.clustering.Cluster;
 import org.apache.geronimo.clustering.Node;
 import org.apache.geronimo.clustering.Session;
 import org.apache.geronimo.clustering.SessionAlreadyExistException;
 import org.apache.geronimo.clustering.SessionListener;
 import org.apache.geronimo.clustering.SessionManager;
+import org.apache.geronimo.clustering.SessionManagerListener;
 import org.apache.geronimo.gbean.GBeanInfo;
 import org.apache.geronimo.gbean.GBeanInfoBuilder;
 import org.apache.geronimo.gbean.GBeanLifecycle;
@@ -41,7 +43,12 @@
 import org.codehaus.wadi.group.Dispatcher;
 import org.codehaus.wadi.group.Peer;
 import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
+import org.codehaus.wadi.servicespace.LifecycleState;
+import org.codehaus.wadi.servicespace.ServiceAlreadyRegisteredException;
+import org.codehaus.wadi.servicespace.ServiceRegistry;
 import org.codehaus.wadi.servicespace.ServiceSpace;
+import org.codehaus.wadi.servicespace.ServiceSpaceLifecycleEvent;
+import org.codehaus.wadi.servicespace.ServiceSpaceListener;
 import org.codehaus.wadi.servicespace.ServiceSpaceName;
 
 /**
@@ -51,27 +58,43 @@
 public class BasicWADISessionManager implements GBeanLifecycle, SessionManager, WADISessionManager {
     private static final Log log = LogFactory.getLog(BasicWADISessionManager.class);
 
-    private final ClassLoader cl;
+    protected final ClassLoader cl;
     private final WADICluster cluster;
-    private final WADISessionManagerConfigInfo configInfo;
-    private final BackingStrategyFactory backingStrategyFactory;
+    protected final WADISessionManagerConfigInfo configInfo;
+    protected final BackingStrategyFactory backingStrategyFactory;
+    private final Collection<ClusteredServiceHolder> serviceHolders;
     private final CopyOnWriteArrayList<SessionListener> listeners;
+    private final Map<SessionManagerListener, ServiceSpaceListener> sessionManagerListenerToAdapter;
 
     private Manager manager;
     private SessionMonitor sessionMonitor;
     private ServiceSpace serviceSpace;
 
-
+    
     public BasicWADISessionManager(ClassLoader cl,
-            WADISessionManagerConfigInfo configInfo,
-            WADICluster cluster,
-            BackingStrategyFactory backingStrategyFactory) {
+        WADISessionManagerConfigInfo configInfo,
+        WADICluster cluster,
+        BackingStrategyFactory backingStrategyFactory,
+        Collection<ClusteredServiceHolder> serviceHolders) {
+        if (null == cl) {
+            throw new IllegalArgumentException("cl is required");
+        } else if (null == configInfo) {
+            throw new IllegalArgumentException("configInfo is required");
+        } else if (null == cluster) {
+            throw new IllegalArgumentException("cluster is required");
+        } else if (null == backingStrategyFactory) {
+            throw new IllegalArgumentException("backingStrategyFactory is required");
+        } else if (null == serviceHolders) {
+            throw new IllegalArgumentException("serviceHolders is required");
+        }
         this.cl = cl;
         this.configInfo = configInfo;
         this.cluster = cluster;
         this.backingStrategyFactory = backingStrategyFactory;
+        this.serviceHolders = serviceHolders;
 
         listeners = new CopyOnWriteArrayList<SessionListener>();
+        sessionManagerListenerToAdapter = new HashMap<SessionManagerListener, ServiceSpaceListener>();
     }
 
     public void doStart() throws Exception {
@@ -80,31 +103,22 @@
         ServiceSpaceName serviceSpaceName = new ServiceSpaceName(configInfo.getServiceSpaceURI());
         StackContext stackContext;
         if (configInfo.isDeltaReplication()) {
-            stackContext = new AOPStackContext(cl,
-                serviceSpaceName,
-                underlyingDisp,
-                configInfo.getSessionTimeoutSeconds(),
-                configInfo.getNumPartitions(),
-                configInfo.getSweepInterval(),
-                backingStrategyFactory);
+            stackContext = newAOPStackContext(underlyingDisp, serviceSpaceName);
         } else {
-            stackContext = new StackContext(cl,
-                serviceSpaceName,
-                underlyingDisp,
-                configInfo.getSessionTimeoutSeconds(),
-                configInfo.getNumPartitions(),
-                configInfo.getSweepInterval(),
-                backingStrategyFactory);
+            stackContext = newStackContext(underlyingDisp, serviceSpaceName);
         }
         stackContext.setDisableReplication(configInfo.isDisableReplication());
         stackContext.build();
 
         serviceSpace = stackContext.getServiceSpace();
+        
         manager = stackContext.getManager();
 
         sessionMonitor = stackContext.getSessionMonitor();
         sessionMonitor.addSessionListener(new SessionListenerAdapter());
         
+        registerClusteredServices();
+
         serviceSpace.start();
     }
 
@@ -134,28 +148,17 @@
         return manager;
     }
 
+    public Cluster getCluster() {
+        return cluster;
+    }
+    
     public Node getNode() {
         return cluster.getLocalNode();
     }
 
     public Set<Node> getRemoteNodes() {
-        Map<Peer, RemoteNode> peerToRemoteNode = new HashMap<Peer, RemoteNode>();
-        Set<Node> clusterNodes = cluster.getRemoteNodes();
-        for (Iterator<Node> iterator = clusterNodes.iterator(); iterator.hasNext();) {
-            RemoteNode remoteNode = (RemoteNode) iterator.next();
-            peerToRemoteNode.put(remoteNode.getPeer(), remoteNode);
-        }
-        
-        Set<Node> nodes = new HashSet<Node>();
         Set<Peer> peers = serviceSpace.getHostingPeers();
-        for (Peer peer : peers) {
-            RemoteNode remoteNode = peerToRemoteNode.get(peer);
-            if (null == remoteNode) {
-                throw new AssertionError("remoteNode is null");
-            }
-            nodes.add(remoteNode);
-        }
-        return nodes;
+        return mapToNodes(peers);
     }
 
     public void registerListener(SessionListener listener) {
@@ -166,25 +169,90 @@
         listeners.remove(listener);
     }
 
-    private void notifyInboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
+    public void registerSessionManagerListener(SessionManagerListener listener) {
+        ServiceSpaceListener adapter = new ServiceSpaceListenerAdapter(listener);
+        serviceSpace.addServiceSpaceListener(adapter);
+        synchronized (sessionManagerListenerToAdapter) {
+            sessionManagerListenerToAdapter.put(listener, adapter);
+        }
+    }
+
+    public void unregisterSessionManagerListener(SessionManagerListener listener) {
+        ServiceSpaceListener adapter;
+        synchronized (sessionManagerListenerToAdapter) {
+            adapter = sessionManagerListenerToAdapter.remove(listener);
+        }
+        if (null == adapter) {
+            throw new IllegalArgumentException("Listener [" + listener + "] is not registered");
+        }
+        serviceSpace.removeServiceSpaceListener(adapter);
+    }
+
+    public ServiceSpace getServiceSpace() {
+        return serviceSpace;
+    }
+
+    protected StackContext newStackContext(Dispatcher underlyingDisp, ServiceSpaceName serviceSpaceName) {
+        return new StackContext(cl,
+            serviceSpaceName,
+            underlyingDisp,
+            configInfo.getSessionTimeoutSeconds(),
+            configInfo.getNumPartitions(),
+            configInfo.getSweepInterval(),
+            backingStrategyFactory);
+    }
+
+    protected AOPStackContext newAOPStackContext(Dispatcher underlyingDisp, ServiceSpaceName serviceSpaceName) {
+        return new AOPStackContext(cl,
+            serviceSpaceName,
+            underlyingDisp,
+            configInfo.getSessionTimeoutSeconds(),
+            configInfo.getNumPartitions(),
+            configInfo.getSweepInterval(),
+            backingStrategyFactory);
+    }
+    
+    protected void registerClusteredServices() throws ServiceAlreadyRegisteredException {
+        ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
+        for (ClusteredServiceHolder serviceHolder : serviceHolders) {
+            serviceRegistry.register(serviceHolder.getServiceName(), serviceHolder.getService());
+        }
+    }
+
+    protected Set<Node> mapToNodes(Set<Peer> peers) throws AssertionError {
+        Set<Node> nodes = new HashSet<Node>();
+        for (Peer peer : peers) {
+            RemoteNode remoteNode = RemoteNode.retrieveAdaptor(peer);
+            nodes.add(remoteNode);
+        }
+        return nodes;
+    }
+
+    protected Node mapToNode(Peer peer) throws AssertionError {
+        return RemoteNode.retrieveAdaptor(peer);
+    }
+
+    protected void notifyInboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
         for (SessionListener listener : listeners) {
             listener.notifyInboundSessionMigration(new WADISessionAdaptor(session));
         }
     }
 
-    private void notifyOutboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
+    protected void notifyOutboundSessionMigration(org.codehaus.wadi.core.session.Session session) {
         for (SessionListener listener : listeners) {
-            listener.notifyOutboundSessionMigration(new WADISessionAdaptor(session));
+            WADISessionAdaptor adaptor = WADISessionAdaptor.retrieveAdaptor(session);
+            listener.notifyOutboundSessionMigration(adaptor);
         }
     }
 
-    private void notifySessionDestruction(org.codehaus.wadi.core.session.Session session) {
+    protected void notifySessionDestruction(org.codehaus.wadi.core.session.Session session) {
         for (SessionListener listener : listeners) {
-            listener.notifySessionDestruction(new WADISessionAdaptor(session));
+            WADISessionAdaptor adaptor = WADISessionAdaptor.retrieveAdaptor(session);
+            listener.notifySessionDestruction(adaptor);
         }
     }
 
-    private class SessionListenerAdapter implements org.codehaus.wadi.core.manager.SessionListener {
+    protected class SessionListenerAdapter implements org.codehaus.wadi.core.manager.SessionListener {
 
         public void onSessionCreation(org.codehaus.wadi.core.session.Session session) {
         }
@@ -203,12 +271,35 @@
         
     }
 
+    protected class ServiceSpaceListenerAdapter implements ServiceSpaceListener {
+        private final SessionManagerListener listener;
+        
+        public ServiceSpaceListenerAdapter(SessionManagerListener listener) {
+            this.listener = listener;
+        }
+
+        public void receive(ServiceSpaceLifecycleEvent event, Set<Peer> newHostingPeers) {
+            LifecycleState state = event.getState();
+            if (state == LifecycleState.STARTED) {
+                Set<Node> newHostingNodes = mapToNodes(newHostingPeers);
+                Node joiningNode = mapToNode(event.getHostingPeer());
+                listener.onJoin(joiningNode, newHostingNodes);
+            } else if (state == LifecycleState.STOPPED || state == LifecycleState.FAILED) {
+                Set<Node> newHostingNodes = mapToNodes(newHostingPeers);
+                Node leavingNode = mapToNode(event.getHostingPeer());
+                listener.onLeave(leavingNode, newHostingNodes);
+            }
+        }
+    }
+    
     public static final GBeanInfo GBEAN_INFO;
 
     public static final String GBEAN_ATTR_WADI_CONFIG_INFO = "wadiConfigInfo";
 
     public static final String GBEAN_REF_CLUSTER = "Cluster";
     public static final String GBEAN_REF_BACKING_STRATEGY_FACTORY = "BackingStrategyFactory";
+    public static final String GBEAN_REF_SERVICE_HOLDERS = "ServiceHolders";
+
 
     static {
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic("WADI Session Manager",
@@ -220,6 +311,7 @@
         infoBuilder.addReference(GBEAN_REF_CLUSTER, WADICluster.class, NameFactory.GERONIMO_SERVICE);
         infoBuilder.addReference(GBEAN_REF_BACKING_STRATEGY_FACTORY, BackingStrategyFactory.class,
                 NameFactory.GERONIMO_SERVICE);
+        infoBuilder.addReference(GBEAN_REF_SERVICE_HOLDERS, ClusteredServiceHolder.class, NameFactory.GERONIMO_SERVICE);
 
         infoBuilder.addInterface(SessionManager.class);
         infoBuilder.addInterface(WADISessionManager.class);
@@ -227,7 +319,8 @@
         infoBuilder.setConstructor(new String[] { "classLoader", 
                 GBEAN_ATTR_WADI_CONFIG_INFO,
                 GBEAN_REF_CLUSTER, 
-                GBEAN_REF_BACKING_STRATEGY_FACTORY });
+                GBEAN_REF_BACKING_STRATEGY_FACTORY,
+                GBEAN_REF_SERVICE_HOLDERS});
 
         GBEAN_INFO = infoBuilder.getBeanInfo();
     }

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ClusteredServiceHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ClusteredServiceHolder.java?rev=630370&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ClusteredServiceHolder.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/ClusteredServiceHolder.java Fri Feb 22 17:02:57 2008
@@ -0,0 +1,30 @@
+/**
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.geronimo.clustering.wadi;
+
+import org.codehaus.wadi.servicespace.ServiceName;
+
+
+/**
+ * 
+ * @version $Rev$ $Date$
+ */
+public interface ClusteredServiceHolder {
+    ServiceName getServiceName();
+    
+    Object getService();
+}
\ No newline at end of file

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/RemoteNode.java Fri Feb 22 17:02:57 2008
@@ -25,6 +25,20 @@
  * @version $Rev$ $Date$
  */
 public class RemoteNode extends AbstractNode {
+    private static final String ADAPTOR_KEY = "ADAPTOR_KEY";
+
+    public static RemoteNode retrieveOptionalAdaptor(Peer peer) {
+        return (RemoteNode) peer.getLocalStateMap().get(ADAPTOR_KEY);
+    }
+
+    public static RemoteNode retrieveAdaptor(Peer peer) {
+        RemoteNode node = (RemoteNode) peer.getLocalStateMap().get(ADAPTOR_KEY);
+        if (null == node) {
+            throw new IllegalStateException("No registered adaptor");
+        }
+        return node;
+    }
+    
     private final Peer peer;
     private final NodeService nodeService;
     private NodeConnectionInfo connectionInfo;
@@ -36,6 +50,8 @@
         }
         this.peer = peer;
         this.nodeService = nodeService;
+        
+        peer.getLocalStateMap().put(ADAPTOR_KEY, this);
     }
 
     public Peer getPeer() {

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/TribesDispatcherHolder.java Fri Feb 22 17:02:57 2008
@@ -29,6 +29,7 @@
 import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
 import org.codehaus.wadi.core.reflect.base.DeclaredMemberFilter;
 import org.codehaus.wadi.core.reflect.jdk.JDKClassIndexerRegistry;
+import org.codehaus.wadi.core.util.SimpleStreamer;
 import org.codehaus.wadi.group.Dispatcher;
 import org.codehaus.wadi.group.DispatcherRegistry;
 import org.codehaus.wadi.group.MessageExchangeException;
@@ -47,22 +48,27 @@
     private final URI endPointURI;
     private final String clusterName;
     private final LocalNode node;
+    private final ClassLoader cl;
     private final DispatcherRegistry dispatcherRegistry;
 
     private TribesDispatcher dispatcher;
     private AdminServiceSpace adminServiceSpace;
 
-    public TribesDispatcherHolder(URI endPointURI, String clusterName, LocalNode node) {
+
+    public TribesDispatcherHolder(ClassLoader cl, URI endPointURI, String clusterName, LocalNode node) {
         if (null == endPointURI) {
             throw new IllegalArgumentException("endPointURI is required");
         } else if (null == clusterName) {
             throw new IllegalArgumentException("clusterName is required");
         } else if (null == node) {
             throw new IllegalArgumentException("node is required");
+        } else if (null == cl) {
+            throw new IllegalArgumentException("cl is required");
         }
         this.endPointURI = endPointURI;
         this.clusterName = clusterName;
         this.node = node;
+        this.cl = cl;
         
         dispatcherRegistry = new StaticDispatcherRegistry();
     }
@@ -74,7 +80,9 @@
             Collections.EMPTY_SET);
         dispatcher.start();
         
-        adminServiceSpace = new AdminServiceSpace(dispatcher, new JDKClassIndexerRegistry(new DeclaredMemberFilter()));
+        adminServiceSpace = new AdminServiceSpace(dispatcher,
+            new JDKClassIndexerRegistry(new DeclaredMemberFilter()),
+            new SimpleStreamer(cl));
         
         registerCustomAdminServices();
         
@@ -133,6 +141,7 @@
         GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(TribesDispatcherHolder.class, 
                 NameFactory.GERONIMO_SERVICE);
         
+        infoBuilder.addAttribute("classLoader", ClassLoader.class, false);
         infoBuilder.addAttribute(GBEAN_ATTR_END_POINT_URI, URI.class, true);
         infoBuilder.addAttribute(GBEAN_ATTR_CLUSTER_NAME, String.class, true);
         
@@ -140,7 +149,7 @@
 
         infoBuilder.addInterface(DispatcherHolder.class);
         
-        infoBuilder.setConstructor(new String[] {
+        infoBuilder.setConstructor(new String[] {"classLoader",
                 GBEAN_ATTR_END_POINT_URI,
                 GBEAN_ATTR_CLUSTER_NAME,
                 GBEAN_REF_NODE });

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptor.java Fri Feb 22 17:02:57 2008
@@ -25,10 +25,24 @@
  * @version $Rev$ $Date$
  */
 public class WADISessionAdaptor implements Session {
+    private static final String ADAPTOR_KEY = "ADAPTOR_KEY";
     private final org.codehaus.wadi.core.session.Session session;
     
+    public static WADISessionAdaptor retrieveAdaptor(org.codehaus.wadi.core.session.Session session) {
+        WADISessionAdaptor adaptor = (WADISessionAdaptor) session.getLocalStateMap().get(ADAPTOR_KEY);
+        if (null == adaptor) {
+            throw new IllegalStateException("No registered adaptor");
+        }
+        return adaptor;
+    }
+
     public WADISessionAdaptor(org.codehaus.wadi.core.session.Session session) {
+        if (null == session) {
+            throw new IllegalArgumentException("session is required");
+        }
         this.session = session;
+
+        session.getLocalStateMap().put(ADAPTOR_KEY, this);
     }
 
     public String getSessionId() {
@@ -62,5 +76,5 @@
     public void onEndAccess() {
         session.onEndProcessing();
     }
-    
+
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionManager.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionManager.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/main/java/org/apache/geronimo/clustering/wadi/WADISessionManager.java Fri Feb 22 17:02:57 2008
@@ -16,12 +16,16 @@
  */
 package org.apache.geronimo.clustering.wadi;
 
+import org.apache.geronimo.clustering.SessionManager;
 import org.codehaus.wadi.core.manager.Manager;
+import org.codehaus.wadi.servicespace.ServiceSpace;
 
 /**
  * 
  * @version $Rev$ $Date$
  */
-public interface WADISessionManager {
+public interface WADISessionManager extends SessionManager {
     Manager getManager();
+    
+    ServiceSpace getServiceSpace();
 }

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADIClusterTest.java Fri Feb 22 17:02:57 2008
@@ -62,6 +62,9 @@
         wadiCluster.getClusterName();
         modify().multiplicity(expect.from(0)).returnValue("name");
 
+        wadiCluster.addClusterListener(null);
+        modify().args(is.NOT_NULL);
+        
         wadiCluster.getDispatcher();
         modify().multiplicity(expect.from(0)).returnValue(dispatcher);
         
@@ -86,6 +89,8 @@
 
     private Peer addPeer(String peerName, Map<Address, Peer> remotePeers) {
         Peer peer = (Peer) mock(Peer.class, peerName);
+        peer.getLocalStateMap();
+        modify().multiplicity(expect.from(0)).returnValue(new HashMap());
 
         Address address = peer.getAddress();
         modify().multiplicity(expect.from(0));
@@ -209,6 +214,9 @@
     }
     
     public void testRemoveListenersOnStopOrFail() throws Exception {
+        wadiCluster.removeClusterListener(null);
+        modify().args(is.NOT_NULL);
+
         AbstractExpression assertSame = new AssertSameWADIListener();
         wadiCluster.addClusterListener(null);
         modify().args(assertSame);

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerTest.java?rev=630370&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerTest.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/BasicWADISessionManagerTest.java Fri Feb 22 17:02:57 2008
@@ -0,0 +1,411 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.wadi;
+
+import java.io.IOException;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.geronimo.clustering.Node;
+import org.apache.geronimo.clustering.SessionListener;
+import org.apache.geronimo.clustering.SessionManagerListener;
+import org.codehaus.wadi.core.assembler.StackContext;
+import org.codehaus.wadi.core.manager.Manager;
+import org.codehaus.wadi.core.manager.SessionAlreadyExistException;
+import org.codehaus.wadi.core.manager.SessionMonitor;
+import org.codehaus.wadi.core.session.Session;
+import org.codehaus.wadi.group.Dispatcher;
+import org.codehaus.wadi.group.Peer;
+import org.codehaus.wadi.replication.strategy.BackingStrategyFactory;
+import org.codehaus.wadi.servicespace.LifecycleState;
+import org.codehaus.wadi.servicespace.ServiceAlreadyRegisteredException;
+import org.codehaus.wadi.servicespace.ServiceName;
+import org.codehaus.wadi.servicespace.ServiceRegistry;
+import org.codehaus.wadi.servicespace.ServiceSpace;
+import org.codehaus.wadi.servicespace.ServiceSpaceLifecycleEvent;
+import org.codehaus.wadi.servicespace.ServiceSpaceListener;
+import org.codehaus.wadi.servicespace.ServiceSpaceName;
+
+import com.agical.rmock.core.describe.ExpressionDescriber;
+import com.agical.rmock.core.match.operator.AbstractExpression;
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicWADISessionManagerTest extends RMockTestCase {
+
+    private ServiceSpace serviceSpace;
+    private SessionMonitor sessionMonitor;
+    private Manager wadiManager;
+    private WADICluster cluster;
+    private BackingStrategyFactory backingStrategyFactory;
+    private BasicWADISessionManager manager;
+
+    private org.codehaus.wadi.core.manager.SessionListener wadiSessionListener;
+    private ServiceSpaceListener serviceSpaceListener;
+
+    @Override
+    protected void setUp() throws Exception {
+        cluster = (WADICluster) mock(WADICluster.class);
+        backingStrategyFactory = (BackingStrategyFactory) mock(BackingStrategyFactory.class);
+        serviceSpace = (ServiceSpace) mock(ServiceSpace.class);
+        wadiManager = (Manager) mock(Manager.class);
+        sessionMonitor = (SessionMonitor) mock(SessionMonitor.class);
+    }
+
+    private BasicWADISessionManager newManager(Collection<ClusteredServiceHolder> serviceHolders) throws Exception {
+        return new BasicWADISessionManager(getClass().getClassLoader(),
+            new WADISessionManagerConfigInfo(new URI("uri"), 60, 12, 60, false, false),
+            cluster,
+            backingStrategyFactory,
+            serviceHolders) {
+            @Override
+            protected StackContext newStackContext(Dispatcher underlyingDisp, ServiceSpaceName serviceSpaceName) {
+                return new StackContext(cl,
+                    serviceSpaceName,
+                    underlyingDisp,
+                    configInfo.getSessionTimeoutSeconds(),
+                    configInfo.getNumPartitions(),
+                    configInfo.getSweepInterval(),
+                    backingStrategyFactory) {
+                    @Override
+                    public void build() throws ServiceAlreadyRegisteredException {
+                    }
+                    @Override
+                    public ServiceSpace getServiceSpace() {
+                        return BasicWADISessionManagerTest.this.serviceSpace;
+                    };
+                    @Override
+                    public Manager getManager() {
+                        return BasicWADISessionManagerTest.this.wadiManager;
+                    }
+                    @Override
+                    public SessionMonitor getSessionMonitor() {
+                        return BasicWADISessionManagerTest.this.sessionMonitor;
+                    }
+                };
+            }
+        };
+    }
+    
+    public void testBuildStackContextAndStartServiceSpaceUponStart() throws Exception {
+        recordDoStart();
+        
+        startVerification();
+        
+        manager = newManager(Collections.EMPTY_SET);
+        manager.doStart();
+    }
+
+    public void testRegisterServiceHoldersPriorToStart() throws Exception {
+        cluster.getCluster().getDispatcher();
+
+        sessionMonitor.addSessionListener(null);
+        modify().args(is.NOT_NULL);
+        
+        ClusteredServiceHolder serviceHolder = (ClusteredServiceHolder) mock(ClusteredServiceHolder.class);
+        
+        serviceHolder.getService();
+        Object service = new Object();
+        modify().returnValue(service);
+        
+        serviceHolder.getServiceName();
+        ServiceName serviceName = new ServiceName("name");
+        modify().returnValue(serviceName);
+
+        beginSection(s.ordered("Register service then start"));
+
+        ServiceRegistry serviceRegistry = serviceSpace.getServiceRegistry();
+        serviceRegistry.register(serviceName, service);
+        
+        serviceSpace.start();
+        endSection();
+        
+        startVerification();
+        
+        manager = newManager(Collections.singleton(serviceHolder));
+        manager.doStart();
+    }
+
+    public void testCreateSessionOK() throws Exception {
+        recordDoStart();
+        
+        String sessionId = "sessionId";
+        recordCreateSession(sessionId);
+        
+        startVerification();
+        
+        manager = newManager(Collections.EMPTY_SET);
+        manager.doStart();
+        manager.createSession(sessionId);
+    }
+
+    public void testCreateSessionFailsWhenSessionIdAlreadyExists() throws Exception {
+        recordDoStart();
+        
+        String sessionId = "sessionId";
+        wadiManager.createWithName(sessionId);
+        modify().throwException(new SessionAlreadyExistException());
+        
+        startVerification();
+        
+        manager = newManager(Collections.EMPTY_SET);
+        manager.doStart();
+        try {
+            manager.createSession(sessionId);
+            fail();
+        } catch (org.apache.geronimo.clustering.SessionAlreadyExistException e) {
+        }
+    }
+    
+    public void testSessionDestructionCallbackPropagatesToSessionListener() throws Exception {
+        new SessionListenerTestTemplate() {
+            @Override
+            protected void executeSessionListenerCallback(SessionListener sessionListener) {
+                sessionListener.notifySessionDestruction(null);
+            }
+            @Override
+            protected void executeWADISessionListenerCallback(Session wadiSession) {
+                wadiSessionListener.onSessionDestruction(wadiSession);
+            }
+        }.executeTest();
+    }
+    
+    public void testInboundSessionMigrationCallbackPropagatesToSessionListener() throws Exception {
+        new SessionListenerTestTemplate() {
+            @Override
+            protected void executeSessionListenerCallback(SessionListener sessionListener) {
+                sessionListener.notifyInboundSessionMigration(null);
+            }
+            @Override
+            protected void executeWADISessionListenerCallback(Session wadiSession) {
+                wadiSessionListener.onInboundSessionMigration(wadiSession);
+            }
+        }.executeTest();
+    }
+    
+    public void testOutboundSessionMigrationCallbackPropagatesToSessionListener() throws Exception {
+        new SessionListenerTestTemplate() {
+            @Override
+            protected void executeSessionListenerCallback(SessionListener sessionListener) {
+                sessionListener.notifyOutboundSessionMigration(null);
+            }
+            @Override
+            protected void executeWADISessionListenerCallback(Session wadiSession) {
+                wadiSessionListener.onOutbountSessionMigration(wadiSession);
+            }
+        }.executeTest();
+    }
+    
+    public void testServiceSpaceListenerStartedEventPropagatesToSessionManagerListener() throws Exception {
+        new SessionManagerListenerTestTemplate() {
+            @Override
+            protected void executeManagerListenerCallback(SessionManagerListener managerListener) {
+                managerListener.onJoin(null, null);
+            }
+        }.executeTest(LifecycleState.STARTED);
+    }
+    
+    public void testServiceSpaceListenerFailedEventPropagatesToSessionManagerListener() throws Exception {
+        new SessionManagerListenerTestTemplate() {
+            @Override
+            protected void executeManagerListenerCallback(SessionManagerListener managerListener) {
+                managerListener.onLeave(null, null);
+            }
+        }.executeTest(LifecycleState.FAILED);
+    }
+    
+    public void testServiceSpaceListenerStoppedEventPropagatesToSessionManagerListener() throws Exception {
+        new SessionManagerListenerTestTemplate() {
+            @Override
+            protected void executeManagerListenerCallback(SessionManagerListener managerListener) {
+                managerListener.onLeave(null, null);
+            }
+        }.executeTest(LifecycleState.STOPPED);
+    }
+    
+    public void testSessionManagerUnregistration() throws Exception {
+        recordDoStart();
+        
+        SessionManagerListener managerListener = (SessionManagerListener) mock(SessionManagerListener.class);
+        serviceSpace.addServiceSpaceListener(null);
+        modify().args(is.NOT_NULL);
+
+        serviceSpace.removeServiceSpaceListener(null);
+        modify().args(is.NOT_NULL);
+
+        startVerification();
+
+        manager = newManager(Collections.EMPTY_SET);
+        manager.doStart();
+        manager.registerSessionManagerListener(managerListener);
+        manager.unregisterSessionManagerListener(managerListener);
+    }
+    
+    public void testGetRemoteNodes() throws Exception {
+        recordDoStart();
+        
+        NodeService nodeService = (NodeService) mock(NodeService.class);
+        
+        Peer peer = (Peer) mock(Peer.class);
+        peer.getName();
+        modify().returnValue("peer");
+        peer.getLocalStateMap();
+        modify().multiplicity(expect.from(0)).returnValue(new HashMap());
+
+        HashSet<Peer> peers = new HashSet<Peer>();
+        peers.add(peer);
+        serviceSpace.getHostingPeers();
+        modify().returnValue(peers);
+
+        startVerification();
+        RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+        manager = newManager(Collections.EMPTY_SET);
+        manager.doStart();
+        Set<Node> remoteNodes = manager.getRemoteNodes();
+        assertEquals(1, remoteNodes.size());
+        assertTrue(remoteNodes.contains(remoteNode));
+    }
+    
+    protected abstract class SessionManagerListenerTestTemplate {
+        public void executeTest(LifecycleState lifecycleState) throws Exception {
+            recordDoStart();
+            
+            SessionManagerListener managerListener = (SessionManagerListener) mock(SessionManagerListener.class);
+            
+            serviceSpace.addServiceSpaceListener(null);
+            modify().args(new AbstractExpression() {
+                public void describeWith(ExpressionDescriber arg0) throws IOException {
+                }
+                public boolean passes(Object arg0) {
+                    serviceSpaceListener = (ServiceSpaceListener) arg0;
+                    return true;
+                }
+            });
+            
+            NodeService nodeService = (NodeService) mock(NodeService.class);
+            
+            final Peer peer = (Peer) mock(Peer.class);
+            peer.getName();
+            modify().returnValue("peer");
+            peer.getLocalStateMap();
+            modify().multiplicity(expect.from(0)).returnValue(new HashMap());
+
+            HashSet<Peer> peers = new HashSet<Peer>();
+            peers.add(peer);
+            
+            executeManagerListenerCallback(managerListener);
+            modify().args(new AbstractExpression() {
+                public void describeWith(ExpressionDescriber arg0) throws IOException {
+                }
+
+                public boolean passes(Object arg0) {
+                    RemoteNode remoteNode = (RemoteNode) arg0;
+                    assertSame(peer, remoteNode.getPeer());
+                    return true;
+                }
+            }, new AbstractExpression() {
+                public void describeWith(ExpressionDescriber arg0) throws IOException {
+                }
+
+                public boolean passes(Object arg0) {
+                    Set<RemoteNode> remoteNodes = (Set<RemoteNode>) arg0;
+                    assertEquals(1, remoteNodes.size());
+                    RemoteNode remoteNode = remoteNodes.iterator().next();
+                    assertSame(peer, remoteNode.getPeer());
+                    return true;
+                }
+            });
+            
+            startVerification();
+            RemoteNode remoteNode = new RemoteNode(peer, nodeService);
+
+            manager = newManager(Collections.EMPTY_SET);
+            manager.doStart();
+            manager.registerSessionManagerListener(managerListener);
+            serviceSpaceListener.receive(new ServiceSpaceLifecycleEvent(new ServiceSpaceName(new URI("name")),
+                peer,
+                lifecycleState),
+                peers);
+        }
+
+        protected abstract void executeManagerListenerCallback(SessionManagerListener managerListener);
+    }
+    
+    protected abstract class SessionListenerTestTemplate {
+        public void executeTest() throws Exception {
+            recordDoStart();
+            
+            String sessionId = "sessionId";
+            org.codehaus.wadi.core.session.Session wadiSession = recordCreateSession(sessionId);
+            
+            SessionListener sessionListener = (SessionListener) mock(SessionListener.class);
+            executeSessionListenerCallback(sessionListener);
+            modify().args(is.NOT_NULL);
+            
+            startVerification();
+            
+            manager = newManager(Collections.EMPTY_SET);
+            manager.doStart();
+            manager.registerListener(sessionListener);
+            manager.createSession(sessionId);
+            executeWADISessionListenerCallback(wadiSession);
+        }
+        
+        protected abstract void executeWADISessionListenerCallback(Session wadiSession);
+
+        protected abstract void executeSessionListenerCallback(SessionListener sessionListener);
+    }
+
+    private void recordDoStart() throws Exception {
+        cluster.getCluster().getDispatcher();
+        
+        serviceSpace.getServiceRegistry();
+        
+        sessionMonitor.addSessionListener(null);
+        modify().args(new AbstractExpression() {
+            public void describeWith(ExpressionDescriber arg0) throws IOException {
+            }
+
+            public boolean passes(Object arg0) {
+                wadiSessionListener = (org.codehaus.wadi.core.manager.SessionListener) arg0;
+                return true;
+            }
+        });
+        
+        serviceSpace.start();
+    }
+
+    private org.codehaus.wadi.core.session.Session recordCreateSession(String sessionId)
+            throws SessionAlreadyExistException {
+        org.codehaus.wadi.core.session.Session wadiSession = wadiManager.createWithName(sessionId);
+        wadiSession.getLocalStateMap();
+        modify().multiplicity(expect.from(0)).returnValue(new HashMap());
+        return wadiSession;
+    }
+
+}

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/RemoteNodeTest.java Fri Feb 22 17:02:57 2008
@@ -16,6 +16,8 @@
  */
 package org.apache.geronimo.clustering.wadi;
 
+import java.util.HashMap;
+
 import org.codehaus.wadi.group.Peer;
 
 import com.agical.rmock.extension.junit.RMockTestCase;
@@ -35,6 +37,9 @@
         peer = (Peer) mock(Peer.class);
         peer.getName();
         modify().multiplicity(expect.from(0)).returnValue("name");
+        
+        peer.getLocalStateMap();
+        modify().returnValue(new HashMap());
         
         nodeService = (NodeService) mock(NodeService.class);
 

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptorTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptorTest.java?rev=630370&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptorTest.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering-wadi/src/test/java/org/apache/geronimo/clustering/wadi/WADISessionAdaptorTest.java Fri Feb 22 17:02:57 2008
@@ -0,0 +1,135 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering.wadi;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.codehaus.wadi.core.session.Session;
+
+import com.agical.rmock.extension.junit.RMockTestCase;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class WADISessionAdaptorTest extends RMockTestCase {
+
+    private Session session;
+
+    @Override
+    protected void setUp() throws Exception {
+        session = (Session) mock(Session.class);
+        session.getLocalStateMap();
+        modify().multiplicity(expect.from(0)).returnValue(new HashMap());
+    }
+    
+    public void testGetSessionIdDelegation() throws Exception {
+        session.getName();
+        String name = "name";
+        modify().returnValue(name);
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        assertEquals(name, adaptor.getSessionId());
+    }
+    
+    public void testReleaseDelegation() throws Exception {
+        session.destroy();
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        adaptor.release();
+    }
+    
+    public void testReleaseThrowsISEWhenDestroyThrowsException() throws Exception {
+        session.destroy();
+        modify().throwException(new Exception());
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        try {
+            adaptor.release();
+            fail();
+        } catch (IllegalStateException e) {
+        }
+    }
+    
+    public void testAddStateDelegation() throws Exception {
+        String key = "key";
+        String value = "value";
+        session.addState(key, value);
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        adaptor.addState(key, value);
+    }
+    
+    public void testRemoveStateDelegation() throws Exception {
+        String key = "key";
+        session.removeState(key);
+
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        adaptor.removeState(key);        
+    }
+
+    public void testGetStateDelegation() throws Exception {
+        Map state = session.getState();
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        assertSame(state, adaptor.getState());
+    }
+ 
+    public void testOnEndAccessDelegation() throws Exception {
+        session.onEndProcessing();
+        
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        adaptor.onEndAccess();
+    }
+
+    public void testRetrieveAdaptorOK() throws Exception {
+        startVerification();
+        
+        WADISessionAdaptor adaptor = new WADISessionAdaptor(session);
+        assertSame(adaptor, WADISessionAdaptor.retrieveAdaptor(session));
+    }
+    
+    public void testRetrieveThrowsISEIfNoAdaptor() throws Exception {
+        startVerification();
+        
+        try {
+            WADISessionAdaptor.retrieveAdaptor(session);
+            fail();
+        } catch (IllegalStateException e) {
+        }
+    }
+}

Modified: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManager.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManager.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManager.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManager.java Fri Feb 22 17:02:57 2008
@@ -54,6 +54,13 @@
     void unregisterListener(SessionListener listener);    
 
     /**
+     * Gets the Cluster this local SessionManager is associated to.
+     * 
+     * @return Associated Cluster.
+     */
+    Cluster getCluster();
+    
+    /**
      * Gets the Node hosting this local SessionManager.
      * 
      * @return Hosting Node.
@@ -66,4 +73,8 @@
      * @return Hosting Node.
      */
     Set<Node> getRemoteNodes();
+    
+    void registerSessionManagerListener(SessionManagerListener listener);
+    
+    void unregisterSessionManagerListener(SessionManagerListener listener);
 }

Added: geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManagerListener.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManagerListener.java?rev=630370&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManagerListener.java (added)
+++ geronimo/server/trunk/plugins/clustering/geronimo-clustering/src/main/java/org/apache/geronimo/clustering/SessionManagerListener.java Fri Feb 22 17:02:57 2008
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.clustering;
+
+import java.util.Set;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public interface SessionManagerListener {
+    void onJoin(Node joiningNode, Set<Node> newHostingNodes);
+    
+    void onLeave(Node leavingNode, Set<Node> newHostingNodes);
+}

Modified: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationControllerTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationControllerTest.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationControllerTest.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationControllerTest.java Fri Feb 22 17:02:57 2008
@@ -51,14 +51,14 @@
 
         Collection<NodeInfo> nodeInfos = new ArrayList<NodeInfo>();
         
-        nodeInfo = (NodeInfo) mock(NodeInfo.class);
+        nodeInfo = (NodeInfo) mock(NodeInfo.class, "NodeInfo1");
         nodeInfos.add(nodeInfo);
         nodeInfo.getName();
         modify().multiplicity(expect.from(0)).returnValue(nodeName);
         nodeInfo.newKernel();
         modify().multiplicity(expect.from(0));
         
-        NodeInfo secondNodeInfo = (NodeInfo) mock(NodeInfo.class);
+        NodeInfo secondNodeInfo = (NodeInfo) mock(NodeInfo.class, "NodeInfo2");
         nodeInfos.add(secondNodeInfo);
         secondNodeInfo.getName();
         modify().multiplicity(expect.from(0)).returnValue("unkown");

Modified: geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStoreClientTest.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStoreClientTest.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStoreClientTest.java (original)
+++ geronimo/server/trunk/plugins/clustering/geronimo-farm/src/test/java/org/apache/geronimo/farm/deployment/BasicClusterConfigurationStoreClientTest.java Fri Feb 22 17:02:57 2008
@@ -101,7 +101,7 @@
     }
 
     private void setUpNode2Remote(Collection<NodeInfo> nodeInfos) throws IOException {
-        node2Info = (NodeInfo) mock(NodeInfo.class);
+        node2Info = (NodeInfo) mock(NodeInfo.class, "NodeInfo2");
         nodeInfos.add(node2Info);
         node2Kernel = node2Info.newKernel();
         modify().multiplicity(expect.from(0));
@@ -110,7 +110,7 @@
     }
 
     private void setUpNode1Local(Collection<NodeInfo> nodeInfos) throws IOException {
-        node1Info = (NodeInfo) mock(NodeInfo.class);
+        node1Info = (NodeInfo) mock(NodeInfo.class, "NodeInfo1");
         nodeInfos.add(node1Info);
         node1Kernel = node1Info.newKernel();
         modify().multiplicity(expect.from(0));

Modified: geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilderExtension.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilderExtension.java?rev=630370&r1=630369&r2=630370&view=diff
==============================================================================
--- geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilderExtension.java (original)
+++ geronimo/server/trunk/plugins/j2ee/geronimo-j2ee-builder/src/main/java/org/apache/geronimo/j2ee/deployment/ModuleBuilderExtension.java Fri Feb 22 17:02:57 2008
@@ -16,23 +16,21 @@
  */
 package org.apache.geronimo.j2ee.deployment;
 
+import java.net.URL;
+import java.util.Collection;
+import java.util.jar.JarFile;
+
+import org.apache.geronimo.common.DeploymentException;
+import org.apache.geronimo.deployment.ModuleIDBuilder;
+import org.apache.geronimo.gbean.AbstractName;
 import org.apache.geronimo.kernel.Naming;
 import org.apache.geronimo.kernel.config.ConfigurationStore;
 import org.apache.geronimo.kernel.repository.Environment;
-import org.apache.geronimo.deployment.ModuleIDBuilder;
-import org.apache.geronimo.common.DeploymentException;
-import org.apache.geronimo.gbean.AbstractName;
-
-import java.io.File;
-import java.util.jar.JarFile;
-import java.util.Collection;
-import java.net.URL;
 
 /**
  * @version $Rev$ $Date$
  */
 public interface ModuleBuilderExtension {
-
     void createModule(Module module, Object plan, JarFile moduleFile, String targetPath, URL specDDUrl, Environment environment, Object moduleContextInfo, AbstractName earName, Naming naming, ModuleIDBuilder idBuilder) throws DeploymentException;
 
     void installModule(JarFile earFile, EARContext earContext, Module module, Collection configurationStores, ConfigurationStore targetConfigurationStore, Collection repository) throws DeploymentException;
@@ -40,5 +38,4 @@
     void initContext(EARContext earContext, Module module, ClassLoader cl) throws DeploymentException;
 
     void addGBeans(EARContext earContext, Module module, ClassLoader cl, Collection repository) throws DeploymentException;
-
 }

Added: geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/BasicEjbDeploymentGBeanNameBuilder.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/BasicEjbDeploymentGBeanNameBuilder.java?rev=630370&view=auto
==============================================================================
--- geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/BasicEjbDeploymentGBeanNameBuilder.java (added)
+++ geronimo/server/trunk/plugins/openejb/geronimo-openejb-builder/src/main/java/org/apache/geronimo/openejb/deployment/BasicEjbDeploymentGBeanNameBuilder.java Fri Feb 22 17:02:57 2008
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.geronimo.openejb.deployment;
+
+import org.apache.geronimo.gbean.AbstractName;
+import org.apache.geronimo.j2ee.deployment.EARContext;
+import org.apache.geronimo.j2ee.j2eeobjectnames.NameFactory;
+import org.apache.openejb.jee.EnterpriseBean;
+import org.apache.openejb.jee.EntityBean;
+import org.apache.openejb.jee.MessageDrivenBean;
+import org.apache.openejb.jee.SessionBean;
+
+/**
+ *
+ * @version $Rev:$ $Date:$
+ */
+public class BasicEjbDeploymentGBeanNameBuilder implements EjbDeploymentGBeanNameBuilder {
+
+    public AbstractName createEjbName(EARContext earContext, EjbModule ejbModule, EnterpriseBean enterpriseBean) {
+        String ejbName = enterpriseBean.getEjbName();
+        String type = null;
+        if (enterpriseBean instanceof SessionBean) {
+            SessionBean sessionBean = (SessionBean) enterpriseBean;
+            switch (sessionBean.getSessionType()) {
+                case STATELESS:
+                    type = NameFactory.STATELESS_SESSION_BEAN;
+                    break;
+                case STATEFUL:
+                    type = NameFactory.STATEFUL_SESSION_BEAN;
+                    break;
+            }
+        } else if (enterpriseBean instanceof EntityBean) {
+            type = NameFactory.ENTITY_BEAN;
+        } else if (enterpriseBean instanceof MessageDrivenBean) {
+            type = NameFactory.MESSAGE_DRIVEN_BEAN;
+        }
+        if (type == null) {
+            throw new IllegalArgumentException("Unknown enterprise bean type XXX " + enterpriseBean.getClass().getName());
+        }
+        return earContext.getNaming().createChildName(ejbModule.getModuleName(), ejbName, type);
+    }
+    
+}



Mime
View raw message