Next: Conclusion and Future Work
Up: Creating a System Agent
Previous: SysAgentHelper
  Contents
To prevent direct access to the System Agent it has to publish its methods for
accessing the resources through the use of a proxy.
The first step to take for creating a proxy is to define an interface used for
the Agents and other parts of the System to access the resource. This interface
will be used by the user of the service to look for it. When the interface is
created, the next step is to implement this interface in the proxy. The proxy
has also to implement the
ProxyIFace which contains the clone
methods. As described in
![[*]](/usr/share/latex2html/icons/crossref.png)
the proxy will be cloned
by the System before given to the requester. For example has the class definition
of the
MAFFinderProxy the following content:
public class MAFFinderProxy implements MAFFinderIFace, ProxyIFace
The proxy needs some variables, the service behind it and the ID of the Agent
when cloned. The reference to the service can be addressed by the interface
used for the proxy, which should also be implemented by the System Agent behind.
The AgentID is null for the primary proxy and contains
the ID of the Agent which requested the proxy when cloned. To prevent the proxy
to be clone again by the Agent it uses a boolean variable which indicates if
the proxy is a clone and may not be cloned again. This leads to the following
variable definitions in the MAFFinderProxy:
-
- /** The service to use. */
private MAFFinderIFace service = null;
/** The AgentID of the Agent using this Proxy. */
private AgentID agentid = null;
/** Is true if this proxy is a clone. */
boolean isClone = false;
When created (constructed) the proxy needs the reference to the service as parameter
for the constructor. The MAFFinderProxy has the following
main constructor:
-
- public MAFFinderProxy(MAFFinderIFace service) {
this.service = service;
}
For the ProxyIFace it has to implement two methods, clone
and isClone. The method clone is called by the platform when a request
for that proxy came in and the proxy has to be cloned for the caller. It should
return an object that implements also the ProxyIFace. In fact
it should return a new instance of the same proxy with some different variables.
The clone method gets the AgentID as parameter to
know for which Agent to make the clone and which Agent the clone uses. For cloning
it should use the following mechanism (it is free to use another, but this is
recommended). The proxy contains a private constructor which gets the AgentID
and the service reference as parameter. It is private so it can only be called
from inside of the proxy. The constructor sets the isClone variable
to true, preventing a new cloning. It has now the AgentID
to make security calls when a method of the proxy is called. The constructor
of the MAFFinderProxy looks like this:
-
- private MAFFinderProxy(MAFFinderIFace service, AgentID agentid) {
this.service = service;
this.agentid = agentid;
isClone = true;
}
And the method to clone and to check if it is a clone are in the following way
implemented:
-
- public ProxyIFace clone(AgentID agentid) {
if(!isClone)
return new MAFFinderProxy(service, agentid);
else
return null;
}
public boolean isClone() {
return isClone;
}
These methods can be taken over by any proxy without big changes making the
creation of a proxy as easy as possible.
Next: Conclusion and Future Work
Up: Creating a System Agent
Previous: SysAgentHelper
  Contents
Thomas Letsch
2001-02-21