Example usage for java.lang System getProperty

List of usage examples for java.lang System getProperty

Introduction

In this page you can find the example usage for java.lang System getProperty.

Prototype

public static String getProperty(String key) 

Source Link

Document

Gets the system property indicated by the specified key.

Usage

From source file:com.revo.deployr.client.example.data.io.anon.discrete.exec.ExternalDataInDataFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;/*from  www .jav a  2s.c om*/

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Create the AnonymousProjectExecutionOptions object
         * to specify data inputs and output to the script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions();

        /* 
         * Load an R object literal "hipStarUrl" into the
         * workspace prior to script execution.
         *
         * The R script checks for the existence of "hipStarUrl"
         * in the workspace and if present uses the URL path
         * to load the Hipparcos star dataset from the DAT file
         * at that location.
         */
        RData hipStarUrl = RDataFactory.createString("hipStarUrl", HIP_DAT_URL);
        List<RData> rinputs = Arrays.asList(hipStarUrl);
        options.rinputs = rinputs;

        log.info("[   DATA INPUT   ] External data source input "
                + "set on execution, [ ProjectPreloadOptions.rinputs ].");

        /*
         * Execute a public analytics Web service as an anonymous
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options);

        log.info("[   EXECUTION    ] Discrete R script " + "execution completed [ RScriptExecution ].");

        /*
         * Retrieve the working directory file (artifact) called
         * hip.csv that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectFile> wdFiles = exec.about().artifacts;

        for (RProjectFile wdFile : wdFiles) {
            if (wdFile.about().filename.equals("hip.csv")) {
                log.info("[  DATA OUTPUT   ] Retrieved working directory " + "file output "
                        + wdFile.about().filename + " [ RProjectFile ].");
                InputStream fis = null;
                try {
                    fis = wdFile.download();
                } catch (Exception ex) {
                    log.warn("Working directory data file " + ex);
                } finally {
                    IOUtils.closeQuietly(fis);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:com.revo.deployr.client.example.data.io.auth.discrete.exec.RepoFileInRepoFileOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;/*ww w.  ja v a 2s  .co m*/

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create the AnonymousProjectExecutionOptions object
         * to specify data inputs and output to the script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        AnonymousProjectExecutionOptions options = new AnonymousProjectExecutionOptions();

        /* 
         * Preload from the DeployR repository the following
         * data input file:
         * /testuser/example-data-io/hipStar.dat
         */
        ProjectPreloadOptions preloadDirectory = new ProjectPreloadOptions();
        preloadDirectory.filename = "hipStar.dat";
        preloadDirectory.directory = "example-data-io";
        preloadDirectory.author = "testuser";
        options.preloadDirectory = preloadDirectory;

        log.info("[   DATA INPUT   ] Repository data file input "
                + "set on execution, [ ProjectExecutionOptions.preloadDirectory ].");

        /* 
         * Request storage of entire workspace as a
         * binary rData file to the DeployR-repository
         * following the execution.
         *
         * Alternatively, you could use storageOptions.objects
         * to store individual objects from the workspace.
         */
        ProjectStorageOptions storageOptions = new ProjectStorageOptions();
        // Use random file name for this example.
        storageOptions.workspace = Long.toHexString(Double.doubleToLongBits(Math.random()));
        storageOptions.directory = "example-data-io";
        options.storageOptions = storageOptions;

        log.info("[  EXEC OPTION   ] Repository storage request "
                + "set on execution [ ProjectExecutionOptions.storageOptions ].");

        /*
         * Execute an analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RScriptExecution exec = rClient.executeScript("dataIO.R", "example-data-io", "testuser", null, options);

        log.info("[   EXECUTION    ] Discrete R script " + "execution completed [ RScriptExecution ].");

        /*
         * Retrieve repository-managed file(s) that were 
         * generated by the execution per ProjectStorageOptions.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RRepositoryFile> repoFiles = exec.about().repositoryFiles;

        for (RRepositoryFile repoFile : repoFiles) {
            log.info("[  DATA OUTPUT   ] Retrieved repository " + "file output " + repoFile.about().filename
                    + " [ RRepositoryFile ].");
            InputStream fis = null;
            try {
                fis = repoFile.download();
            } catch (Exception ex) {
                log.warn("Repository-managed file download " + ex);
            } finally {
                IOUtils.closeQuietly(fis);
                try { // Clean-up after example.
                    repoFile.delete();
                } catch (Exception dex) {
                    log.warn("Repository-managed file delete " + dex);
                }
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:Lock.java

public static void main(String args[]) throws IOException, InterruptedException {
    RandomAccessFile file = null; // The file we'll lock
    FileChannel f = null; // The channel to the file
    FileLock lock = null; // The lock object we hold

    try { // The finally clause closes the channel and releases the lock
        // We use a temporary file as the lock file.
        String tmpdir = System.getProperty("java.io.tmpdir");
        String filename = Lock.class.getName() + ".lock";
        File lockfile = new File(tmpdir, filename);

        // Create a FileChannel that can read and write that file.
        // Note that we rely on the java.io package to open the file,
        // in read/write mode, and then just get a channel from it.
        // This will create the file if it doesn't exit. We'll arrange
        // for it to be deleted below, if we succeed in locking it.
        file = new RandomAccessFile(lockfile, "rw");
        f = file.getChannel();/*from   w  w w .  j  a  v  a  2 s  . c o  m*/

        // Try to get an exclusive lock on the file.
        // This method will return a lock or null, but will not block.
        // See also FileChannel.lock() for a blocking variant.
        lock = f.tryLock();

        if (lock != null) {
            // We obtained the lock, so arrange to delete the file when
            // we're done, and then write the approximate time at which
            // we'll relinquish the lock into the file.
            lockfile.deleteOnExit(); // Just a temporary file

            // First, we need a buffer to hold the timestamp
            ByteBuffer bytes = ByteBuffer.allocate(8); // a long is 8 bytes

            // Put the time in the buffer and flip to prepare for writing
            // Note that many Buffer methods can be "chained" like this.
            bytes.putLong(System.currentTimeMillis() + 10000).flip();

            f.write(bytes); // Write the buffer contents to the channel
            f.force(false); // Force them out to the disk
        } else {
            // We didn't get the lock, which means another instance is
            // running. First, let the user know this.
            System.out.println("Another instance is already running");

            // Next, we attempt to read the file to figure out how much
            // longer the other instance will be running. Since we don't
            // have a lock, the read may fail or return inconsistent data.
            try {
                ByteBuffer bytes = ByteBuffer.allocate(8);
                f.read(bytes); // Read 8 bytes from the file
                bytes.flip(); // Flip buffer before extracting bytes
                long exittime = bytes.getLong(); // Read bytes as a long
                // Figure out how long that time is from now and round
                // it to the nearest second.
                long secs = (exittime - System.currentTimeMillis() + 500) / 1000;
                // And tell the user about it.
                System.out.println("Try again in about " + secs + " seconds");
            } catch (IOException e) {
                // This probably means that locking is enforced by the OS
                // and we were prevented from reading the file.
            }

            // This is an abnormal exit, so set an exit code.
            System.exit(1);
        }

        // Simulate a real application by sleeping for 10 seconds.
        System.out.println("Starting...");
        Thread.sleep(10000);
        System.out.println("Exiting.");
    } finally {
        // Always release the lock and close the file
        // Closing the RandomAccessFile also closes its FileChannel.
        if (lock != null && lock.isValid())
            lock.release();
        if (file != null)
            file.close();
    }
}

From source file:examples.ssh.LocalPF.java

public static void main(String... args) throws Exception {
    SSHClient ssh = new SSHClient();

    ssh.loadKnownHosts();/*from  w w w.  j  a va 2s .  com*/

    ssh.connect("localhost");
    try {

        ssh.authPublickey(System.getProperty("user.name"));

        /*
         * _We_ listen on localhost:8080 and forward all connections on to server, which then forwards it to
         * google.com:80
         */

        ssh.newLocalPortForwarder(new InetSocketAddress("localhost", 8080), "google.com", 80).listen();

    } finally {
        ssh.disconnect();
    }
}

From source file:com.revo.deployr.client.example.data.io.auth.stateful.preload.RepoFileInGraphicsPlotOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;//from  w  ww.  ja va 2  s. co  m
    RProject rProject = null;

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create a ProjectCreationOptions instance
         * to specify data inputs that "pre-heat" the R session
         * workspace or working directory for your project.
         */
        ProjectCreationOptions options = new ProjectCreationOptions();

        /* 
         * Preload from the DeployR repository the following
         * data input file:
         * /testuser/example-data-io/hipStar.dat
         */
        ProjectPreloadOptions preloadDirectory = new ProjectPreloadOptions();
        preloadDirectory.filename = "hipStar.dat";
        preloadDirectory.directory = "example-data-io";
        preloadDirectory.author = "testuser";
        options.preloadDirectory = preloadDirectory;

        log.info("[ PRELOAD INPUT  ] Repository data file input "
                + "set on project creation, [ ProjectCreationOptions.preloadDirectory ].");

        /*
         * Create a temporary project (R session) passing a 
         * ProjectCreationOptions to "pre-heat" data into the
         * workspace and/or working directory.
         */
        rProject = rUser.createProject(options);

        log.info("[  GO STATEFUL   ] Created stateful temporary " + "R session [ RProject ].");

        /*
         * Execute a public analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null, null);

        log.info("[   EXECUTION    ] Stateful R script " + "execution completed [ RProjectExecution ].");

        /*
         * Retrieve R graphics device plot (result) called
         * unnamedplot*.png that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectResult> results = exec.about().results;

        for (RProjectResult result : results) {
            log.info("[  DATA OUTPUT   ] Retrieved graphics device " + "plot output " + result.about().filename
                    + " [ RProjectResult ].");
            InputStream fis = null;
            try {
                fis = result.download();
            } catch (Exception ex) {
                log.warn("Graphics device plot download " + ex);
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rProject != null) {
                /*
                 * Close rProject before application exits.
                 */
                rProject.close();
            }
        } catch (Exception fex) {
        }
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:net.vnt.ussdapp.util.ContextTest.java

