comp.lang.ada
 help / color / mirror / Atom feed
* Setting up a Java Callback to Ada
@ 2002-01-18 18:11 Kevin Brugh
  2002-01-19 19:38 ` Marc A. Criley
  0 siblings, 1 reply; 10+ messages in thread
From: Kevin Brugh @ 2002-01-18 18:11 UTC (permalink / raw)


I need to create some Ada code that will call Java code to set up a
callback.  I need the Java side to save the Callback procedure I sent
it. When a event is triggered, specifically an OnMessage call from
Weblogic. The OnMessage method in my java code will use that saved
Callback Procedure and call my Ada procedure.  Any suggestions??

Kevin



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-18 18:11 Setting up a Java Callback to Ada Kevin Brugh
@ 2002-01-19 19:38 ` Marc A. Criley
  2002-01-21  6:08   ` Kevin Brugh
  0 siblings, 1 reply; 10+ messages in thread
From: Marc A. Criley @ 2002-01-19 19:38 UTC (permalink / raw)


Kevin Brugh wrote:
> 
> I need to create some Ada code that will call Java code to set up a
> callback.  I need the Java side to save the Callback procedure I sent
> it. When a event is triggered, specifically an OnMessage call from
> Weblogic. The OnMessage method in my java code will use that saved
> Callback Procedure and call my Ada procedure.  Any suggestions??

Are you talking about invoking a native method written in Ada?

Or can the Ada be compiled by JGNAT into JBC, which means it can be
treated pretty much like any other Java method?  (See the JGNAT docs for
info on invoking Java from Ada and vice versa.)

Marc A. Criley
Consultant
Quadrus Corporation
www.quadruscorp.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-19 19:38 ` Marc A. Criley
@ 2002-01-21  6:08   ` Kevin Brugh
  2002-01-21  6:49     ` Jim Rogers
  0 siblings, 1 reply; 10+ messages in thread
From: Kevin Brugh @ 2002-01-21  6:08 UTC (permalink / raw)


Yes, a JNI.  I have Aonix 95 that uses JNI to interface with Java
code.  But, since Ada doesn't have Objects/Method like Java.  Ada
cannot handle Java interfaces, which Weblogic and many other Java
Classes use a lot of.  I figured if I could pass the access of the
procedure to Java and it would save it, then when my method was
invoked/notified I could use that call back procedure.  It would be
nice if Java could call a Ada procedure that would call my callback
procedure directly. I have looked at using a C/C++ wrapper for Java,
but I would like something more simpler and direct.

"Marc A. Criley" <mcqada95@earthlink.net> wrote in message news:<3C49BE2C.F114478D@earthlink.net>...
> Kevin Brugh wrote:
> > 
> > I need to create some Ada code that will call Java code to set up a
> > callback.  I need the Java side to save the Callback procedure I sent
> > it. When a event is triggered, specifically an OnMessage call from
> > Weblogic. The OnMessage method in my java code will use that saved
> > Callback Procedure and call my Ada procedure.  Any suggestions??
> 
> Are you talking about invoking a native method written in Ada?
> 
> Or can the Ada be compiled by JGNAT into JBC, which means it can be
> treated pretty much like any other Java method?  (See the JGNAT docs for
> info on invoking Java from Ada and vice versa.)
> 
> Marc A. Criley
> Consultant
> Quadrus Corporation
> www.quadruscorp.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-21  6:08   ` Kevin Brugh
@ 2002-01-21  6:49     ` Jim Rogers
  2002-01-21  9:54       ` Hyman Rosen
  2002-01-21 12:50       ` Marc A. Criley
  0 siblings, 2 replies; 10+ messages in thread
From: Jim Rogers @ 2002-01-21  6:49 UTC (permalink / raw)


Kevin Brugh wrote:

