public static void main(String[] args) {
        // run application from cmd line using Maven:
        // mvn exec:java -Dexec.mainClass="io.joynr.demo.MyRadioConsumerApplication" -Dexec.args="<arguments>"
        DiscoveryScope tmpDiscoveryScope = DiscoveryScope.LOCAL_AND_GLOBAL;
        String host = "localhost";
        int port = 4242;
        String providerDomain = "domain";
        String transport = null;

        CommandLine line;
        Options options = new Options();
        Options helpOptions = new Options();
        setupOptions(options, helpOptions);
        CommandLineParser parser = new DefaultParser();

        // check for '-h' option alone first. This is required in order to avoid
        // reports about missing other args when using only '-h', which should supported
        // to just get help / usage info.
        try {
            line = parser.parse(helpOptions, args);

            if (line.hasOption('h')) {
                HelpFormatter formatter = new HelpFormatter();
                // use 'options' here to print help about all possible parameters
                formatter.printHelp(MyRadioConsumerApplication.class.getName(), options, true);
                System.exit(0);
            }
        } catch (ParseException e) {
            // ignore, since any option except '-h' will cause this exception
        }

        try {
            line = parser.parse(options, args);

            if (line.hasOption('d')) {
                providerDomain = line.getOptionValue('d');
                LOG.info("found domain = " + providerDomain);
            }
            if (line.hasOption('H')) {
                host = line.getOptionValue('H');
                LOG.info("found host = " + host);
            }
            if (line.hasOption('l')) {
                tmpDiscoveryScope = DiscoveryScope.LOCAL_ONLY;
                LOG.info("found scope local");
            }
            if (line.hasOption('p')) {
                port = Integer.parseInt(line.getOptionValue('p'));
                LOG.info("found port = " + port);
            }
            if (line.hasOption('t')) {
                transport = line.getOptionValue('t').toLowerCase();
                LOG.info("found transport = " + transport);
            }
        } catch (ParseException e) {
            LOG.error("failed to parse command line: " + e);
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(MyRadioConsumerApplication.class.getName(), options, true);
            System.exit(1);
        }

        // joynr config properties are used to set joynr configuration at compile time. They are set on the
        // JoynInjectorFactory.
        Properties joynrConfig = new Properties();
        Module runtimeModule = getRuntimeModule(transport, host, port, joynrConfig);

        LOG.debug("Using the following runtime module: " + runtimeModule.getClass().getSimpleName());
        LOG.debug("Searching for providers on domain \"{}\"", providerDomain);

        // Set a custom static persistence file (default is joynr.properties in the working dir) to store
        // joynr configuration. It allows for changing the joynr configuration at runtime. Custom persistence
        // files support running the consumer and provider applications from within the same directory.
        joynrConfig.setProperty(MessagingPropertyKeys.PERSISTENCE_FILE, STATIC_PERSISTENCE_FILE);

        // How to use custom infrastructure elements:

        // 1) Set them programmatically at compile time using the joynr configuration properties at the
        // JoynInjectorFactory. E.g. uncomment the following lines to set a certain joynr server
        // instance.
        // joynrConfig.setProperty(MessagingPropertyKeys.BOUNCE_PROXY_URL, "http://localhost:8080/bounceproxy/");
        // joynrConfig.setProperty(MessagingPropertyKeys.DISCOVERYDIRECTORYURL, "http://localhost:8080/discovery/channels/discoverydirectory_channelid/");
        joynrConfig.setProperty(PROPERTY_JOYNR_DOMAIN_LOCAL, "radioapp_consumer_local_domain");

        // 2) Or set them in the static persistence file (default: joynr.properties in working dir) at
        // runtime. If not available in the working dir, it will be created during the first launch
        // of the application. Copy the following lines to the custom persistence file to set a
        // certain joynr server instance.
        // NOTE: This application uses a custom static persistence file consumer-joynr.properties.
        // Copy the following lines to the custom persistence file to set a certain joynr server
        // instance.
        // joynr.messaging.bounceproxyurl=http://localhost:8080/bounceproxy/
        // joynr.messaging.discoverydirectoryurl=http://localhost:8080/discovery/channels/discoverydirectory_channelid/

        // 3) Or set them in Java System properties.
        // -Djoynr.messaging.bounceProxyUrl=http://localhost:8080/bounceproxy/
        // -Djoynr.messaging.capabilitiesDirectoryUrl=http://localhost:8080/discovery/channels/discoverydirectory_channelid/

        // NOTE:
        // Programmatically set configuration properties override properties set in the static persistence file.
        // Java system properties override both

        // Application-specific configuration properties are injected to the application by setting
        // them on the JoynApplicationModule.
        Properties appConfig = new Properties();
        appConfig.setProperty(APP_CONFIG_PROVIDER_DOMAIN, providerDomain);
        final DiscoveryScope discoveryScope = tmpDiscoveryScope;

        JoynrApplication myRadioConsumerApp = new JoynrInjectorFactory(joynrConfig,
                                                                       runtimeModule).createApplication(new JoynrApplicationModule(MyRadioConsumerApplication.class, appConfig) {
                                                                           @Override
                                                                           protected void configure() {
                                                                               super.configure();
                                                                               bind(DiscoveryScope.class).toInstance(discoveryScope);
                                                                           }
                                                                       });
        myRadioConsumerApp.run();

        myRadioConsumerApp.shutdown();
    }
