use of org.apache.tapestry5.ioc.services.ServiceActivityScoreboard in project tapestry-5 by apache.
the class TapestryAppInitializer method announceStartup.
/**
* Announce application startup, by logging (at INFO level) the names of all pages,
* components, mixins and services.
*/
public void announceStartup() {
if (// if info logging is off we can stop now
!logger.isInfoEnabled()) {
return;
}
long toFinish = System.currentTimeMillis();
SymbolSource source = registry.getService("SymbolSource", SymbolSource.class);
StringBuilder buffer = new StringBuilder("Startup status:\n\nServices:\n\n");
Formatter f = new Formatter(buffer);
int unrealized = 0;
ServiceActivityScoreboard scoreboard = registry.getService(ServiceActivityScoreboard.class);
List<ServiceActivity> serviceActivity = scoreboard.getServiceActivity();
int longest = 0;
for (ServiceActivity activity : serviceActivity) {
Status status = activity.getStatus();
longest = Math.max(longest, activity.getServiceId().length());
if (status == Status.DEFINED || status == Status.VIRTUAL)
unrealized++;
}
String formatString = "%" + longest + "s: %s\n";
for (ServiceActivity activity : serviceActivity) {
f.format(formatString, activity.getServiceId(), activity.getStatus().name());
}
f.format("\n%4.2f%% unrealized services (%d/%d)\n", 100. * unrealized / serviceActivity.size(), unrealized, serviceActivity.size());
f.format("\nApplication '%s' (version %s) startup time: %,d ms to build IoC Registry, %,d ms overall.", appName, source.valueForSymbol(TapestryHttpSymbolConstants.APPLICATION_VERSION), registryCreatedTime - startTime, toFinish - startTime);
String version = source.valueForSymbol(TapestryHttpSymbolConstants.TAPESTRY_VERSION);
boolean productionMode = Boolean.parseBoolean(source.valueForSymbol(TapestryHttpSymbolConstants.PRODUCTION_MODE));
buffer.append("\n\n");
buffer.append(" ______ __ ____\n");
buffer.append("/_ __/__ ____ ___ ___ / /_______ __ / __/\n");
buffer.append(" / / / _ `/ _ \\/ -_|_-</ __/ __/ // / /__ \\ \n");
buffer.append("/_/ \\_,_/ .__/\\__/___/\\__/_/ \\_, / /____/\n");
f.format(" /_/ /___/ %s%s\n\n", version, productionMode ? "" : " (development mode)");
// log multi-line string with OS-specific line endings (TAP5-2294)
logger.info(buffer.toString().replaceAll("\\n", System.getProperty("line.separator")));
}
Aggregations