Jinterface question
Gordon Beaton
gordon.beaton@REDACTED
Wed Feb 23 12:55:13 CET 2000
On 23 Feb 2000 10:14:00 GMT, Per Bohlin wrote:
> > I also have a question about the functionallity of JInterface.
> > At first I thought that it provided the same functionallity to JAVA
> > that you get to C when using erl_interface.
> > I've used erl_interface a bit in a User Interface tool where
> > C++ objects are represented with Erlang PID's.
> > When receiving messages from erlang a dictionary is used to keep
> > track of which object to transfer the message to based on the pid
> > that the message is sent to. So effectivly the erlang side can send
> > messages to C++ objects (represening windows) as if they where Erlang
> > processes.
> >
> > In JInterface it is possible to create Erlang PIDs on the java side.
> > But, I have not found any way of getting the PID that the Erlang message
> > was sent to. The messages just ends up in the OtpConnection.receive
> > without reference to the PID that the message was sent to.
> >
> > Is there a way to find the PID that the message was sent to?
> > (And possibly also the PID of the process that the message was sent
> > from, I don't need it but it is there in erl_interface)
This was a design decision. I thought about returning the received
message inside another object along with the header information, but
one of the goals with Jinterface was to provide something that was a
lot easier to use than erl-interface and in particular had a lower
learning threshold.
For example, all outgoing messages appear to come from the same Erlang
Pid, you don't need to make them up in order to send messages to
Erlang. By the same token, you don't get to find out what Pid messages
were sent to. It's possible that this decision should be reevaluated.
If you need to dispatch incoming messages to different receivers you
can still do it quite easily by including the intended recipient in
the body of the message: { pid, msg } or similar. The recipient
doesn't even need to be a pid in this case, for example if you use an
integer then you can switch on it.
/gordon
--
g o r d o n . b e a t o n @ e r i c s s o n . c o m
please no spam, chain letters or virtual postcards!
More information about the erlang-questions
mailing list