> Yes, a JNI.  I have Aonix 95 that uses JNI to interface with Java
> code.  But, since Ada doesn't have Objects/Method like Java.  Ada
> cannot handle Java interfaces, which Weblogic and many other Java
> Classes use a lot of.  I figured if I could pass the access of the
> procedure to Java and it would save it, then when my method was
> invoked/notified I could use that call back procedure.  It would be
> nice if Java could call a Ada procedure that would call my callback
> procedure directly. I have looked at using a C/C++ wrapper for Java,
> but I would like something more simpler and direct.
> 

The real difficulty is on the Java side. Sun claims that JNI should be
able to work with a wide variety of languages. Currently JNI works only
with C. This means that your Ada dlls or shared libraries must look like
C. It also means that you are responsible for handling any and all
data compatibility issues between Ada and Java. Part of the JNI model
is that Java has no knowledge of other programming languages. All other
languages must support Java data types for JNI to work.

Note that the JNI model of software development ALWAYS starts with Java.
First you define your class containing remote methods. Then you create a
C header file from those methods using the javah tool. You implement the
corresponding C functions. You also implement the Java code to call the
remote methods. The C functions must handle all compatibility issues.

If you want Java to call an Ada subprogram you must build a C wrapper
that Java actually calls. That wrapper will handle all data
compatiblity issues and call the Ada subprogram. Trying to use JNI to
communicate between Java and Ada means programming in three languages.

Jim Rogers
Colorado Springs, Colorado USA




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-21  6:49     ` Jim Rogers
@ 2002-01-21  9:54       ` Hyman Rosen
  2002-01-21 22:40         ` David Kirk
  2002-01-21 12:50       ` Marc A. Criley
  1 sibling, 1 reply; 10+ messages in thread
From: Hyman Rosen @ 2002-01-21  9:54 UTC (permalink / raw)


Jim Rogers wrote:

> Note that the JNI model of software development ALWAYS starts with Java.


That's not true. There's a way to start off in C (and therefore in Ada).




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-21  6:49     ` Jim Rogers
  2002-01-21  9:54       ` Hyman Rosen
@ 2002-01-21 12:50       ` Marc A. Criley
  2002-01-22 18:35         ` Stephen Leake
  1 sibling, 1 reply; 10+ messages in thread
From: Marc A. Criley @ 2002-01-21 12:50 UTC (permalink / raw)


Jim Rogers wrote:
> 
> Note that the JNI model of software development ALWAYS starts with Java.
> First you define your class containing remote methods. Then you create a
> C header file from those methods using the javah tool. You implement the
> corresponding C functions. You also implement the Java code to call the
> remote methods. The C functions must handle all compatibility issues.
> 
> If you want Java to call an Ada subprogram you must build a C wrapper
> that Java actually calls. That wrapper will handle all data
> compatiblity issues and call the Ada subprogram. Trying to use JNI to
> communicate between Java and Ada means programming in three languages.
> 

Jim is correct here.  As an exercise a couple years ago I did in fact
have Java call an Ada subprogram via JNI.  It worked, but I had to have
the C wrapper, and also additional (native) C functions to call adainit
and adafinal.

Marc A. Criley
Consultant
Quadrus Corporation
www.quadruscorp.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-21  9:54       ` Hyman Rosen
@ 2002-01-21 22:40         ` David Kirk
  0 siblings, 0 replies; 10+ messages in thread
From: David Kirk @ 2002-01-21 22:40 UTC (permalink / raw)


On Mon, 21 Jan 2002 09:54:09 GMT, Hyman Rosen <hyrosen@mail.com>
wrote:

>Jim Rogers wrote:
>
>> Note that the JNI model of software development ALWAYS starts with Java.
>
>
>That's not true. There's a way to start off in C (and therefore in Ada).
>

