Package javarepl.examples

Source Code of javarepl.examples.EmbedInApplication

package javarepl.examples;

import javarepl.console.ConsoleConfig;
import javarepl.console.SimpleConsole;
import javarepl.console.commands.EvaluateFromHistory;
import javarepl.console.commands.ListValues;
import javarepl.console.commands.SearchHistory;
import javarepl.console.commands.ShowHistory;
import javarepl.console.rest.RestConsole;

import java.io.File;
import java.util.Date;

import static java.lang.System.getProperty;
import static javarepl.Result.result;
import static javarepl.console.ConsoleConfig.consoleConfig;

/**
* Example shows how to embed JavaREPL inside your application. Note that your application needs to be running via JDK
* for the JavaREPL to work.
*/
public class EmbedInApplication {
    public static void main(String... args) throws Exception {
        ConsoleConfig config = consoleConfig()
                .historyFile(new File(getProperty("user.home"), ".javarepl-embedded.history"))
                .commands(
                        ListValues.class,
                        ShowHistory.class,
                        EvaluateFromHistory.class,
                        SearchHistory.class)
                .results(
                        result("date", new Date()),
                        result("num", 42));

        new RestConsole(new SimpleConsole(config), 8001);
    }
}
TOP

Related Classes of javarepl.examples.EmbedInApplication

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.