Java 类org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent 实例源码

项目:fast-ngrok    文件:NgrokEmbeddedServletContainerInitializedEventListener.java   
@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();
}
项目:happylifeplat-transaction    文件:ApplicationStartListener.java   
@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)));

}
项目:Your-Microservice    文件:SystemInstanceSetupBean.java   
/**
 * 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...");
    }
}
项目:jblockchain    文件:NodeService.java   
/**
 * 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);
    }
}
项目:saluki    文件:WebAppAutoConfiguration.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    int httpPort = event.getEmbeddedServletContainer().getPort();
    if (grpcProperties.getRegistryHttpPort() == 0) {
        if (httpPort != 0) {
            grpcProperties.setRegistryHttpPort(httpPort);
        }
    }
}
项目:ait-platform    文件:AitTaskExcecutorBase.java   
@Override
public void onApplicationEvent(final EmbeddedServletContainerInitializedEvent event) {
    try {
        serverPort = event.getEmbeddedServletContainer().getPort();
        serverIp = AitLocalhostIpAddress.search().getHostAddress();
    } catch (final UnknownHostException e) {
        e.printStackTrace();
    }
}
项目:dashboard    文件:ServiceDiscovery.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    if (props.isServiceDiscoveryEnabled()) {
        port = event.getEmbeddedServletContainer().getPort();
        init();
    }
}
项目:mojito    文件:WSTestBase.java   
@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);
        }
    };
}
项目:mojito    文件:CLITestBase.java   
@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);
        }
    };
}
项目:springboot-camel-metrics-publisher    文件:MetricsServletConfiguration.java   
/**
 * 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);

        }
    };
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedServerPortFileWriter.java   
@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));
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedServerPortFileWriterTests.java   
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;
}
项目:spring-boot-concourse    文件:EmbeddedServerPortFileWriter.java   
@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));
    }
}
项目:spring-boot-concourse    文件:EmbeddedServerPortFileWriterTests.java   
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;
}
项目:data-acquisition    文件:DasLocalConfig.java   
@Bean
public ApplicationListener<EmbeddedServletContainerInitializedEvent> portGrabber() {
    List<CallbackUrlListener> listeners = Arrays.asList((CallbackUrlListener)metadataParser, 
            (CallbackUrlListener)downloaderClient);

    DasLocalConfig.callbackUrl = callbackUrlPrivate;

    return new PortGrabber(listeners);
}
项目:contestparser    文件:ServerPortInfoApplicationContextInitializer.java   
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
    applicationContext.addApplicationListener(
            new ApplicationListener<EmbeddedServletContainerInitializedEvent>() {
                @Override
                public void onApplicationEvent(
                        EmbeddedServletContainerInitializedEvent event) {
                    ServerPortInfoApplicationContextInitializer.this
                            .onApplicationEvent(event);
                }
            });
}
项目:contestparser    文件:EmbeddedServerPortFileWriter.java   
@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));
    }
}
项目:contestparser    文件:EmbeddedServerPortFileWriterTests.java   
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;
}
项目:singleTransferableVoteElections-web    文件:ServerStartedMessagePrintingListener.java   
@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);
    }
}
项目:tx-lcn    文件:ApplicationStartListener.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    int serverPort = event.getEmbeddedServletContainer().getPort();
    String ip = getIp();
    Constants.address = ip+":"+serverPort;
}
项目:tx-lcn    文件:ServerListener.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.serverPort = event.getEmbeddedServletContainer().getPort();
}
项目:elephant    文件:BeanAutoConfiguration.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.registerCenter4Provider.registerServer(buildServerDto());
}
项目:karate    文件:ServerStartedInitializingBean.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent e) {
    localPort = e.getEmbeddedServletContainer().getPort();
    logger.info("after runtime init, local server port: {}", localPort);
}
项目:karate    文件:ServerStartedInitializingBean.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent e) {
    localPort = e.getEmbeddedServletContainer().getPort();
    logger.info("after runtime init, local server port: {}", localPort);
}
项目:springboot-analysis    文件:CustomWebListener.java   
@Override
    public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
        // 可以做一些参数的监测,如果不合格的话,直接stop
//        event.getEmbeddedServletContainer().stop();
    }
项目:kubernetes-zipkin    文件:HelloController.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EndpointWebMvcAutoConfigurationTests.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    if (event.getApplicationContext() != this.rootContext) {
        this.servletContainer = event.getEmbeddedServletContainer();
    }
}
项目:Zipkin    文件:SampleController.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:SampleController.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:SampleController.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:SampleService.java   
@Override public void onApplicationEvent(
        EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:ServerPropertiesEndpointLocator.java   
@EventListener(EmbeddedServletContainerInitializedEvent.class)
public void grabPort(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:TraceFilterCustomExtractorTests.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:SleuthBenchmarkingSpringApp.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:Zipkin    文件:ServerPropertiesHostLocator.java   
@EventListener(EmbeddedServletContainerInitializedEvent.class)
public void grabPort(EmbeddedServletContainerInitializedEvent event) {
    this.port = event.getEmbeddedServletContainer().getPort();
}
项目:spring-boot-concourse    文件:EndpointWebMvcAutoConfigurationTests.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    if (event.getApplicationContext() != this.rootContext) {
        this.servletContainer = event.getEmbeddedServletContainer();
    }
}
项目:mccy-engine    文件:WebServerPortProviderImpl.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) {
    this.port = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer().getPort();
    LOG.debug("Discovered web container port to be {}", this.port);
}
项目:example-restful-project    文件:PortHolder.java   
@Override
public void onApplicationEvent(
        EmbeddedServletContainerInitializedEvent event) {
    port = event.getEmbeddedServletContainer().getPort();
}
项目:fnf.clientapi    文件:EndpointService.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent embeddedServletContainerInitializedEvent) {
    port = embeddedServletContainerInitializedEvent.getEmbeddedServletContainer().getPort();
    httpEndpoint = "http://" + address + ":" + port;
    LOG.info("Server is running on port " + port);
}
项目:data-acquisition    文件:DasLocalConfig.java   
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    for (CallbackUrlListener l: listeners) {
        l.setCallbacksUrl(callbackUrl);
    }
}