As if implementing these methods wasn't simple enough, a three extra tools exist to make it even easier.
The first is the JointConsoleFacet class in org.jtrix.project.libjtrix.netlet. Its constructor takes two or more IConsoleFacet objects. The result is a new object which combines the commands and properties of all.
    IConsoleFacet primary   = // ...  Some console facet
    IConsoleFacet secondary = // ... Some other console facet
    IConsoleFacet both      = new JointConsoleFacet(primary, secondary);
    // Now "both" is a console facet with all the commands and properties
    // of "primary" and "secondary".
The second is ConsoleFacetFactory in the same package, which generates commands by itself! A new ConsoleFacetFactory is constructed by giving an interface which implements IRemote. The new factory introspects the named interface and those interfaces it extends. It looks for methods whose parameters and return values are all Property-friendly objects and it automatically creates a command for each one. Then to create an IConsoleFacet we just give it an object which implements the original interface. We can also give it properties which can be read from the console command line.
    // ISomeFacet is a facet. We want to turn its methods into console commands.
    // "facet_impl" is an actual implementation of ISomeFacet.
    Class c            = ISomeFacet.class;
    IRemote facet_impl = // ... Some implementation of ISomeFacet
    ConsoleFacetFactory fact = new ConsoleFacetFactory(c);
    IConsoleFacet cons       = fact.createConsoleFacet(facet_impl);
    // Now "cons" is a console facet, and each of its commands is a method in
    // ISomeFacet. Each command will be handled by the implementation "facet_impl".
The third is the getStandardConsole() method of IPeerSupport
to get Beatrix's standard console. This returns an IConsoleFacet
of commands standard to that netlet. On a manager these are genuinely
useful commands. On a worker there are no commands in this console,
so it's not much help. Either way, this is the same IConsoleFacet
that a ServiceManager adds to every admin service provider's
facet collection, as described in Section ![[*]](crossref.png) .
.
    // Our plugin manager is in variable "pm".  We use the static method
    // IPeerSupport.Get.one() to get the one instance of the IPeerSupport
    // plugin that we expect in this plugin manager.
    IConsoleFacet cons = IPeerSupport.Get.one(pm).getStandardConsole();
    // Now "cons" is a the console facet that's supplied with this netlet.
    // If we're in a manager netlet this contains admin commands. If we're
    // in a worker netlet there are no commands, though this may change in
    // future.
The SkeletonServiceProvider plugin (Section ![[*]](crossref.png) )
uses all of these tools. It first uses a ConsoleFacetFactory
to turn the SkeletonFacet from a class with a getMessage()
method into an IConsoleFacet with a getMessage command
line command. Then it uses the JointConsoleFacet
class to add in the commands provided by Beatrix's standard console
facet. (Since this takes place on a worker netlet, the standard console
facet has no commands in it; the standard console facet for a manager
contains all the privileged admin commands.)
)
uses all of these tools. It first uses a ConsoleFacetFactory
to turn the SkeletonFacet from a class with a getMessage()
method into an IConsoleFacet with a getMessage command
line command. Then it uses the JointConsoleFacet
class to add in the commands provided by Beatrix's standard console
facet. (Since this takes place on a worker netlet, the standard console
facet has no commands in it; the standard console facet for a manager
contains all the privileged admin commands.)
Nik Silver 2002-03-09