class RCLJava {

    public static void rclJavaInit(final String... args) {
        synchronized (RCLJava.class) {
            if (!RCLJava.initialized) {
                if (args != null) {
                    RCLJava.arguments = args;

                    for (final String arg : RCLJava.arguments) {
                        if (arg.contains("=")) {
                            final String[] keyVal = arg.split("=");
                            RCLJava.logger.debug("Args : " + keyVal[0] + "\t : " + keyVal[1]);
                        } else {
                            RCLJava.logger.debug("Args : " + arg);
                        }
                    }
                }

                // Auto-detect RMW implementation.
                if (RCLJava.rmwImplementation == null) {
                    RCLJava.displayContext();
                    RCLJava.autoLoadRmw();
                }

                // No RMW implementation founded !
                if (RCLJava.rmwImplementation == null) {
                    RCLJava.logger.error("No RMW implementation found...");
                    System.exit(1);
                } else

                // RMW implementation founded.
                {
                    RCLJava.logger.debug("Initialize rclJava with " + RCLJava.rmwImplementation);
                    RCLJava.nativeRCLJavaInit(RCLJava.arguments);
                    RCLJava.initialized = true;
                }
            } else {
                final NotInitializedException ex = new NotInitializedException("Cannot intialized twice !");
                logger.error(ex.getMessage());
                throw ex;
            }
        }
    }

    private  RCLJava();

}