ok, just created a simple app deployed on 2 machines:
Mac OS machine (GF 3.1 nightly)
Servlet3 + FooBean + FooIF + BarIF, packaged as web3.war
SunOS machine (GF 3.0.1)
BarBean + BarIF, packged as BarBean.jar
Servlet3 calls the colocated FooBean, and the remote BarBean, both beans prints out its os.name, as a way to tell where it is:
/Users/cf126330/workspace/web3 > curl
http://localhost:8080/web3/Servlet3
foo.hello returned: Hello, test.Servlet3 from Mac OS X
bar.hello returned: Hello, test.Servlet3 from SunOS
The ejb interfaces and bean classes contain no location info, the same as if running in the same machine. The servlet class @EJB has the mappedName using corbaname to point to the remote machine. That's the only place that specifies a location.
package test;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(loadOnStartup=1, urlPatterns={"/Servlet3"})
public class Servlet3 extends HttpServlet {
@EJB
private FooIF foo;
@EJB(mappedName="corbaname:iiop:1.2_at_gf.sun.com:3700#test.BarIF")
private BarIF bar;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
PrintWriter writer = response.getWriter();
writer.println("foo.hello returned: " + foo.hello(getServletName()));
writer.println("bar.hello returned: " + bar.hello(getServletName()));
}
}
------------------
package test;
public interface FooIF {
public String hello(String name);
}
-----------------
package test;
import javax.ejb.Remote;
import javax.ejb.Stateful;
@Stateful
@Remote(FooIF.class)
public class FooBean {
public String hello(String name) {
return "Hello, " + name + " from " + System.getProperty("os.name");
}
}
-----------------
package test;
public interface BarIF {
public String hello(String name);
}
-----------------
package test;
import javax.ejb.Remote;
import javax.ejb.Stateless;
@Stateless
@Remote(BarIF.class)
public class BarBean {
public String hello(String name) {
return "Hello, " + name + " from " + System.getProperty("os.name");
}
}
-----------------
/Users/cf126330/workspace/web3 > jar tf web3.war
WEB-INF/classes/test/BarIF.class
WEB-INF/classes/test/FooBean.class
WEB-INF/classes/test/FooIF.class
WEB-INF/classes/test/Servlet3.class
/Users/cf126330/workspace/web3 > jar tf BarBean.jar
test/BarBean.class
test/BarIF.class
[Message sent by forum member 'cf126330']
http://forums.java.net/jive/thread.jspa?messageID=476677