or any language. I occasionaly use Delphi to instantiate and control
the jvm. From what I remember the datatypes are less important than
the size of the data being passed, so anything can be used (well not
VB as far as I know, but that doesn't count)

I vaguely remember seeing an ada JNI binding somewhere on the net.
Can't remember where and haven't tried it. Google came up with it when
I was looking for something else.

Hope it is some use



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-21 12:50       ` Marc A. Criley
@ 2002-01-22 18:35         ` Stephen Leake
  2002-01-23 21:04           ` richtmp
  0 siblings, 1 reply; 10+ messages in thread
From: Stephen Leake @ 2002-01-22 18:35 UTC (permalink / raw)


"Marc A. Criley" <mcqada95@earthlink.net> writes:

> Jim Rogers wrote:
> > 
> > Note that the JNI model of software development ALWAYS starts with Java.
> > First you define your class containing remote methods. Then you create a
> > C header file from those methods using the javah tool. You implement the
> > corresponding C functions. You also implement the Java code to call the
> > remote methods. The C functions must handle all compatibility issues.
> > 
> > If you want Java to call an Ada subprogram you must build a C wrapper
> > that Java actually calls. That wrapper will handle all data
> > compatiblity issues and call the Ada subprogram. Trying to use JNI to
> > communicate between Java and Ada means programming in three languages.
> > 
> 
> Jim is correct here.  As an exercise a couple years ago I did in fact
> have Java call an Ada subprogram via JNI.  It worked, but I had to have
> the C wrapper, and also additional (native) C functions to call adainit
> and adafinal.

But you can export Ada fuctions with convention C, and call adainit
and adafinal from an Ada subprogram; just don't assume adainit has been
called yet in that subprogram!. That's sort of writing in Ada :).

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-22 18:35         ` Stephen Leake
@ 2002-01-23 21:04           ` richtmp
  2002-01-25 12:53             ` Marc A. Criley
  0 siblings, 1 reply; 10+ messages in thread
From: richtmp @ 2002-01-23 21:04 UTC (permalink / raw)


If somebody would send out an example of Java and Ada together,
it would be greatly appreciated.

Thanks,
Peter


Stephen Leake wrote:

> "Marc A. Criley" <mcqada95@earthlink.net> writes:
>
> > Jim Rogers wrote:
> > >
> << snip >>
> > >
> >
> > Jim is correct here.  As an exercise a couple years ago I did in fact
> > have Java call an Ada subprogram via JNI.  It worked, but I had to have
> > the C wrapper, and also additional (native) C functions to call adainit
> > and adafinal.
>
> But you can export Ada fuctions with convention C, and call adainit
> and adafinal from an Ada subprogram; just don't assume adainit has been
> called yet in that subprogram!. That's sort of writing in Ada :).
>
> --
> -- Stephe




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Setting up a Java Callback to Ada
  2002-01-23 21:04           ` richtmp
@ 2002-01-25 12:53             ` Marc A. Criley
  0 siblings, 0 replies; 10+ messages in thread
From: Marc A. Criley @ 2002-01-25 12:53 UTC (permalink / raw)


richtmp wrote:
> 
> If somebody would send out an example of Java and Ada together,
> it would be greatly appreciated.

I have a package, JAWS.Sockets, that is an analog of Samuel Tardieu's
AdaSockets package.  It is designed for compilation by JGNAT and
interacts with the JDK's networking/socket classes--and works just fine!
:-)

It's a bit longish for posting, but I'll be happy to e-mail it to any
interested parties.

Marc A. Criley
Consultant
Quadrus Corporation
www.quadruscorp.com



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2002-01-25 12:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-18 18:11 Setting up a Java Callback to Ada Kevin Brugh
2002-01-19 19:38 ` Marc A. Criley
2002-01-21  6:08   ` Kevin Brugh
2002-01-21  6:49     ` Jim Rogers
2002-01-21  9:54       ` Hyman Rosen
2002-01-21 22:40         ` David Kirk
2002-01-21 12:50       ` Marc A. Criley
2002-01-22 18:35         ` Stephen Leake
2002-01-23 21:04           ` richtmp
2002-01-25 12:53             ` Marc A. Criley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox