@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { int port = event.getSource().getPort(); String serverAddress = ngrokProperties.getServerAddress(); int serverPort = ngrokProperties.getServerPort(); String subdomain = ngrokProperties.getSubdomain(); String hostname = ngrokProperties.getHostname(); String proto = ngrokProperties.getProto(); int remotePort = ngrokProperties.getRemotePort(); String httpAuth = ngrokProperties.getHttpAuth(); Tunnel tunnel = new Tunnel.TunnelBuild() .setPort(port) .setProto(proto) .setSubDomain(subdomain) .setHostname(hostname) .setRemotePort(remotePort) .setHttpAuth(httpAuth) .build(); new NgrokClient(serverAddress, serverPort) .addTunnel(tunnel).start(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { int port = event.getEmbeddedServletContainer().getPort(); final String host = getHost(); Address.getInstance() .setHost(host) .setPort(port) .setDomain(String.join(":", host, String.valueOf(port))); }
/** * Trap applicable Application Events. * * @param applicationEvent Application Event to be processed. */ @Override public void onApplicationEvent(ApplicationEvent applicationEvent) { if (applicationEvent instanceof EmbeddedServletContainerInitializedEvent) { hostPortUsed = ((EmbeddedServletContainerInitializedEvent) applicationEvent). getEmbeddedServletContainer().getPort(); LOGGER.info("onApplicationEvent Fired, System Port Identity:[{}]", hostPortUsed); } else if (applicationEvent instanceof ContextClosedEvent) { LOGGER.info("onApplicationEvent for ContextClosedEvent..."); } }
/** * Initial setup, query master Node for * - Other Nodes * - All Addresses * - Current Blockchain * - Transactions in pool * and publish self on all other Nodes * @param embeddedServletContainerInitializedEvent serverletContainer for port retrieval */ @Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) { Node masterNode = getMasterNode(); // construct self node String host = retrieveSelfExternalHost(masterNode, restTemplate); int port = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer().getPort(); self = getSelfNode(host, port); LOG.info("Self address: " + self.getAddress()); // download data if necessary if (self.equals(masterNode)) { LOG.info("Running as master node, nothing to init"); } else { knownNodes.add(masterNode); // retrieve data retrieveKnownNodes(masterNode, restTemplate); addressService.retrieveAddresses(masterNode, restTemplate); blockService.retrieveBlockchain(masterNode, restTemplate); transactionService.retrieveTransactions(masterNode, restTemplate); // publish self broadcastPut("node", self); } }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { int httpPort = event.getEmbeddedServletContainer().getPort(); if (grpcProperties.getRegistryHttpPort() == 0) { if (httpPort != 0) { grpcProperties.setRegistryHttpPort(httpPort); } } }
@Override public void onApplicationEvent(final EmbeddedServletContainerInitializedEvent event) { try { serverPort = event.getEmbeddedServletContainer().getPort(); serverIp = AitLocalhostIpAddress.search().getHostAddress(); } catch (final UnknownHostException e) { e.printStackTrace(); } }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { if (props.isServiceDiscoveryEnabled()) { port = event.getEmbeddedServletContainer().getPort(); init(); } }
@Bean public ApplicationListener<EmbeddedServletContainerInitializedEvent> getApplicationListenerEmbeddedServletContainerInitializedEvent() { return new ApplicationListener<EmbeddedServletContainerInitializedEvent>() { @Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { int serverPort = event.getEmbeddedServletContainer().getPort(); logger.debug("Saving port number = {}", serverPort); resttemplateConfig.setPort(serverPort); } }; }
/** * Initialise the embedded servlet container metrics reporting. * * @return An ApplicationListener which will register a MetricsPublisher when the Servlet container is * initialised */ @Bean public ApplicationListener<EmbeddedServletContainerInitializedEvent> embeddedServletContainerMetricsInitializer() { final MetricRegistry registry = codahaleMetricsRegistry(); return new ApplicationListener<EmbeddedServletContainerInitializedEvent>() { @Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) { EmbeddedServletContainer initializedServletContainer = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer(); if (initializedServletContainer == null) { LOGGER.error("The EmbeddedServletContainer obtained from the EmbeddedServletContainerInitializedEvent was null; metrics will not be published"); return; } int serverPort = initializedServletContainer.getPort(); LOGGER.info("Initialising MetricsPublisher on port {}", serverPort); TomcatMetricsPublisher.forRegistry(registry) .serverPortIs(serverPort) .start(); // register the graphite reporter Statsd statsd = new Statsd(metricsReporterHost, metricsReporterPort); StatsdReporter statsdReporter = StatsdReporter.forRegistry(registry) .prefixedWith(metricsPrefix + serverPort) .convertDurationsTo(TimeUnit.MILLISECONDS) .convertRatesTo(TimeUnit.SECONDS) .filter(new ConfigurableCodaHaleMetricFilter(DynamicPropertyFactory.getInstance())) .build(statsd); statsdReporter.start(pollingPeriodInSeconds, TimeUnit.SECONDS); } }; }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { File portFile = getPortFile(event.getApplicationContext()); try { String port = String.valueOf(event.getEmbeddedServletContainer().getPort()); createParentFolder(portFile); FileCopyUtils.copy(port.getBytes(), portFile); portFile.deleteOnExit(); } catch (Exception ex) { logger.warn(String.format("Cannot create port file %s", this.file)); } }
private EmbeddedServletContainerInitializedEvent mockEvent(String name, int port) { EmbeddedWebApplicationContext applicationContext = mock( EmbeddedWebApplicationContext.class); EmbeddedServletContainer source = mock(EmbeddedServletContainer.class); given(applicationContext.getNamespace()).willReturn(name); given(source.getPort()).willReturn(port); EmbeddedServletContainerInitializedEvent event = new EmbeddedServletContainerInitializedEvent( applicationContext, source); return event; }
@Bean public ApplicationListener<EmbeddedServletContainerInitializedEvent> portGrabber() { List<CallbackUrlListener> listeners = Arrays.asList((CallbackUrlListener)metadataParser, (CallbackUrlListener)downloaderClient); DasLocalConfig.callbackUrl = callbackUrlPrivate; return new PortGrabber(listeners); }
@Override public void initialize(ConfigurableApplicationContext applicationContext) { applicationContext.addApplicationListener( new ApplicationListener<EmbeddedServletContainerInitializedEvent>() { @Override public void onApplicationEvent( EmbeddedServletContainerInitializedEvent event) { ServerPortInfoApplicationContextInitializer.this .onApplicationEvent(event); } }); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent o) { LOG.info("Die Wahlauszählung kann beginnen. Die Eingabemaske ist nun unter den folgenden URLs erreichbar:"); for (URI uri : getAllHostNameUrls(o.getEmbeddedServletContainer().getPort())) { LOG.info("{}", uri); } }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { int serverPort = event.getEmbeddedServletContainer().getPort(); String ip = getIp(); Constants.address = ip+":"+serverPort; }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { this.serverPort = event.getEmbeddedServletContainer().getPort(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { this.registerCenter4Provider.registerServer(buildServerDto()); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent e) { localPort = e.getEmbeddedServletContainer().getPort(); logger.info("after runtime init, local server port: {}", localPort); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { // 可以做一些参数的监测,如果不合格的话,直接stop // event.getEmbeddedServletContainer().stop(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { this.port = event.getEmbeddedServletContainer().getPort(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { if (event.getApplicationContext() != this.rootContext) { this.servletContainer = event.getEmbeddedServletContainer(); } }
@Override public void onApplicationEvent( EmbeddedServletContainerInitializedEvent event) { this.port = event.getEmbeddedServletContainer().getPort(); }
@EventListener(EmbeddedServletContainerInitializedEvent.class) public void grabPort(EmbeddedServletContainerInitializedEvent event) { this.port = event.getEmbeddedServletContainer().getPort(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) { this.port = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer().getPort(); LOG.debug("Discovered web container port to be {}", this.port); }
@Override public void onApplicationEvent( EmbeddedServletContainerInitializedEvent event) { port = event.getEmbeddedServletContainer().getPort(); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) { port = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer().getPort(); httpEndpoint = "http://" + address + ":" + port; LOG.info("Server is running on port " + port); }
@Override public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) { for (CallbackUrlListener l: listeners) { l.setCallbacksUrl(callbackUrl); } }