Example usage for java.util UUID randomUUID

List of usage examples for java.util UUID randomUUID

Introduction

In this page you can find the example usage for java.util UUID randomUUID.

Prototype

public static UUID randomUUID() 

Source Link

Document

Static factory to retrieve a type 4 (pseudo randomly generated) UUID.

Usage

From source file:net.doubledoordev.backend.Main.java

public static void main(String[] args) throws Exception {
    System.setProperty("file.encoding", "UTF-8");
    Field charset = Charset.class.getDeclaredField("defaultCharset");
    charset.setAccessible(true);//  w w w .  j  a  va 2 s.co  m
    charset.set(null, null);

    for (String arg : args) {
        if (arg.equalsIgnoreCase("debug"))
            debug = true;
    }

    LOGGER.info("\n\n    D3Backend  Copyright (C) 2015  Dries007 & Double Door Development\n"
            + "    This program comes with ABSOLUTELY NO WARRANTY;\n"
            + "    This is free software, and you are welcome to redistribute it under certain conditions;\n"
            + "    Type `license' for details.\n\n");

    LOGGER.info("Making necessary folders...");
    mkdirs();
    LOGGER.info("Starting webserver...");

    final HttpServer webserver = new HttpServer();
    final ServerConfiguration config = webserver.getServerConfiguration();

    // Html stuff
    freemarkerHandler = new FreemarkerHandler(Main.class, TEMPLATES_PATH);
    config.addHttpHandler(freemarkerHandler);
    config.setDefaultErrorPageGenerator(freemarkerHandler);
    config.addHttpHandler(new CLStaticHttpHandler(Main.class.getClassLoader(), STATIC_PATH), STATIC_PATH);
    config.addHttpHandler(new ServerFileHandler(P2S_PATH), P2S_PATH);
    config.addHttpHandler(new ServerFileHandler(), RAW_PATH);

    // Socket stuff
    ServerMonitorSocketApplication.register();
    ServerControlSocketApplication.register();
    ServerPropertiesSocketApplication.register();
    FileManagerSocketApplication.register();
    ServerconsoleSocketApplication.register();
    ConsoleSocketApplication.register();
    AdvancedSettingsSocketApplication.register();
    UsersSocketApplication.register();

    final NetworkListener networkListener = new NetworkListener("listener",
            Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
            Strings.isNotBlank(SETTINGS.certificatePath) ? SETTINGS.portHTTPS : SETTINGS.portHTTP);
    if (Strings.isNotBlank(SETTINGS.certificatePath)) {
        networkListener.setSecure(true);
        networkListener.setSSLEngineConfig(createSslConfiguration());
        webserver.addListener(new NetworkListener("redirect-listener",
                Strings.isBlank(SETTINGS.hostname) ? NetworkListener.DEFAULT_NETWORK_HOST : SETTINGS.hostname,
                SETTINGS.portHTTP));
    }
    webserver.addListener(networkListener);
    networkListener.registerAddOn(new WebSocketAddOn());
    webserver.start();

    LOGGER.info("Setting up caching...");
    Cache.init();

    if (SETTINGS.users.isEmpty()) {
        adminKey = UUID.randomUUID().toString();
        LOGGER.warn("Your userlist is empty.");
        LOGGER.warn("Make a new account and use the special admin token in the '2 + 2 = ?' field.");
        LOGGER.warn(
                "You can only use this key once. It will be regenerated if the userlist is empty when the backend starts.");
        LOGGER.warn("Admin token: " + adminKey);
    }

    LOGGER.info("Use the help command for help.");

    CommandHandler.init();
    for (Server server : SETTINGS.servers.values()) {
        server.init();
        if (server.getRestartingInfo().autoStart) {
            try {
                server.startServer();
            } catch (Exception ignored) {
                ignored.printStackTrace();
            }
        }
    }
}

From source file:co.turnus.analysis.buffers.MpcBoundedSchedulingCliLauncher.java

public static void main(String[] args) {
    try {/*from   www.  j  a  v  a2 s.  co  m*/
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(cliOptions, args);
        Configuration config = parseCommandLine(cmd);

        // init models
        AnalysisActivator.init();

        // set logger verbosity
        if (config.getBoolean(VERBOSE, false)) {
            TurnusLogger.setLevel(TurnusLevel.ALL);
        }

        File tDir = new File(config.getString(TRACE_PROJECT));
        TraceProject project = TraceProject.load(tDir);

        MpcBoundedScheduling mpc = new MpcBoundedScheduling(project);
        mpc.setConfiguration(config);
        BufferMinimizationData data = mpc.run();

        TurnusLogger.info("Storing results...");
        File outPath = new File(config.getString(OUTPUT_PATH));

        // store the analysis report
        String uuid = UUID.randomUUID().toString();
        File rFile = new File(outPath, uuid + "." + TurnusExtension.REPORT);
        Report report = DataFactory.eINSTANCE.createReport();
        report.setDate(new Date());
        report.setComment("Report with only Bounded Buffer Scheduling results analysis");
        report.getDataSet().add(data);
        EcoreHelper.storeEObject(report, new ResourceSetImpl(), rFile);
        TurnusLogger.info("TURNUS report stored in " + rFile);

        // store formatted reports
        String xlsName = config.getString(XLS, "");
        if (!xlsName.isEmpty()) {
            File xlsFile = new File(outPath, xlsName + ".xls");
            new XlsBufferMinimizationDataWriter().write(data, xlsFile);
            TurnusLogger.info("XLS report stored in " + xlsFile);
        }

        String bxdfName = config.getString(BXDF, "");
        if (!bxdfName.isEmpty()) {
            File bxdfFile = new File(outPath, bxdfName + ".bxdf");
            new XmlBufferMinimizationDataWriter().write(data, bxdfFile);
            TurnusLogger.info("BXDF files (one for each configuration) " + "stored in " + outPath);
        }

        TurnusLogger.info("Analysis Done!");

    } catch (ParseException e) {
        TurnusLogger.error(e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(AlgorithmicBottlenecksCliLauncher.class.getSimpleName(), cliOptions);
    } catch (Exception e) {
        TurnusLogger.error(e.getMessage());
    }
}

From source file:Main.java

public static String uuid() {
    return UUID.randomUUID().toString();
}

From source file:Main.java

public static String uuid() {
    return UUID.randomUUID().toString().replace("-", "").toUpperCase();
}

From source file:Main.java

public static String getUUID() {
    return UUID.randomUUID().toString().replace("-", "");
}

From source file:Main.java

private static String getUuid() {
    return UUID.randomUUID().toString().trim().replaceAll("-", "");
}

From source file:Main.java

private static String getUUID() {
    return UUID.randomUUID().toString().replace("-", "");
}

From source file:Main.java

public static String GetGUID() {
    return UUID.randomUUID().toString();
}

From source file:Main.java

public static String getUUID() {
    return UUID.randomUUID().toString().replace("-", "").toLowerCase();
}

From source file:Main.java

public static String getUUId() {
    return UUID.randomUUID().toString();
}