Hi
I want to build an
EJB that solves equations.
For this, the client sends to the ejb component the rmi adress of a class that implements the equation logic.
My problem is that if the client and the ejb server are on different machines the server needs to have the stub class in the CLASSPATH. This is inconvenient for the client because he has to upload the stub on the server every time he wants to solve a new equation.
Is there a way that the client can call the EJB without uploading on the server the stub class ? I tryied serialization but it did not work out.
I have defined the following interface:
public interface Function extends java.rmi.Remote {
public float getX(float x);
}
An implementation of this interface is this:
public class ClientFunction extends UnicastRemoteObject implements Function {
private Registry reg = null;
private
String name = null;
public ClientFunction (Registry reg, String name) throws Exception {
super ();
this.reg = reg;
this.name = name;
reg.rebind (name, this);
}
public float getX(float x) {
return x*x;
}
public void unbind () throws Exception {
reg.unbind (name);
}
}
The ejb component create method has the following code:
public void ejbCreate(String lookupString) throws CreateException,ODEException {
try {
f= (Function) Naming.lookup(lookupString);
} catch (Exception e)
{
e.printStackTrace();
throw new ODEException("Can't find "+lookupString);
}
}
I thank big to the one that helps me with this
Cristi