NIO/TCP Transport

The NIO-based transport provider is based on Apache Mina (1.1.7). This transport is extremely performant and scalable. It is Ubik's default transport provider.


You can export an object in two manners: using the on of the Hub class export(...) methods, or using an instance of the MinaServerExporter class.


The Mina transport provider accepts multiple configuration properties. You may want to configure threading based on your server's use cases:

  • ubik.rmi.server.core-threads: the minimum number threads for the worker thread pool (defaults to 5).
  • ubik.rmi.server.max-threads: the maximum number of threads for the worker thread pool (defaults to 25).
  • ubik.rmi.server.threads.queue-size: the size of the request queue assigned to the worker thread pool (defaults to 50).
  • ubik.rmi.server.threads.keep-alive: the maximum time (in seconds) to keep idle worker threads (defaults to 30 seconds)

If you export an object using the hub's export(Object o, Properties props) and you target this provider, you can specify the above-mentioned configuration properties as part of the given Properties argument; and you must specify the "type" identifier of this provider, with the following property (also in the properties passed in):

  • ubik.rmi.transport.mplex.acceptor-threads (the property's value must be: nio/tcp/mina).
When you bind an object to Ubik's JNDI implementation, and that object is not a stub corresponding to an already exported object, the JNDI implementation will export that object automatically, using this transport provider (since it is the default).

Exporting an Object

When you use the Hub's export(Object o) or export(Object o, int port) methods, Ubik uses the Mina provider to start a server on a dynamic port, or on the user-specified port. From then on, the object that you export can potentially receive remote method calls

Using the Exporter

Rather than using a more tedious approach, we recommend you use a MinaServerExporter, as follows:

MinaServerExporter exporter = new NioServerExporter();
    Hello helloServer = exporter.export(new HelloImpl());

The above exports the HelloImpl instance as a server, using the Mina-based transport. The stub that is returned by the export() method can then be bound to Ubik's JNDI, as such:

Context context = JNDIContextBuilder.newInstance().domain("myDomain").build();
    context.bind("hello", helloServer);