public static void main(String[] args) {
    ApplicationContext context = new ClassPathXmlApplicationContext(new String[] { "/context.xml" });
    ContextProperties ctxProp = (ContextProperties) Context.getInstance().getBean("ContextProperties");
    TXTParser parser = (TXTParser) Context.getInstance().getBean("TXTParser");
    String mainmenu = ctxProp.getProperty("ussdapp.wrong");
    try {/*  w w  w . j a va2s  .  c o  m*/
        Vector<String> vs = parser.readFields(mainmenu);
        Enumeration<String> ens = vs.elements();
        StringBuilder sb = new StringBuilder();
        while (ens.hasMoreElements()) {
            sb.append(ens.nextElement()).append("\n");
        }
        System.out.println(sb.toString());
    } catch (IOException ex) {
        Logger.getLogger(ContextTest.class.getName()).log(Level.SEVERE, null, ex);
    }
    System.out.println(System.getProperty("os.arch"));
}

From source file:org.openpplsoft.Main.java

/**
 * Main entry point for the OPS runtime.
 * @param args command line args to main
 *///from  w w  w . ja va 2s  .  c om
public static void main(final String[] args) {

    // The name of the environment to access is expected at args[0]
    System.setProperty("contextFile", args[0] + ".xml");
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(System.getProperty("contextFile"));

    // The name of the component to load is expected at args[1]
    ComponentRuntimeProfile profileToRun = (ComponentRuntimeProfile) ctx.getBean(args[1]);

    try {
        Runtime.getRuntime().addShutdownHook(new ENTShutdownHook());
        TraceFileVerifier.init(profileToRun);
        Environment.init((String) ctx.getBean("psEnvironmentName"), profileToRun.getOprid());

        Environment.setSystemVar("%Component", new PTString(profileToRun.getComponentName()));
        Environment.setSystemVar("%Menu", new PTString("SA_LEARNER_SERVICES"));
        Environment.setSystemVar("%Mode", new PTString(profileToRun.getMode()));

        Environment.setSystemVar("%Action_UpdateDisplay", new PTString("U"));
        Environment.setSystemVar("%Action_Add", new PTString("A"));

        /*
         * The following system vars can theoretically vary among environments.
         * However, at the moment, I am running this on identically configured
         * vanilla PS instances. Therefore, I am not going to externalize these
         * values for the time being.
         */
        Environment.setSystemVar("%Portal", new PTString("EMPLOYEE"));
        Environment.setSystemVar("%Node", new PTString("HRMS"));

        // Since we are verifying against a tracefile, we have to override
        // the default current date and time with the date and time
        // on/at which the tracefile was generated.
        Environment.setSystemVar("%Date", profileToRun.getTraceFileDate());
        Environment.setSystemVar("%Time", profileToRun.getTraceFileDateTime());

        final Component c = DefnCache.getComponent((String) Environment.getSystemVar("%Component").read(),
                "GBL");

        // Set %Page to the name of the first page in the component.
        Environment.setSystemVar("%Page", new PTString(c.getPages().get(0).getPNLNAME()));

        DefnCache.getMenu((String) Environment.getSystemVar("%Menu").read());

        ComponentBuffer.init(c);
        ComponentBuffer.getSearchRecord().fireEvent(PCEvent.SEARCH_INIT, new FireEventSummary());
        ComponentBuffer.fillSearchRecord();

        ComponentBuffer.assembleBuffers();
        ComponentBuffer.expandRecordBuffersWhereNecessary();
        ComponentBuffer.addEffDtKeyWhereNecessary();
        ComponentBuffer.logPageHierarchyVisual();
        ComponentBuffer.printStructure();
        ComponentStructureVerifier.verify(profileToRun);
        ComponentBuffer.materialize();

        ComponentBuffer.emitPRM();

        ComponentBuffer.firstPassFill();
        ComponentBuffer.fireEvent(PCEvent.PRE_BUILD, new FireEventSummary());
        ComponentBuffer.runRelatedDisplayProcessing();
        ComponentBuffer.runDefaultProcessing();

        ComponentBuffer.fireEvent(PCEvent.ROW_INIT, new FireEventSummary());
        ComponentBuffer.fireEvent(PCEvent.POST_BUILD, new FireEventSummary());

        TraceFileVerifier.logVerificationSummary(false);

    } catch (final OPSVMachRuntimeException opsvmre) {
        log.fatal(opsvmre.getMessage(), opsvmre);
        TraceFileVerifier.logVerificationSummary(true);
        System.exit(1);
    }
}

From source file:com.revo.deployr.client.example.data.io.auth.stateful.exec.RepoFileInGraphicsPlotOut.java

public static void main(String args[]) throws Exception {

    RClient rClient = null;// w w  w. ja  v  a2  s  .com
    RProject rProject = null;

    try {

        /*
         * Determine DeployR server endpoint.
         */
        String endpoint = System.getProperty("endpoint");
        log.info("[ CONFIGURATION  ] Using endpoint=" + endpoint);

        /*
         * Establish RClient connection to DeployR server.
         *
         * An RClient connection is the mandatory starting
         * point for any application using the client library.
         */
        rClient = RClientFactory.createClient(endpoint);

        log.info("[   CONNECTION   ] Established anonymous " + "connection [ RClient ].");

        /*
         * Build a basic authentication token.
         */
        RAuthentication rAuth = new RBasicAuthentication(System.getProperty("username"),
                System.getProperty("password"));

        /*
         * Establish an authenticated handle with the DeployR
         * server, rUser. Following this call the rClient 
         * connection is operating as an authenticated connection
         * and all calls on rClient inherit the access permissions
         * of the authenticated user, rUser.
         */
        RUser rUser = rClient.login(rAuth);
        log.info("[ AUTHENTICATION ] Upgraded to authenticated " + "connection [ RUser ].");

        /*
         * Create a temporary project (R session).
         *
         * Optionally:
         * ProjectCreationOptions options =
         * new ProjectCreationOptions();
         *
         * Populate options as needed, then:
         *
         * rProject = rUser.createProject(options);
         */
        rProject = rUser.createProject();

        log.info("[  GO STATEFUL   ] Created stateful temporary " + "R session [ RProject ].");

        /*
         * Create a ProjectExecutionOptions instance
         * to specify data inputs and output to the
         * execution of the repository-managed R script.
         *
         * This options object can be used to pass standard
         * execution model parameters on execution calls. All
         * fields are optional.
         *
         * See the Standard Execution Model chapter in the
         * Client Library Tutorial on the DeployR website for
         * further details.
         */
        ProjectExecutionOptions options = new ProjectExecutionOptions();

        /* 
         * Preload from the DeployR repository the following
         * data input file:
         * /testuser/example-data-io/hipStar.dat
         */
        ProjectPreloadOptions preloadDirectory = new ProjectPreloadOptions();
        preloadDirectory.filename = "hipStar.dat";
        preloadDirectory.directory = "example-data-io";
        preloadDirectory.author = "testuser";
        options.preloadDirectory = preloadDirectory;

        log.info("[   DATA INPUT   ] Repository data file input set on execution, "
                + "[ ProjectExecutionOptions.preloadDirectory ].");

        /*
         * Execute a public analytics Web service as an authenticated
         * user based on a repository-managed R script:
         * /testuser/example-data-io/dataIO.R
         */
        RProjectExecution exec = rProject.executeScript("dataIO.R", "example-data-io", "testuser", null,
                options);

        log.info("[   EXECUTION    ] Stateful R script " + "execution completed [ RProjectExecution ].");

        /*
         * Retrieve R graphics device plot (result) called
         * unnamedplot*.png that was generated by the execution.
         *
         * Outputs generated by an execution can be used in any
         * number of ways by client applications, including:
         *
         * 1. Use output data to perform further calculations.
         * 2. Display output data to an end-user.
         * 3. Write output data to a database.
         * 4. Pass output data along to another Web service.
         * 5. etc.
         */
        List<RProjectResult> results = exec.about().results;

        for (RProjectResult result : results) {
            log.info("[  DATA OUTPUT   ] Retrieved graphics device " + "plot output " + result.about().filename
                    + " [ RProjectResult ].");
            InputStream fis = null;
            try {
                fis = result.download();
            } catch (Exception ex) {
                log.warn("Graphics device plot download " + ex);
            } finally {
                IOUtils.closeQuietly(fis);
            }
        }

    } catch (Exception ex) {
        log.warn("Unexpected runtime exception=" + ex);
    } finally {
        try {
            if (rProject != null) {
                /*
                 * Close rProject before application exits.
                 */
                rProject.close();
            }
        } catch (Exception fex) {
        }
        try {
            if (rClient != null) {
                /*
                 * Release rClient connection before application exits.
                 */
                rClient.release();
            }
        } catch (Exception fex) {
        }
    }

}

From source file:com.pinterest.terrapin.client.ClientTool.java

public static void main(String[] args) throws Exception {
    PropertiesConfiguration config = new PropertiesConfiguration(System.getProperty("terrapin.config"));
    TerrapinClient client = new TerrapinClient(config, 9090, 1000, 5000);
    String key = args[1];//  w ww  . j  a v  a  2  s.  c o  m
    TerrapinSingleResponse response = client.getOne(args[0], // fileset
            ByteBuffer.wrap(key.getBytes())).get();
    if (response.isSetErrorCode()) {
        System.out.println("Got error " + response.getErrorCode().toString());
    } else if (response.isSetValue()) {
        System.out.println("Got value.");
        System.out.println(new String(response.getValue()));
    } else {
        System.out.println("Key " + key + " not found.");
    }
    System.exit(0);
}

From source file:org.tdmx.server.runtime.ServerLauncher.java

public static void main(String[] args) {
    String javaVersion = System.getProperty("java.version");

    StringTokenizer tokens = new StringTokenizer(javaVersion, ".-_");

    int majorVersion = Integer.parseInt(tokens.nextToken());
    int minorVersion = Integer.parseInt(tokens.nextToken());

    if (majorVersion < 2 && minorVersion < 7) {
        log.error("TDMX-Server requires Java 7 or later.");
        log.error("Your java version is " + javaVersion);
        log.error("Java Home:  " + System.getProperty("java.home"));
        System.exit(-1);/*from   ww w. j  a v a 2 s .  c o m*/
    }

    // Construct the SpringApplication
    BeanFactoryLocator beanFactoryLocator = ContextSingletonBeanFactoryLocator.getInstance();
    BeanFactoryReference beanFactoryReference = beanFactoryLocator.useBeanFactory("applicationContext");
    ApplicationContext context = (ApplicationContext) beanFactoryReference.getFactory();

    SslServerSocketInfo si = (SslServerSocketInfo) context.getBean("server.sslInfo");
    log.info("JVM supportedCipherSuites: "
            + StringUtils.arrayToCommaDelimitedString(si.getSupportedCipherSuites()));
    log.info("JVM supportedProtocols: " + StringUtils.arrayToCommaDelimitedString(si.getSupportedProtocols()));
    log.info("default TrustManagerFactoryAlgorithm: " + si.getDefaultTrustManagerFactoryAlgorithm());

    // Start the Jetty
    ServerContainer sc = (ServerContainer) context.getBean("server.Container");
    sc.runUntilStopped();
}