public static void main ( String [ ] args ) { DiscoveryScope tmpDiscoveryScope = DiscoveryScope . LOCAL_AND_GLOBAL ; String host = "localhost" ; int port = 4242 ; String providerDomain = "domain" ; String transport = null ; CommandLine line ; Options options = new Options ( ) ; Options helpOptions = new Options ( ) ; setupOptions ( options , helpOptions ) ; CommandLineParser parser = new DefaultParser ( ) ; try { line = parser . parse ( helpOptions , args ) ; if ( line . hasOption ( 'h' ) ) { HelpFormatter formatter = new HelpFormatter ( ) ; formatter . printHelp ( MyRadioConsumerApplication . class . getName ( ) , options , true ) ; System . exit ( 0 ) ; } } catch ( ParseException e ) { } try { line = parser . parse ( options , args ) ; if ( line . hasOption ( 'd' ) ) { providerDomain = line . getOptionValue ( 'd' ) ; LOG . info ( "found domain = " + providerDomain ) ; } if ( line . hasOption ( 'H' ) ) { host = line . getOptionValue ( 'H' ) ; LOG . info ( "found host = " + host ) ; } if ( line . hasOption ( 'l' ) ) { tmpDiscoveryScope = DiscoveryScope . LOCAL_ONLY ; LOG . info ( "found scope local" ) ; } if ( line . hasOption ( 'p' ) ) { port = Integer . parseInt ( line . getOptionValue ( 'p' ) ) ; LOG . info ( "found port = " + port ) ; } if ( line . hasOption ( 't' ) ) { transport = line . getOptionValue ( 't' ) . toLowerCase ( ) ; LOG . info ( "found transport = " + transport ) ; } } catch ( ParseException e ) { LOG . error ( "failed to parse command line: " + e ) ; HelpFormatter formatter = new HelpFormatter ( ) ; formatter . printHelp ( MyRadioConsumerApplication . class . getName ( ) , options , true ) ; System . exit ( 1 ) ; } Properties joynrConfig = new Properties ( ) ; Module runtimeModule = getRuntimeModule ( transport , host , port , joynrConfig ) ; LOG . debug ( "Using the following runtime module: " + runtimeModule . getClass ( ) . getSimpleName ( ) ) ; LOG . debug ( "Searching for providers on domain \"{}\"" , providerDomain ) ; joynrConfig . setProperty ( MessagingPropertyKeys . PERSISTENCE_FILE , STATIC_PERSISTENCE_FILE ) ; joynrConfig . setProperty ( PROPERTY_JOYNR_DOMAIN_LOCAL , "radioapp_consumer_local_domain" ) ; Properties appConfig = new Properties ( ) ; appConfig . setProperty ( APP_CONFIG_PROVIDER_DOMAIN , providerDomain ) ; final DiscoveryScope discoveryScope = tmpDiscoveryScope ; JoynrApplication myRadioConsumerApp = new JoynrInjectorFactory ( joynrConfig , runtimeModule ) . createApplication ( new JoynrApplicationModule ( MyRadioConsumerApplication . class , appConfig ) { @ Override protected void configure ( ) { super . configure ( ) ; bind ( DiscoveryScope . class ) . toInstance ( discoveryScope ) ; } } ) ; myRadioConsumerApp . run ( ) ; myRadioConsumerApp . shutdown ( ) ; }
Main method. This method is responsible for: 1. Instantiating the consumer application. 2. Injecting the instance
with Guice bindings 3. Starting the application. 4. Ending the application so that the necessary clean up calls
are made.

@param args arguments give when calling the main method