/** * Construct a new {@link JavaVirtualMachine}. * This constructor is private as the {@link JavaVirtualMachine} * platform is a singleton as there is only one local JVM. */ private JavaVirtualMachine() { super("Java Virtual Machine"); // ----- establish InetAddress of the LocalPlatform ----- // attempt to use the system property that may have been defined // (in the future we may use a PlatformAddress Option to achieve this) String addressSystemProperty = System.getProperty("bedrock.runtime.address"); if (addressSystemProperty == null) { this.address = NetworkHelper.getFeasibleLocalHost(); } else { try { this.address = InetAddress.getByName(addressSystemProperty); } catch (UnknownHostException e) { // TODO: log that the specified address can't be resolved, defaulting to the feasible localhost this.address = NetworkHelper.getFeasibleLocalHost(); } } }
/** * Construct a new {@link JavaVirtualMachine}. * This constructor is private as the {@link JavaVirtualMachine} * platform is a singleton as there is only one local JVM. */ private JavaVirtualMachine() { super("Java Virtual Machine"); // ----- establish InetAddress of the LocalPlatform ----- // attempt to use the system property that may have been defined // (in the future we may use a PlatformAddress Option to achieve this) String addressSystemProperty = System.getProperty("bedrock.runtime.address"); if (addressSystemProperty == null) { this.address = NetworkHelper.getFeasibleLocalHost(); } else { try { this.address = InetAddress.getByName(addressSystemProperty); } catch (UnknownHostException e) { // TODO: log that the specified address can't be resolved, defaulting to the feasible localhost this.address = NetworkHelper.getFeasibleLocalHost(); } } }
this.address = NetworkHelper.getFeasibleLocalHost(); this.address = NetworkHelper.getFeasibleLocalHost();
this.address = NetworkHelper.getFeasibleLocalHost(); this.address = NetworkHelper.getFeasibleLocalHost();
/** * Start the HTTP server that will be used to serve the artifacts * to be deployed. * * @param executor the {@link Executor} to pass to the {@link HttpServer} * @param artifacts a {@link Map} of {@link DeploymentArtifact}s to deploy * keyed by the URL path for each artifact * * @return the {@link HttpServer} */ protected HttpServer createServer(ExecutorService executor, Map<String, DeploymentArtifact> artifacts) { try { LocalPlatform platform = LocalPlatform.get(); InetAddress address = NetworkHelper.getFeasibleLocalHost(); int port = platform.getAvailablePorts().next(); HttpServer server = HttpServer.create(new InetSocketAddress(address, port), 0); server.createContext("/", new ArtifactsHandler(artifacts, optionsByType.asArray())); server.setExecutor(executor); server.start(); return server; } catch (IOException e) { throw new RuntimeException("Unable to create HTTP server", e); } }