当前位置: 首页>>代码示例>>Java>>正文


Java EmbeddedServletContainerInitializedEvent类代码示例

本文整理汇总了Java中org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent的典型用法代码示例。如果您正苦于以下问题:Java EmbeddedServletContainerInitializedEvent类的具体用法?Java EmbeddedServletContainerInitializedEvent怎么用?Java EmbeddedServletContainerInitializedEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


EmbeddedServletContainerInitializedEvent类属于org.springframework.boot.context.embedded包,在下文中一共展示了EmbeddedServletContainerInitializedEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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();
}
 
开发者ID:cyejing,项目名称:fast-ngrok,代码行数:23,代码来源:NgrokEmbeddedServletContainerInitializedEventListener.java

示例2: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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)));

}
 
开发者ID:yu199195,项目名称:happylifeplat-transaction,代码行数:11,代码来源:ApplicationStartListener.java

示例3: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
/**
 * 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...");
	}
}
 
开发者ID:jaschenk,项目名称:Your-Microservice,代码行数:17,代码来源:SystemInstanceSetupBean.java

示例4: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
/**
 * 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);
    }
}
 
开发者ID:neozo-software,项目名称:jblockchain,代码行数:37,代码来源:NodeService.java

示例5: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    int httpPort = event.getEmbeddedServletContainer().getPort();
    if (grpcProperties.getRegistryHttpPort() == 0) {
        if (httpPort != 0) {
            grpcProperties.setRegistryHttpPort(httpPort);
        }
    }
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:10,代码来源:WebAppAutoConfiguration.java

示例6: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(final EmbeddedServletContainerInitializedEvent event) {
	try {
		serverPort = event.getEmbeddedServletContainer().getPort();
		serverIp = AitLocalhostIpAddress.search().getHostAddress();
	} catch (final UnknownHostException e) {
		e.printStackTrace();
	}
}
 
开发者ID:allianzit,项目名称:ait-platform,代码行数:10,代码来源:AitTaskExcecutorBase.java

示例7: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@Override
public void onApplicationEvent(EmbeddedServletContainerInitializedEvent event) {
    if (props.isServiceDiscoveryEnabled()) {
        port = event.getEmbeddedServletContainer().getPort();
        init();
    }
}
 
开发者ID:resourcepool,项目名称:dashboard,代码行数:8,代码来源:ServiceDiscovery.java

示例8: getApplicationListenerEmbeddedServletContainerInitializedEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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);
        }
    };
}
 
开发者ID:box,项目名称:mojito,代码行数:13,代码来源:WSTestBase.java

示例9: getApplicationListenerEmbeddedServletContainerInitializedEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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);
        }
    };
}
 
开发者ID:box,项目名称:mojito,代码行数:14,代码来源:CLITestBase.java

示例10: embeddedServletContainerMetricsInitializer

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
/**
 * 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);

        }
    };
}
 
开发者ID:andrewharmellaw,项目名称:springboot-camel-metrics-publisher,代码行数:45,代码来源:MetricsServletConfiguration.java

示例11: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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));
	}
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:EmbeddedServerPortFileWriter.java

示例12: mockEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
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;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:11,代码来源:EmbeddedServerPortFileWriterTests.java

示例13: portGrabber

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@Bean
public ApplicationListener<EmbeddedServletContainerInitializedEvent> portGrabber() {
    List<CallbackUrlListener> listeners = Arrays.asList((CallbackUrlListener)metadataParser, 
            (CallbackUrlListener)downloaderClient);

    DasLocalConfig.callbackUrl = callbackUrlPrivate;

    return new PortGrabber(listeners);
}
 
开发者ID:trustedanalytics,项目名称:data-acquisition,代码行数:10,代码来源:DasLocalConfig.java

示例14: initialize

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@Override
public void initialize(ConfigurableApplicationContext applicationContext) {
	applicationContext.addApplicationListener(
			new ApplicationListener<EmbeddedServletContainerInitializedEvent>() {
				@Override
				public void onApplicationEvent(
						EmbeddedServletContainerInitializedEvent event) {
					ServerPortInfoApplicationContextInitializer.this
							.onApplicationEvent(event);
				}
			});
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:13,代码来源:ServerPortInfoApplicationContextInitializer.java

示例15: onApplicationEvent

import org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent; //导入依赖的package包/类
@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);
	}
}
 
开发者ID:BGehrels,项目名称:singleTransferableVoteElections-web,代码行数:9,代码来源:ServerStartedMessagePrintingListener.java


注:本文中的org.springframework.boot.context.embedded.EmbeddedServletContainerInitializedEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。