[E-Lang] Remote Object E Question
Marc Stiegler
marcs@skyhunter.com
Sun, 26 Aug 2001 08:44:23 -0700
> A.) Have these java processes (agents) essentially invoke a method on a
> remote object (from a collection of objects at another agent) via E.
The
> question here is then how do I/ can I bind an object from the runtime to
> the E script interpretation? I found documentation on what seems like
> java object creation and invocation - using "E call..." - but in my case
I
> want to take a "live" object, import it into my E session, obtain a URI
and
> offer it up for access by others via E.
>
> B.) the other question is this: presuming I can bind a live object to my
E
> session, is there any way that I can "wrap" it in E? So for example, I
> may want to hide it behind a "transparent forwarder" (per example given at
> bottom of http://www.skyhunter.com/marcs/ewalnut.html#SEC14) so that the
> owning process may choose to revoke its capabilities should it choose?
I would use the second question to answer the first: Yes, you can "wrap" a
Java object with E; then by using the sturdy ref on the wrapper you make a
uri that you can distribute to the rest of your world. The most interesting
such wrapper I have done was for a DBMS: I needed a DBMS for a distributed E
application, so I took an open source Java DBMS class library (InstantDB),
which was designed just to support a single thread on single jvm, wrapped it
in an E object, and handed the uri for that E object to the other objects in
my system.
The not-yet-published next release of E in a Walnut has a much improved
pattern for revocation using forwarders. Putting it all together into a
chunk of code you can pretty much use straight off (but I haven't run this
piece of email through E, so it probably contains a syntax error and a
runtime error somewhere),
class revokerCapabilityPairMaker new(baseCapableObject) :near {
var capableObject := baseCapableObject
def revoker {
to revoke() {capableObject == null}
}
def forwarder {delegate {capableObject}}
[revoker,forwarder]
}
def [agentRevoker,agentForwarder] := revokerCapabilityPairMaker new(agent)
def agentURI := introducer sturdyToURI(sturdyRef(agentForwarder))
#......some other program
def agentRcvr := introducer sturdyFromURI(agentURI) promiseRef()
Depending on which version of E you are using, in the last line you may be
using either promiseRef() or liveRef(), since the name has changed....and
the name will change again before we finalize the terminology for the next
release of Walnut, which will be documenting the next release of E (I think
it will go back to being "liveRef", though I am uncertain). The suffix
"Rcvr" is the current candidate convention for saying, "I am warning you,
you need to treat this object as a remote reference, and communicate to it
only with eventual sends, not immediate calls". The term "receiver" refers
to "someone to whom you can only send, not call".
--marcs