use of org.glassfish.grizzly.utils.Futures in project Payara by payara.
the class GrizzlyService method postConstruct.
/**
* The component has been injected with any dependency and
* will be placed into commission by the subsystem.
*/
@Override
public void postConstruct() {
events.register(this);
final NetworkConfig networkConfig = config.getNetworkConfig();
configListener = new DynamicConfigListener(config, LOGGER);
ObservableBean bean = (ObservableBean) ConfigSupport.getImpl(networkConfig.getNetworkListeners());
bean.addListener(configListener);
bean = (ObservableBean) ConfigSupport.getImpl(config.getHttpService());
bean.addListener(configListener);
transactions.addListenerForType(SystemProperty.class, configListener);
configListener.setGrizzlyService(this);
try {
boolean isAtLeastOneProxyStarted = false;
futures = new ArrayList<>();
// Record how long it took for the listeners to start up
final long startTime = System.currentTimeMillis();
// Keep a list of successfully started listeners
List<NetworkListener> startedListeners = new ArrayList<>();
for (NetworkListener listener : networkConfig.getNetworkListeners().getNetworkListener()) {
if (createNetworkProxy(listener) != null) {
isAtLeastOneProxyStarted = true;
startedListeners.add(listener);
}
}
if (isAtLeastOneProxyStarted) {
// Get the startup time
final long startupTime = System.currentTimeMillis() - startTime;
// Log the listeners which started.
String boundAddresses = Arrays.toString(startedListeners.stream().map(listener -> listener.getName() + ":" + getRealPort(listener)).collect(Collectors.toList()).toArray());
LOGGER.log(Level.INFO, KernelLoggerInfo.grizzlyStarted, new Object[] { Grizzly.getDotedVersion(), startupTime, boundAddresses });
registerContainerAdapters();
}
} catch (RuntimeException e) {
// So far postConstruct can not throw any other exception type
LOGGER.log(Level.SEVERE, KernelLoggerInfo.grizzlyCantStart, e);
for (NetworkProxy proxy : proxies) {
try {
proxy.stop();
} catch (Exception proxyStopException) {
LOGGER.log(Level.SEVERE, KernelLoggerInfo.grizzlyCloseException, new Object[] { proxy.getPort(), proxyStopException });
}
}
throw e;
}
registerMonitoringStatsProviders();
}
Aggregations