Table of Contents Previous Next
Logo
Server-Side Slice-to-Java Mapping : 12.5 Parameter Passing
Copyright © 2003-2009 ZeroC, Inc.

12.5 Parameter Passing

For each parameter of a Slice operation, the Java mapping generates a corresponding parameter for the corresponding method in the
_<interfacename>Operations interface. In addition, every operation has an additional, trailing parameter of type Ice.Current. For example, the name operation of the Node interface has no parameters, but the name member function of the _NodeOperations interface has a single parameter of type Ice.Current. We explain the purpose of this parameter in Section 32.6 and will ignore it for now.
To illustrate the rules, consider the following interface that passes string parameters in all possible directions:
module M {
    interface Example {
        string op(string sin, out string sout);
    };
};
The generated skeleton class for this interface looks as follows:
public interface _ExampleOperations
{
    String op(String sin, Ice.StringHolder sout,
              Ice.Current current);
}
As you can see, there are no surprises here. For example, we could implement op as follows:
public final class ExampleI extends M._ExampleDisp {

    public String op(String sin, Ice.StringHolder sout,
                     Ice.Current current)
    {
        System.out.println(sin);     // In params are initialized
        sout.value = "Hello World!"; // Assign out param
        return "Done";
    }
}
This code is in no way different from what you would normally write if you were to pass strings to and from a function; the fact that remote procedure calls are involved does not impact on your code in any way. The same is true for parameters of other types, such as proxies, classes, or dictionaries: the parameter passing conventions follow normal Java rules and do not require special-purpose API calls.
Table of Contents Previous Next
Logo