Raymond Feng wrote:
Hi, Simon.

Please see my comments inline.

Thanks,
Raymond
--------------------------------------------------
From: "Simon Laws" <[EMAIL PROTECTED]>
Sent: Friday, June 27, 2008 5:15 AM
To: <[email protected]>
Subject: Re: AW: Apache Tuscany doubts

Hi Raymond

Nice idea. Comments in line...

If we did want to fully support C++ classes as SCA components, i.e. with
references and all the trimings then we could look to use the native runtime
in the same domain, as opposed to in the same VM. Embedding it might be
tricky.

Yes. There are two SCA runtimes in Tuscany, one is implemented in Java and the other in C++. But it should also be possible for the Java runtime to host C/C++ components and vice versa.


Simon

On Thu, Jun 26, 2008 at 7:16 PM, Raymond Feng <[EMAIL PROTECTED]> wrote:

Hi,

Can you describe the use cases you have in mind? It will help us better
understand what you want to achieve.

Are you interested in contributing in this area? I can give some pointers and thoughts to get you started. The following is based on my on-the-surface
thoughts.

For example, you have a C/C++ DLL which provides some business functions
and you want to use them to implement SCA components.

As the first step, you can even use implementation.java to call JNI and you
just have to write an implementation class like:

@Service(Calculator.class)
public class JNICalculatorImpl implements Calculator {
  static {
      System.loadLibrary("calculator.dll");
  }
  public native int method calculate(String op, int n1, int n2);

  @Reference
  public Add addService;
}

And configure the component as:

<component name="JNICalculatorComponent">
  <implementation.java class="calculator.dll"/>
</component>


Did you mean ...

<implementation.java class="JNICalculatorImpl "/>


Yes, that's what I meant. Thank you for correcting it.



For the second step, we can try to automate the JNI access as follows:

1) Model the component as implementation.jni:

<component name="JNICalculatorComponent">
  <implementation.jni library="calculator.dll"/>
</component>

You also need to provide a componentType file to describe the JNI
operations (Potentially we can introspect the native C++ interface).

<componentType>
  <service name="Calculator">
<interface.java interface="calculator.Calculator"/> <!-- This is the
java interface for the JNI functions -->
  </service>
  <reference name="Add">
      <interface.java interface="calculator.Add"/> <!-- This is the java
interface for the JNI functions -->
  </service>
</componentType>

Then we can generate the JNICalculatorImpl class as illustrated above to
represent the JNI component using ASM.


This looks like a promising and straightforward idea to get dlls working as component implementations. In the native runtime there is a Java scagen tool
that does C++ header file introspection. Its for generating C++ service
proxy classes but there may be some code that is of use there if there is a
requirement to do instropection in this case


It would be great if we can introspect the C++ header file to create a componentType for the C++ components.




Thanks,
Raymond

--------------------------------------------------
From: ""Dietrich, Björn"" <[EMAIL PROTECTED]>
Sent: Wednesday, June 25, 2008 11:45 PM
To: <[email protected]>
Subject: AW: Apache Tuscany doubts


 Hi,

We are also looking for native (JNI) binding between Java and C++,
This would be a real cool feature.

Greetings
Björn


-----Ursprüngliche Nachricht-----
Von: Malte Marquarding [mailto:[EMAIL PROTECTED]
Gesendet: Donnerstag, 26. Juni 2008 02:51
An: [email protected]
Betreff: Re: Apache Tuscany doubts

Hi,

Is there a timeline for the java runtime hosting a c++ component? We are currently evaluating tuscany and need to access c++ components as these are
needed for specialized algorithms.


Cheers,
Malte.


 At this point, Tuscany has both Java and C++ for 1). But the java
runtime doesn't support C++ component, and not C++ runtime supports
Java component either. So we have to use different runtimes to host
the C++ and Java components at this point, but it's potentially
possible that the Java runtime will be capable of hosting C++ component.



Here are a few ideas:

a) Run your C++ component on the Tuscany C++ runtime, with an SCA Web Service binding using Axis2C's mini-server or Apache Httpd. Run other (Java?) components on the Java runtime. From the Java components use SCA references wired to the C++ component using SCA Web Service bindings.

Note: The C++ runtime implements an older level of the SCA spec and we've not tested much the interop with the Java runtime recently.

b) Use Raymond's JNI-based approach to run your C++ component on the Java runtime.

c) Use approach (b) but run the C++ component in a different SCA node (i.e. a different JVM) to shield your Java components from any side effects caused by the C++ component of if you need to integrate several C++ components with incompatible 3rd party dependencies for example.

Wiring components that run on different nodes/JVMs in an SCA domain is very easy/transparent using the SCA default binding.

d) Options (b) or (c) with some level of integration to introspect the C++ headers (to be developed), and generate the source of corresponding Java interfaces or just their bytecode at runtime. This should be easy to do by tweaking some of the generator code from the Tuscany C++ project.

Tell us what you think... We can probably brainstorm more and help find the best integration approach if you tell us a little more about the other kinds of components that you're integrating the C++ code with, what kind of SCA support (like reference passing, use of SCA C++ APIs etc) you're interested in (maybe not much if the C++ is existing code?), and what kind of data (just simple types or complex objects?) you're passing across.

Hope this helps.
--
Jean-Sebastien

Reply via email to