What I'd like to do is to define a service analogous to the Adder,
Subtracter.

Then, I'd like to define a service, Math that uses the Adder and
Subtracter modules to provide the following interface:

public interface Math {
    int add(int arg0, int arg1);
    int subtract(int arg0, int arg1);
}

with implementation:

package hivemind.examples.impl;

import hivemind.examples.Math;
import hivemind.examples.Adder;
import hivemind.examples.Subtracter;

public class MathImpl implements Math {
    private Adder adder;

    public void setAdder(Adder adder) {
        this.adder = adder;
    }

    private Subtracter subtracter;

    public void setSubtracter(Subtracter subtracter) {
        this.subtracter = subtracter;
    }

    public int add(int arg0, int arg1) {
        return adder.add(arg0, arg1);
    }

    public int subtract(int arg0, int arg1) {
        return subtracter.add(arg0, arg1);
    }
}

and call it from code thus (after appropriate registry construction,
etc.):

        Math math = (Math) registry.getService("hivemind.examples.Math",
                                               Math.class);

        System.out.println("Result of add: " + math.add(arg0, arg1));
        System.out.println("Result of subtract: " + math.subtract(arg0, arg1));

I'm a bit confused as to how to tie all of this together.  Could someone
provide some pointers?

Thanks.


Bill

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to