Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You can either deploy another set of keystores that use the above names or change the named used and deploy new keystores. The key aliases must be set to a valid key in the store that will be used to secure the communication.

#top

Using the client jar

From Apache ServiceMix Kernel 1.1.0 and posterior versions, it is possible to use a more lightweight way to connect to a ServiceMix Kernel instance using the following command line:

Code Block

java -jar lib/servicemix-client.jar

There are a few parameters that can be set on the command line to change the URL used to connect to the Kernel, the user or the password.
All these parameters are detailed in the help screen:

Panel
bgColor#000000

No Format
nopaneltrue

> java -jar lib/servicemix-client.jar --help
Apache ServiceMix Kernel client
  -a [address]  specify the URL to connect to
  -u [user]     specify the user name
  -p [password] specify the password
  --help        shows this help message
  [commands]    commands to run
If no commands are specified, the client will be put in an interactive mode

For example, to shut down the Kernel from the command line, you can run the following command:

Panel
bgColor#000000

No Format
nopaneltrue

> java -jar lib/servicemix-client.jar osgi shutdown
Connected
>

#top

Programmatically connect to the Kernel

A connection to the kernel can also be done programmatically.
You can find a code example from the client library mentionned in the previous section.

Code Block
langjava

import org.apache.geronimo.gshell.remote.crypto.CryptoContext;
import org.apache.geronimo.gshell.remote.client.RshClient;
import org.apache.geronimo.gshell.remote.client.RemoteExecuteException;
import org.apache.geronimo.gshell.remote.client.handler.EchoHandler;
import org.apache.geronimo.gshell.remote.client.handler.ClientMessageHandler;
import org.apache.geronimo.gshell.whisper.transport.TransportException;
import org.apache.geronimo.gshell.whisper.transport.TransportFactory;
import org.apache.geronimo.gshell.whisper.transport.TransportFactoryLocator;
import org.apache.geronimo.gshell.whisper.transport.tcp.SpringTcpTransportFactory;
import org.apache.geronimo.gshell.whisper.stream.StreamFeeder;
import org.apache.geronimo.gshell.layout.NotFoundException;
import org.apache.geronimo.gshell.ExitNotification;

public class Main {

    public static void main(String[] args) throws Exception {
        RshClient client = null;
        try {
            CryptoContext context = new CryptoContext("RSA", null);
            List<ClientMessageHandler> handlers = new LinkedList<ClientMessageHandler>();
            handlers.add(new EchoHandler());
            client = new RshClient(context, new Locator(), handlers);

            client.initialize();
            client.connect(address, new URI("tcp://0.0.0.0:0"));
            client.login(user, password);
            StreamFeeder outputFeeder = new StreamFeeder(client.getInputStream(), System.out);
            outputFeeder.createThread().start();
            client.openShell();
            System.out.println("Connected");

            client.execute(args[0]);
        } catch (ExitNotification e) {
            System.exit(0);
        } catch (Throwable t) {
            t.printStackTrace();
            System.exit(1);
        } finally {
            try {
                client.closeShell();
                client.close();
            } catch (Throwable t) { }
        }
        System.exit(0);
    }

    private static class Locator implements TransportFactoryLocator {
        SpringTcpTransportFactory factory = new SpringTcpTransportFactory();

        public TransportFactory locate(URI arg0) throws TransportException {
            return factory;
        }

    }
}

You can find a more complete example at the following location.

#top

Wiki Markup
{scrollbar}