Introspection format and out argument

asked 2014-04-03 06:43:47 -0700

PierreR gravatar image

updated 2014-04-04 00:00:52 -0700

When defining an interface in AllJoyn XML fomat (currently DBus introspection format), one can define a method with several out parameters. But when using the Java binding, there is obviously only one return value.

I've seen we can use Mutable.StringValue, Mutable.IntegerValue and Mutable.ShortValue in java to wrap java type and add the in/out semantic.

  • how do we know which out parameter is used as a return value (the last one?) and whose are wrapped in a Mutable class ?
  • how do we manage other out parameter type ?

Edit 04/04/2014 - 09h00

To make things more clear, I add an example : let's say you have an XML interface definition with several out parameters :

<method name="severalOutParamsMethods">
  <arg type="s" direction="in"/>
  <arg type="s" direction="out"/>
  <arg type="s" direction="out"/>

Given this interface, how should I map this on a java interface ? My current approach is to use the first out parameter as a return value, and the followings as paramaters wrapped in a Mutable.String object. For full disclosure, I'm working on a dynamic java binding, so my question is not really how I could do that with the current binding (although that would be an interesting question too) but more how should a dynamic binding ideally handle this case.

edit retag flag offensive close merge delete


PierreR are you still haveing problems with how to handle out arguments in the Java binding? If so please add an additional edit to your question and I see if I can help solve the problem.

georgen ( 2014-05-12 09:56:10 -0700 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-04-03 08:59:10 -0700

georgen gravatar image

updated 2014-04-04 08:30:27 -0700

To get multiple return values in Java requires making a public class to hold those return values with some annotations to help the code know what to do. See the Guide to AllJoyn development using the Java SDK Multiple return values

so using your example with a string, integer and short you would need to make an interface similar to this.

@BusInterface (name = "com.example.georgen.sample")
public interface MultipleReturnValuesInterface {
    public class ReturnValues {
        @Position(0) public String strReturnValue;
        @Position(1) public int intReturnValue;
        @Position(2) public short shortReturnValue;

    public ReturnValues foo() throws BusException;

Now when the foo method is invoked it will return a ReturnValues class with the return values.

A few things to be aware of. the ReturnValues class and all of its member variables must be public.

Updated to address the XML definition given in the edited question

In Java when you want to implement multiple return values they are always returned as a single value. I could modify my sample from above to use the severalOutParamsMethods method given in the Edit 04/04/2014

@BusInterface (name = "com.example.georgen.sample")
public interface MultipleReturnValuesInterface {
    public class OutParams {
        @Position(0) public String strOut1;
        @Position(1) public String strOut2;

    public OutParams severalOutParamsMethods(String strIn) throws BusException;
edit flag offensive delete publish link more


thanks for your answer, unfortunately it's not what I meant, I was thinking on mapping an existing XML definition with several out parameters to a Java interface. I'll edit my questions to make things more clear.

PierreR ( 2014-04-03 23:55:18 -0700 )edit
Login/Signup to Answer

Question Tools



Asked: 2014-04-03 06:43:47 -0700

Seen: 312 times

Last updated: Apr 04 '14