hello there, this is really urgent, do you know how to convert from a string to AgletProxy ??
i have two classes : Parent.java and Child.java,
The Parent.java class, creates a child , passes it its agletproxy while creating it and dispatches it to another machine :
package examples.help;
import com.ibm.aglet.Aglet;
import com.ibm.aglet.AgletContext;
import com.ibm.aglet.AgletID;
import com.ibm.aglet.AgletProxy;
import java.net.URL;
public class Parent extends Aglet {
private AgletContext context;
private AgletProxy parentProxy;
private AgletID agletID;
@Override
public void run() {
try {
context = getAgletContext();
parentProxy = getProxy();
String agletProxy = parentProxy.toString();
System.out.println("The Parent Proxy is : " + parentProxy.toString());
try {
AgletProxy childProxy = context.createAglet(getCodeBase(), "examples.help.Child", agletProxy);
childProxy.dispatch(new URL("atp://localhost:2000"));
} catch (Exception e) {
System.out.println(e.toString());
}
}
catch(Exception ex)
{
ex.printStackTrace();
System.out.println("Exception!!!!");
}
}
}
...
The Child.java class, uses Parent's agletproxy sent to it via the creation method , to sends back a message to the parent
package examples.help;
import com.ibm.aglet.Aglet;
import com.ibm.aglet.event.MobilityAdapter;
import com.ibm.aglet.event.MobilityEvent;
public class Child extends Aglet {
private String parentProxy;
@Override
public void onCreation(Object init) {
parentProxy = (String)init;
addMobilityListener( new MobilityAdapter(){
@Override
public void onArrival(MobilityEvent me) {
System.out.println("ParentProxy : " +parentProxy);
aHomeProxy = (AgletProxy) parentProxy;
aHomeProxy.sendOnewayMessage(new Message("I have arrived safely",remoteContext.getAgletProxy(id)));
}
});
}
but the probem is with the 2 green lines above, how can i convert the parent proxy back to an AgletProxy so the child can use it to send a message to the parent ? im getting an error "incompatible type" when im converting the string to AgletProxy => (aHomeProxy = (AgletProxy) parentProxy; )
please if you know the answer, plz reply ! thank you :))