[prev in list] [next in list] [prev in thread] [next in thread]
List: openejb-cvs
Subject: [openejb-scm] openejb/modules/core/src/java/org/openejb/client/naming RemoteEJBAddr.java RemoteEJBOb
From: gdamour () codehaus ! org
Date: 2005-12-21 14:21:50
Message-ID: 20051221142150.17008.qmail () codehaus ! org
[Download RAW message or body]
gdamour 2005/12/21 09:21:50
Modified: modules/core/src/java/org/openejb/client/naming
RemoteEJBObjectFactory.java RemoteEJBRefAddr.java
Added: modules/core/src/java/org/openejb/client/naming
RemoteEJBAddr.java
Log:
GERONIMO-1397 Clustering of SFSB
First step of many others to add the clustering of SFSB.
This check-in adds the following features:
* definition of an EJBClusterManager, which abstracts an EJB Cluster node;
* this EJB cluster node is a standard GBean (the default or
WADI implementation is DefaultEJBClusterManager);
* in an openejb-jar.xml DD, a SFSB can declare a reference to this node via
the ejb-cluster-reference element;
* when the SFSB container is started, the EJB cluster node notifies
the cluster that it is running a specific SFSB container;
* when a clustered SFSB InstanceContext is created, an array of nodes running
the container of this SFSB is associated to the InstanceContext. Note that
this array of nodes is updated upon start-up of a clustered SFSB container or
upon node failure;
* this array of nodes capable of running the created SFSB is propagated to
clients. Actually, this array is propagated at each EJB invocation.
Revision Changes Path
1.3 +29 -11 \
openejb/modules/core/src/java/org/openejb/client/naming/RemoteEJBObjectFactory.java
Index: RemoteEJBObjectFactory.java
===================================================================
RCS file: /home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/client/naming/RemoteEJBObjectFactory.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RemoteEJBObjectFactory.java 8 Dec 2005 04:43:40 -0000 1.2
+++ RemoteEJBObjectFactory.java 21 Dec 2005 14:21:50 -0000 1.3
@@ -65,7 +65,9 @@
import org.openejb.client.EJBMetaDataImpl;
import org.openejb.client.JNDIRequest;
import org.openejb.client.JNDIResponse;
+import org.openejb.client.RequestInfo;
import org.openejb.client.ResponseCodes;
+import org.openejb.client.ResponseInfo;
import org.openejb.client.ServerMetaData;
/**
@@ -98,28 +100,44 @@
return null;
}
Reference ref = (Reference) obj;
- RefAddr addr = ref.get(0);
- if (!(addr instanceof RemoteEJBRefAddr)) {
- throw new IllegalStateException("Reference address must be a \
RemoteEJBRefAddr: " + addr); +
+ if (0 == ref.size()) {
+ throw new IllegalStateException("No defined RemoteEJBRefAddr");
+ }
+
+ String containerId = null;
+ ServerMetaData[] servers = new ServerMetaData[ref.size() + 1];
+ for (int i = 0; i < servers.length - 1; i++) {
+ RefAddr addr = ref.get(i);
+ if (!(addr instanceof RemoteEJBRefAddr)) {
+ throw new IllegalStateException("Reference address must be a \
RemoteEJBRefAddr: " + addr); + }
+ RemoteEJBAddr ejbAddr = (RemoteEJBAddr) addr.getContent();
+ servers[i] = ejbAddr.getServer();
+ if (null == containerId) {
+ containerId = ejbAddr.getContainerId();
+ } else if (false == containerId.equals(ejbAddr.getContainerId())) {
+ throw new IllegalStateException("Distinct containerId");
+ }
}
+ servers[servers.length - 1] = new ServerMetaData("BOOT", \
RemoteEJBObjectFactory.IP, RemoteEJBObjectFactory.PORT);
- String containerId = (String) addr.getContent();
JNDIRequest req = new JNDIRequest(JNDIRequest.JNDI_LOOKUP, containerId);
- JNDIResponse res = null;
- ServerMetaData server;
+ ResponseInfo resInfo = new ResponseInfo(new JNDIResponse());
try{
- server = new ServerMetaData(RemoteEJBObjectFactory.IP, \
RemoteEJBObjectFactory.PORT);
- res = (JNDIResponse) Client.request(req, new JNDIResponse(), server);
+ Client.request(new RequestInfo(req, servers), resInfo);
} catch (Exception e){
throw (NamingException)new NamingException("Cannot lookup " + \
containerId).initCause(e); }
-
+
+ JNDIResponse res = (JNDIResponse) resInfo.getResponse();
switch ( res.getResponseCode() ) {
case ResponseCodes.JNDI_EJBHOME:
// Construct a new handler and proxy.
EJBMetaDataImpl ejb = (EJBMetaDataImpl)res.getResult();
- EJBHomeHandler handler = EJBHomeHandler.createEJBHomeHandler(ejb, \
server); + ServerMetaData[] newServers = resInfo.getServers();
+ EJBHomeHandler handler = EJBHomeHandler.createEJBHomeHandler(ejb, \
newServers); EJBHomeProxy proxy = handler.createEJBHomeProxy();
ejb.setEJBHomeProxy(proxy);
return proxy;
1.2 +5 -5 \
openejb/modules/core/src/java/org/openejb/client/naming/RemoteEJBRefAddr.java
Index: RemoteEJBRefAddr.java
===================================================================
RCS file: /home/projects/openejb/scm/openejb/modules/core/src/java/org/openejb/client/naming/RemoteEJBRefAddr.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- RemoteEJBRefAddr.java 29 Sep 2004 19:35:59 -0000 1.1
+++ RemoteEJBRefAddr.java 21 Dec 2005 14:21:50 -0000 1.2
@@ -54,14 +54,14 @@
*/
public class RemoteEJBRefAddr extends RefAddr {
private final static String TYPE = RemoteEJBRefAddr.class.getName();
- private final String containerId;
+ private final RemoteEJBAddr addr;
- public RemoteEJBRefAddr(String containerId) {
+ public RemoteEJBRefAddr(RemoteEJBAddr addr) {
super(TYPE);
- this.containerId = containerId;
+ this.addr = addr;
}
public Object getContent() {
- return containerId;
+ return addr;
}
}
1.1 \
openejb/modules/core/src/java/org/openejb/client/naming/RemoteEJBAddr.java
Index: RemoteEJBAddr.java
===================================================================
/**
* Redistribution and use of this software and associated documentation
* ("Software"), with or without modification, are permitted provided
* that the following conditions are met:
*
* 1. Redistributions of source code must retain copyright
* statements and notices. Redistributions must also contain a
* copy of this document.
*
* 2. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. The name "OpenEJB" must not be used to endorse or promote
* products derived from this Software without prior written
* permission of The OpenEJB Group. For written permission,
* please contact info@openejb.org.
*
* 4. Products derived from this Software may not be called "OpenEJB"
* nor may "OpenEJB" appear in their names without prior written
* permission of The OpenEJB Group. OpenEJB is a registered
* trademark of The OpenEJB Group.
*
* 5. Due credit should be given to the OpenEJB Project
* (http://openejb.org/).
*
* THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
* NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
*
* $Id: RemoteEJBAddr.java,v 1.1 2005/12/21 14:21:50 gdamour Exp $
*/
package org.openejb.client.naming;
import java.io.Serializable;
import org.openejb.client.ServerMetaData;
/**
*
*/
public class RemoteEJBAddr implements Serializable {
private final ServerMetaData server;
private final String containerId;
public RemoteEJBAddr(ServerMetaData server, String containerId) {
this.server = server;
this.containerId = containerId;
}
public String getContainerId() {
return containerId;
}
public ServerMetaData getServer() {
return server;
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic