public static String buildStatusResponse() { return "{\n \"status\":\"ok\"\n \"version\":\"" + MetaUtil.readVersion() + "\"\n}"; }
public static Properties readMetaProperties() { if (isNull(metaProperties)) { metaProperties = new Properties(); try (InputStream properties = getClassLoader().getResourceAsStream(METADATA_PROPERTIES)) { if (!isNull(properties)) { metaProperties.load(properties); } } catch (IOException e) { LOGGER.warn("Error reading metadata properties from {} - continuing", METADATA_PROPERTIES, e); } } return metaProperties; }
private void startServer(String[] originalArgs) { InjectorUtil.create(new BootstrapModule()).injectMembers(this); if (isNull(pluginClassNames) || 0 == pluginClassNames.length) { LOGGER.debug("No plugins specified - attempting to load defaults"); // check for list of comma-separated plugin classes to load if none specified pluginClassNames = ofNullable(MetaUtil.readMetaProperties().getProperty("plugins")) .map(plugin -> plugin.split(",")) .orElse(new String[0]); } final Map<String, String> splitArgs = Arrays.stream(ofNullable(pluginArgs).orElse(new String[0])) .map(arg -> arg.split("=")) .collect(Collectors.toMap(splitArg -> splitArg[0], splitArg -> splitArg[1])); imposterConfig.setConfigDirs(configDirs); imposterConfig.setPluginClassNames(pluginClassNames); imposterConfig.setListenPort(listenPort); imposterConfig.setHost(host); imposterConfig.setServerUrl(serverUrl); imposterConfig.setTlsEnabled(tlsEnabled); imposterConfig.setKeystorePath(keystorePath); imposterConfig.setKeystorePassword(keystorePassword); imposterConfig.setPluginArgs(splitArgs); final List<String> args = Lists.newArrayList(originalArgs); args.add(0, "run"); args.add(1, ImposterVerticle.class.getCanonicalName()); super.dispatch(args.toArray(new String[args.size()])); }
public static String readVersion() { if (isNull(version)) { try { final Enumeration<URL> manifests = getClassLoader().getResources(METADATA_MANIFEST); while (manifests.hasMoreElements() && isNull(version)) { try (final InputStream manifestStream = manifests.nextElement().openStream()) { final Manifest manifest = new Manifest(manifestStream); version = manifest.getMainAttributes().getValue(MANIFEST_VERSION_KEY); } } } catch (IOException ignored) { } version = Optional.ofNullable(version).orElse("unknown"); } return version; }
private void printVersion() { System.out.println("Version: " + MetaUtil.readVersion()); }