/** * Writes System OS and JVM properties. * @param writer Writer to render to */ protected void serverinfo(PrintWriter writer) { if (debug >= 1) log("serverinfo"); try { StringBuffer props = new StringBuffer(); props.append("OK - Server info"); props.append("\nTomcat Version: "); props.append(ServerInfo.getServerInfo()); props.append("\nOS Name: "); props.append(System.getProperty("os.name")); props.append("\nOS Version: "); props.append(System.getProperty("os.version")); props.append("\nOS Architecture: "); props.append(System.getProperty("os.arch")); props.append("\nJVM Version: "); props.append(System.getProperty("java.runtime.version")); props.append("\nJVM Vendor: "); props.append(System.getProperty("java.vm.vendor")); writer.println(props.toString()); } catch (Throwable t) { getServletContext().log("ManagerServlet.serverinfo",t); writer.println(sm.getString("managerServlet.exception", t.toString())); } }
/** * Writes System OS and JVM properties. * * @param writer Writer to render to */ protected void serverinfo(final PrintWriter writer) { if (debug >= 1) { log("serverinfo"); } try { final StringBuffer props = new StringBuffer(100); props.append("Tomcat Version: "); props.append(ServerInfo.getServerInfo()); props.append("\nOS Name: "); props.append(System.getProperty("os.name")); props.append("\nOS Version: "); props.append(System.getProperty("os.version")); props.append("\nOS Architecture: "); props.append(System.getProperty("os.arch")); props.append("\nJVM Version: "); props.append(System.getProperty("java.runtime.version")); props.append("\nJVM Vendor: "); props.append(System.getProperty("java.vm.vendor")); writer.println(props.toString()); } catch (Throwable t) { getServletContext().log("ManagerServlet.serverinfo", t); writer.println(sm.getString("managerServlet.exception", t.toString())); } }
/** * Writes System OS and JVM properties. * * @param writer * Writer to render to */ protected void serverinfo(PrintWriter writer, StringManager smClient) { if (debug >= 1) log("serverinfo"); try { StringBuilder props = new StringBuilder(); props.append("OK - Server info"); props.append("\nTomcat Version: "); props.append(ServerInfo.getServerInfo()); props.append("\nOS Name: "); props.append(System.getProperty("os.name")); props.append("\nOS Version: "); props.append(System.getProperty("os.version")); props.append("\nOS Architecture: "); props.append(System.getProperty("os.arch")); props.append("\nJVM Version: "); props.append(System.getProperty("java.runtime.version")); props.append("\nJVM Vendor: "); props.append(System.getProperty("java.vm.vendor")); writer.println(props.toString()); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getServletContext().log("ManagerServlet.serverinfo", t); writer.println(smClient.getString("managerServlet.exception", t.toString())); } }
public boolean start() throws ContainerException { // load the web applications loadComponents(); // Start the Tomcat server try { tomcat.getServer().start(); } catch (LifecycleException e) { throw new ContainerException(e); } for (Connector con: tomcat.getService().findConnectors()) { Debug.logInfo("Connector " + con.getProtocol() + " @ " + con.getPort() + " - " + (con.getSecure() ? "secure" : "not-secure") + " [" + con.getProtocolHandlerClassName() + "] started.", module); } Debug.logInfo("Started " + ServerInfo.getServerInfo(), module); return true; }
/** * The process message is responsible for processing an incoming serviceTask and generate * a response based on the incoming serviceTask input * @param serviceTask The serviceTask that will be processed by the service * @return A result based on the processed incoming serviceTask * @see ServiceTask * @see ServiceResult */ @Override public ServiceResult<GetSystemInformationOutput> process(final ServiceTask<GetSystemInformationInput> serviceTask) { final SystemInformationDto systemInformation = new SystemInformationDto(); systemInformation.setJavaVersion(System.getProperty("java.version")); systemInformation.setJavaVendor(System.getProperty("java.vendor")); systemInformation.setOperatingSystemName(System.getProperty("os.name")); systemInformation.setTomcatBuilt(ServerInfo.getServerBuilt()); systemInformation.setTomcatInfo(ServerInfo.getServerInfo()); systemInformation.setTomcatVersion(ServerInfo.getServerNumber()); systemInformation.setAvailableProcessors(Runtime.getRuntime().availableProcessors()); systemInformation.setTotalMemory(Runtime.getRuntime().totalMemory() / 1000000); // Megabytes systemInformation.setMaxMemory(Runtime.getRuntime().maxMemory() / 1000000); // Megabytes systemInformation.setFreeMemory(Runtime.getRuntime().freeMemory() / 1000000); // Megabytes systemInformation.setCastleMockHomeDirectory(this.castleMockHomeDirectory); final GetSystemInformationOutput output = new GetSystemInformationOutput(systemInformation); return createServiceResult(output); }
private ServiceRegistration publishServerAsAService(StandardService server) { Properties props = new Properties(); // put some extra properties to easily identify the service props.put(Constants.SERVICE_VENDOR, "Spring Dynamic Modules"); props.put(Constants.SERVICE_DESCRIPTION, ServerInfo.getServerInfo()); props.put(Constants.BUNDLE_VERSION, ServerInfo.getServerNumber()); props.put(Constants.BUNDLE_NAME, bundleContext.getBundle().getSymbolicName()); // spring-dm specific property props.put("org.springframework.osgi.bean.name", "tomcat-server"); // publish just the interfaces and the major classes (server/handlerWrapper) String[] classes = new String[] { StandardService.class.getName(), Service.class.getName(), MBeanRegistration.class.getName(), Lifecycle.class.getName() }; return bundleContext.registerService(classes, server, props); }
/** * Writes System OS and JVM properties. * @param writer Writer to render to */ protected void serverinfo(PrintWriter writer, StringManager smClient) { if (debug >= 1) log("serverinfo"); try { StringBuilder props = new StringBuilder(); props.append("OK - Server info"); props.append("\nTomcat Version: "); props.append(ServerInfo.getServerInfo()); props.append("\nOS Name: "); props.append(System.getProperty("os.name")); props.append("\nOS Version: "); props.append(System.getProperty("os.version")); props.append("\nOS Architecture: "); props.append(System.getProperty("os.arch")); props.append("\nJVM Version: "); props.append(System.getProperty("java.runtime.version")); props.append("\nJVM Vendor: "); props.append(System.getProperty("java.vm.vendor")); writer.println(props.toString()); } catch (Throwable t) { ExceptionUtils.handleThrowable(t); getServletContext().log("ManagerServlet.serverinfo",t); writer.println(smClient.getString("managerServlet.exception", t.toString())); } }
/** * Open the new log file for the date specified by <code>dateStamp</code>. */ @Override protected synchronized void open() { super.open(); if (currentLogFile.length()==0) { writer.println("#Fields: " + pattern); writer.println("#Version: 2.0"); writer.println("#Software: " + ServerInfo.getServerInfo()); } }
/** * Start this component and implement the requirements * of {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException if this component detects a fatal error * that prevents this component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Log our server identification information if(log.isInfoEnabled()) log.info( "Starting Servlet Engine: " + ServerInfo.getServerInfo()); // Standard container startup super.startInternal(); }
/** * Open the new log file for the date specified by <code>dateStamp</code>. */ protected synchronized void open() { super.open(); if (currentLogFile.length()==0) { writer.println("#Fields: " + pattern); writer.println("#Version: 2.0"); writer.println("#Software: " + ServerInfo.getServerInfo()); } }
private void addVersionInfo(List<MetricFamilySamples> mfs) { GaugeMetricFamily tomcatInfo = new GaugeMetricFamily( "tomcat_info", "tomcat version info", Arrays.asList("version", "build")); tomcatInfo.addMetric(Arrays.asList(ServerInfo.getServerNumber(), ServerInfo.getServerBuilt()), 1); mfs.add(tomcatInfo); }
/** * Open the new log file for the date specified by <code>dateStamp</code>. */ @Override protected synchronized void open() { super.open(); if (currentLogFile.length() == 0) { writer.println("#Fields: " + pattern); writer.println("#Version: 2.0"); writer.println("#Software: " + ServerInfo.getServerInfo()); } }
/** * Start this component and implement the requirements of * {@link org.apache.catalina.util.LifecycleBase#startInternal()}. * * @exception LifecycleException * if this component detects a fatal error that prevents this * component from being used */ @Override protected synchronized void startInternal() throws LifecycleException { // Log our server identification information if (log.isInfoEnabled()) log.info("Starting Servlet Engine: " + ServerInfo.getServerInfo()); // Standard container startup super.startInternal(); }
@Test public void startShouldCollectServerInfo() throws Exception { // Given String expectedServerInfo = ServerInfo.getServerInfo(); // When service.start(); service.stop(); // Then ServerMetaData serverMetaData = getServerMetaData(); assertEquals(serverMetaData.getServerInfo(), expectedServerInfo); }
public boolean start() throws ContainerException { // Start the Tomcat server try { tomcat.getServer().start(); } catch (LifecycleException e) { throw new ContainerException(e); } // load the web applications loadComponents(); for (Connector con: tomcat.getService().findConnectors()) { ProtocolHandler ph = con.getProtocolHandler(); int port = con.getPort(); con.setAttribute("port", port); if (ph instanceof Http11Protocol) { Http11Protocol hph = (Http11Protocol) ph; Debug.logInfo("Connector " + hph.getName() + " @ " + hph.getPort() + " - " + (hph.getSecure() ? "secure" : "not-secure") + " [" + con.getProtocolHandlerClassName() + "] started.", module); } else { Debug.logInfo("Connector " + con.getProtocol() + " @ " + con.getPort() + " - " + (con.getSecure() ? "secure" : "not-secure") + " [" + con.getProtocolHandlerClassName() + "] started.", module); } } Debug.logInfo("Started " + ServerInfo.getServerInfo(), module); return true; }
private void log() { log.info(sm.getString("versionLoggerListener.serverInfo.server.version", ServerInfo.getServerInfo())); log.info(sm.getString("versionLoggerListener.serverInfo.server.built", ServerInfo.getServerBuilt())); log.info(sm.getString("versionLoggerListener.serverInfo.server.number", ServerInfo.getServerNumber())); log.info(sm.getString("versionLoggerListener.os.name", System.getProperty("os.name"))); log.info(sm.getString("versionLoggerListener.os.version", System.getProperty("os.version"))); log.info(sm.getString("versionLoggerListener.os.arch", System.getProperty("os.arch"))); log.info(sm.getString("versionLoggerListener.java.home", System.getProperty("java.home"))); log.info(sm.getString("versionLoggerListener.vm.version", System.getProperty("java.runtime.version"))); log.info(sm.getString("versionLoggerListener.vm.vendor", System.getProperty("java.vm.vendor"))); log.info(sm.getString("versionLoggerListener.catalina.base", System.getProperty("catalina.base"))); log.info(sm.getString("versionLoggerListener.catalina.home", System.getProperty("catalina.home"))); if (logArgs) { List<String> args = ManagementFactory.getRuntimeMXBean().getInputArguments(); for (String arg : args) { log.info(sm.getString("versionLoggerListener.arg", arg)); } } if (logEnv) { Map<String,String> envs = System.getenv(); SortedSet<String> keys = new TreeSet<String>(envs.keySet()); for (String key : keys) { log.info(sm.getString("versionLoggerListener.env", key, envs.get(key))); } } }
@Override public void after(Object target, Object[] args, Object result, Throwable throwable) { if (isDebug) { logger.afterInterceptor(target, args, result, throwable); } String serverInfo = ServerInfo.getServerInfo(); ServerMetaDataHolder holder = this.traceContext.getServerMetaDataHolder(); holder.setServerName(serverInfo); holder.notifyListeners(); }
public void stop(BundleContext context) throws Exception { // unpublish service first registration.unregister(); urlRegistration.unregister(); log.info("Unpublished " + ServerInfo.getServerInfo() + " OSGi service"); // default startup procedure ClassLoader cl = Activator.class.getClassLoader(); Thread current = Thread.currentThread(); ClassLoader old = current.getContextClassLoader(); try { current.setContextClassLoader(cl); //reset CCL // current.setContextClassLoader(null); log.info("Stopping " + ServerInfo.getServerInfo() + " ..."); server.stop(); log.info("Succesfully stopped " + ServerInfo.getServerInfo()); } catch (Exception ex) { log.error("Cannot stop " + ServerInfo.getServerInfo(), ex); throw ex; } finally { current.setContextClassLoader(old); } }
private synchronized void installServerInfo() { if (SystemInstance.get().getOptions().get("tomee.keep-server-info", false)) { return; } // force static init final String value = ServerInfo.getServerInfo(); Field field = null; boolean acc = true; try { field = ServerInfo.class.getDeclaredField("serverInfo"); acc = field.isAccessible(); final int slash = value.indexOf('/'); field.setAccessible(true); final String tomeeVersion = OpenEjbVersion.get().getVersion(); final int modifiers = field.getModifiers(); if (Modifier.isFinal(modifiers)) { // this is a bit fragile, we can surely drop this feature at some point final Field modifiersField = Field.class.getDeclaredField("modifiers"); modifiersField.setAccessible(true); modifiersField.setInt(field, modifiers & ~Modifier.FINAL); } field.set(null, value.substring(0, slash) + " (TomEE)" + value.substring(slash) + " (" + tomeeVersion + ")"); } catch (final Exception e) { // no-op } finally { if (field != null) { field.setAccessible(acc); } } }
@Override protected void injectEnvironmentInfoIntoBanner(final Formatter formatter, final Environment environment, final Class<?> sourceClass) { formatter.format("Apache Tomcat Version: %s%n", ServerInfo.getServerInfo()); formatter.format("%s%n", LINE_SEPARATOR); }
/** * Report the current Tomcat Server Release number * @return Tomcat release identifier */ public String getServerInfo() { return ServerInfo.getServerInfo(); }
public String getServerVersion() { return(ServerInfo.getServerInfo()); }