I have found that although Aglets were listed in
the "finder_viewer" confirming that they were
registered, a call to getAgletProxy( agletId ) always
results in an EntryNotFound exception, whenever the
Aglet being looked is in another context. I finally
tracked down the cause of the problem today, I could
be wrong but it seems to be a bug in the Aglets source
code. I'm using Aglets 1.2 (from Kovey's page) and JDK
1.3 for the development. Here's what seems to be the
bug.
the createAglet() from
com.ibm.aglets.AgletContextImpl...
public AgletProxy createAglet(URL url, String
classname, Object init)
throws IOException,
AgletException, ClassNotFoundException,
InstantiationException {
Certificate owner =
AgletRuntime.getCurrentCertificate();
return createAglet(url, classname,
owner, init);
}
the last call to another createAglet method uses the
certificate later on as follows
...
LocalAgletRef ref = new
LocalAgletRef(this, _secure);
ref.setName
(AgletRuntime.newName(owner));
...
...
The finder0 seems to be called everytime an event
occurs (creation, cloning, disposal etc..)
in this method the following is done for creation,
cloning and arrival
...
finder.register_agent(ref.getName(),
_hostingURL.toString(),
MAF.toAgentProfile
(ref.info));
...
So the certificate is used to create a Name object
(com.ibm.maf.Name), and this Name object is used when
registering the newly created Aglet with the Finder.
Name class has the following instance variables.
...
public byte[] authority;
public byte[] identity;
public short agent_system_type
...
However in the getAgletProxy(AgletID) code, when the
aglet isn't found in the local context the finder is
used, by the following code:
...
public AgletProxy getAgletProxy(AgletID aid) {
AgletProxy p = (AgletProxy)_agletProxies.get
(aid);
if (p != null) {
return p;
}
try {
MAFFinder finder =
MAFAgentSystem.getLocalMAFAgentSystem
().get_MAFFinder();
if (finder != null) {
String[] locations =
------> finder.lookup_agent(MAFUtil.toName
(aid, null), null);
p = getAgletProxy(new URL
(locations[0]), aid);
}
....
The line noted is where a Name object is created by
MAFUtil.toName() and used for the lookup_agent() call.
However the second parameter to MAFUtil.toName() is a
certificate and null is supplied, so the Name object
created has an empty authority field. So the
finder.lookup_agent() call will never find a matching
Name object for calls to getAgletProxy( id) where id
is that of a remote Aglet will never work, as all
fields of the Name object are checked in it's equals()
method.