List of usage examples for javax.servlet ServletContext getServerInfo
public String getServerInfo();
From source file:org.mobicents.servlet.sip.restcomm.callmanager.mgcp.MgcpCallManager.java
@Override public final void init(final ServletConfig config) throws ServletException { try {//from w w w.j a va 2 s. c o m final ServletContext context = config.getServletContext(); LOGGER.info( "initializing the servlet with context:" + context + " ServerInfo:" + context.getServerInfo() + " ServletContextName:" + context.getServletContextName() + " config:" + config); context.setAttribute("org.mobicents.servlet.sip.restcomm.callmanager.CallManager", this); try { Bootstrapper.bootstrap(config); } catch (final BootstrapException exception) { throw new ServletException(exception); } sipFactory = (SipFactory) config.getServletContext().getAttribute(SIP_FACTORY); final ServiceLocator services = ServiceLocator.getInstance(); servers = services.get(MgcpServerManager.class); configuration = services.get(Configuration.class); proxyUser = configuration.getString("outbound-proxy-user"); proxyPassword = configuration.getString("outbound-proxy-password"); final String uri = configuration.getString("outbound-proxy-uri"); if (uri != null && !uri.isEmpty()) { proxyUri = sipFactory.createSipURI(null, uri); } /////////// LOGGER.info("initializing jvoicexml inteface........"); embJVXML = new EmbeddedJVXML(); embJVXML.init(); // //init jvoicexml context // contextJXML = new InitialContext(); // LOGGER.info("init jvoicexml context:contextJXML:"+contextJXML); // // // // LOGGER.info("creating VoiceXML documents and binding to the applications....."); // vxmlDocument = createVXMLDoc(); // printDocument(vxmlDocument); // // // // LOGGER.info("adding VXML document to repository..."); // vxmlURI=addDocument(vxmlDocument); // } catch (Exception e) { ExLog.exception(LOGGER, e); } }
From source file:org.sakaiproject.portal.render.portlet.PortletToolRenderService.java
private boolean isPortletApplication(ServletContext context, ToolConfiguration configuration) throws ToolRenderException, MalformedURLException { SakaiPortletWindow window = registry.getOrCreatePortletWindow(configuration); if (window == null) { return false; }//from w w w.j ava 2 s .com if (LOG.isDebugEnabled()) { LOG.debug("Checking context for potential portlet "); } ServletContext crossContext = context.getContext(window.getContextPath()); if (LOG.isDebugEnabled()) { LOG.debug("Got servlet context as " + crossContext); LOG.debug("Getting Context for path " + window.getContextPath()); LOG.debug("Base Path " + crossContext.getRealPath("/")); LOG.debug("Context Name " + crossContext.getServletContextName()); LOG.debug("Server Info " + crossContext.getServerInfo()); LOG.debug(" and it is a portlet ? :" + (crossContext.getResource("/WEB-INF/portlet.xml") != null)); } return crossContext.getResource("/WEB-INF/portlet.xml") != null; }
From source file:lucee.runtime.net.rpc.server.RPCServer.java
/** * Initialization method.//from w w w.j a va2 s .c o m * @throws AxisFault */ private RPCServer(ServletContext context) throws AxisFault { this.context = context; initQueryStringHandlers(); ServiceAdmin.setEngine(this.getEngine(), context.getServerInfo()); webInfPath = context.getRealPath("/WEB-INF"); homeDir = ReqRspUtil.getRootPath(context); }
From source file:org.opentaps.common.util.UtilCommon.java
/** * Gets the absolute path to the given file according to the servlet context. * Files are in /runtime/output/ and we get there from the servlet context path. * @param servletContext a <code>ServletContext</code> value * @param filename a <code>String</code> value * @return the absolute path/*from w w w .jav a 2s . co m*/ */ public static String getAbsoluteFilePath(ServletContext servletContext, final String filename) { String rootPath; // JBoss is a special case as the directory structure is a bit different than with the embedded tomcat server if (servletContext.getServerInfo().toLowerCase().contains("jboss")) { rootPath = servletContext.getRealPath("../"); } else { rootPath = servletContext.getRealPath("../../../../"); } String filePath = "/runtime/output/"; return rootPath + filePath + filename; }
From source file:com.atlassian.jira.startup.JiraSystemInfo.java
/** * This only gets the most basic environment information to avoid bring up the JIRA world before the raw database * checks are done./* w w w. j a v a 2 s . c o m*/ * <p/> * It MUST BE CAREFUL not to access an JIRA code that will bring up the world * * @param context - a ServletContext that the app is running in. This may be nulll */ public void obtainBasicInfo(final ServletContext context) { final SystemInfoUtils systemInfoUtils = new SystemInfoUtilsImpl(); final ReleaseInfo releaseInfo = ReleaseInfo.getReleaseInfo(ReleaseInfo.class); logMsg.outputHeader("Environment"); logMsg.outputProperty("JIRA Build", buildUtilsInfo.getBuildInformation()); logMsg.outputProperty("Build Date", String.valueOf(buildUtilsInfo.getCurrentBuildDate())); logMsg.outputProperty("JIRA Installation Type", releaseInfo.getInfo()); if (context != null) { logMsg.outputProperty("Application Server", context.getServerInfo() + " - Servlet API " + context.getMajorVersion() + "." + context.getMinorVersion()); } logMsg.outputProperty("Java Version", jiraSystemProperties.getProperty("java.version", STRANGELY_UNKNOWN) + " - " + jiraSystemProperties.getProperty("java.vendor", STRANGELY_UNKNOWN)); logMsg.outputProperty("Current Working Directory", jiraSystemProperties.getProperty("user.dir", STRANGELY_UNKNOWN)); final Runtime rt = Runtime.getRuntime(); final long maxMemory = rt.maxMemory() / MEGABYTE; final long totalMemory = rt.totalMemory() / MEGABYTE; final long freeMemory = rt.freeMemory() / MEGABYTE; final long usedMemory = totalMemory - freeMemory; logMsg.outputProperty("Maximum Allowable Memory", maxMemory + "MB"); logMsg.outputProperty("Total Memory", totalMemory + "MB"); logMsg.outputProperty("Free Memory", freeMemory + "MB"); logMsg.outputProperty("Used Memory", usedMemory + "MB"); for (final MemoryInformation memory : systemInfoUtils.getMemoryPoolInformation()) { logMsg.outputProperty("Memory Pool: " + memory.getName(), memory.toString()); } logMsg.outputProperty("JVM Input Arguments", systemInfoUtils.getJvmInputArguments()); // do we have any patches Set<AppliedPatchInfo> appliedPatches = AppliedPatches.getAppliedPatches(); if (appliedPatches.size() > 0) { logMsg.outputHeader("Applied Patches"); for (AppliedPatchInfo appliedPatch : appliedPatches) { logMsg.outputProperty(appliedPatch.getIssueKey(), appliedPatch.getDescription()); } } logMsg.outputProperty("Java Compatibility Information", "JIRA version = " + buildUtilsInfo.getVersion() + ", Java Version = " + jiraSystemProperties.getProperty("java.version", STRANGELY_UNKNOWN)); }
From source file:org.openflamingo.web.util.VersionConfigurer.java
@Override public void contextInitialized(ServletContextEvent servletContextEvent) { Log4jWebConfigurer.initLogging(servletContextEvent.getServletContext()); Properties properties = new Properties(); ServletContext context = servletContextEvent.getServletContext(); InputStream inputStream = null; try {/* ww w .j a v a2 s . c o m*/ inputStream = context.getResourceAsStream("/WEB-INF/version.properties"); properties.load(inputStream); } catch (Exception ex) { throw new IllegalArgumentException("Cannot load a '/WEB/INF/version.properties' file.", ex); } finally { IOUtils.closeQuietly(inputStream); } StringBuilder builder = new StringBuilder(); printHeader(builder, "Application Information"); Properties appProps = new Properties(); appProps.put("Application", "Flamingo Workflow Engine"); appProps.put("Version", properties.get("version")); appProps.put("Build Date", properties.get("build.timestamp")); appProps.put("Build Number", properties.get("build.number")); appProps.put("Revision Number", properties.get("revision.number")); appProps.put("Build Key", properties.get("build.key")); if (context != null) { appProps.put("Application Server", context.getServerInfo() + " - Servlet API " + context.getMajorVersion() + "." + context.getMinorVersion()); } Properties systemProperties = System.getProperties(); appProps.put("Java Version", systemProperties.getProperty("java.version", UNKNOWN) + " - " + systemProperties.getProperty("java.vendor", UNKNOWN)); appProps.put("Current Working Directory", systemProperties.getProperty("user.dir", UNKNOWN)); print(builder, appProps); Properties memPros = new Properties(); final Runtime rt = Runtime.getRuntime(); final long maxMemory = rt.maxMemory() / MEGA_BYTES; final long totalMemory = rt.totalMemory() / MEGA_BYTES; final long freeMemory = rt.freeMemory() / MEGA_BYTES; final long usedMemory = totalMemory - freeMemory; memPros.put("Maximum Allowable Memory", maxMemory + "MB"); memPros.put("Total Memory", totalMemory + "MB"); memPros.put("Free Memory", freeMemory + "MB"); memPros.put("Used Memory", usedMemory + "MB"); print(builder, memPros); printHeader(builder, "Java System Properties"); Properties sysProps = new Properties(); for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) { sysProps.put(entry.getKey(), entry.getValue()); } print(builder, sysProps); printHeader(builder, "System Environments"); Map<String, String> getenv = System.getenv(); Properties envProps = new Properties(); Set<String> strings = getenv.keySet(); for (String key : strings) { String message = getenv.get(key); envProps.put(key, message); } print(builder, envProps); logger.info("================================================="); logger.info(" Flamingo Web Services starting..."); logger.info("=================================================\n{}", builder.toString()); }
From source file:org.openflamingo.engine.util.VersionConfigurer.java
/** * Notification that the web application initialization * process is starting.//from w w w . ja v a 2 s .c om * All ServletContextListeners are notified of context * initialization before any filter or servlet in the web * application is initialized. * * @param servletContextEvent {@link javax.servlet.ServletContextEvent} */ @Override public void contextInitialized(ServletContextEvent servletContextEvent) { Log4jWebConfigurer.initLogging(servletContextEvent.getServletContext()); Properties properties = new Properties(); ServletContext context = servletContextEvent.getServletContext(); InputStream inputStream = null; try { inputStream = context.getResourceAsStream("/WEB-INF/version.properties"); properties.load(inputStream); } catch (Exception ex) { throw new IllegalArgumentException("Cannot load a '/WEB/INF/version.properties' file.", ex); } finally { IOUtils.closeQuietly(inputStream); } StringBuilder builder = new StringBuilder(); printHeader(builder, "Application Information"); Properties appProps = new Properties(); appProps.put("Application", "Flamingo Workflow Engine"); appProps.put("Version", properties.get("version")); appProps.put("Build Date", properties.get("build.timestamp")); appProps.put("Build Number", properties.get("build.number")); appProps.put("Revision Number", properties.get("revision.number")); appProps.put("Build Key", properties.get("build.key")); if (context != null) { appProps.put("Application Server", context.getServerInfo() + " - Servlet API " + context.getMajorVersion() + "." + context.getMinorVersion()); } Properties systemProperties = System.getProperties(); appProps.put("Java Version", systemProperties.getProperty("java.version", UNKNOWN) + " - " + systemProperties.getProperty("java.vendor", UNKNOWN)); appProps.put("Current Working Directory", systemProperties.getProperty("user.dir", UNKNOWN)); print(builder, appProps); printHeader(builder, "JVM Heap Information"); Properties memPros = new Properties(); final Runtime rt = Runtime.getRuntime(); final long maxMemory = rt.maxMemory() / MEGA_BYTES; final long totalMemory = rt.totalMemory() / MEGA_BYTES; final long freeMemory = rt.freeMemory() / MEGA_BYTES; final long usedMemory = totalMemory - freeMemory; memPros.put("Maximum Allowable Memory", maxMemory + "MB"); memPros.put("Total Memory", totalMemory + "MB"); memPros.put("Free Memory", freeMemory + "MB"); memPros.put("Used Memory", usedMemory + "MB"); print(builder, memPros); printHeader(builder, "Java System Properties"); Properties sysProps = new Properties(); for (final Map.Entry<Object, Object> entry : systemProperties.entrySet()) { sysProps.put(entry.getKey(), entry.getValue()); } print(builder, sysProps); printHeader(builder, "System Environments"); Map<String, String> getenv = System.getenv(); Properties envProps = new Properties(); Set<String> strings = getenv.keySet(); for (String key : strings) { String message = getenv.get(key); envProps.put(key, message); } print(builder, envProps); logger.info("================================================="); logger.info(" Flamingo Workflow Engine starting..."); logger.info("=================================================\n{}", builder.toString()); }
From source file:com.aurel.track.ApplicationStarter.java
private void printSystemInfo() { LOGGER.info("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version")); LOGGER.info("Operating System: " + System.getProperty("os.name") + " " + System.getProperty("os.arch")); Locale loc = Locale.getDefault(); LOGGER.info("Default locale: " + loc.getDisplayName()); ServletContext application = ApplicationBean.getInstance().getServletContext(); try {//from ww w. jav a 2s .com LOGGER.info("Servlet real path: " + application.getRealPath(File.separator)); } catch (Exception ex) { LOGGER.error("Error trying to obtain getRealPath()"); } LOGGER.info("Servlet container: " + application.getServerInfo()); Connection conn = null; try { PropertiesConfiguration pc = ApplicationBean.getInstance().getDbConfig(); LOGGER.info("Configured database type: " + pc.getProperty("torque.database.track.adapter")); LOGGER.info( "Configured database driver: " + pc.getProperty("torque.dsfactory.track.connection.driver")); LOGGER.info("Configured JDBC URL: " + pc.getProperty("torque.dsfactory.track.connection.url")); conn = Torque.getConnection(BaseTSitePeer.DATABASE_NAME); DatabaseMetaData dbm = conn.getMetaData(); LOGGER.info("Database type: " + dbm.getDatabaseProductName() + " " + dbm.getDatabaseProductVersion()); LOGGER.info("Driver info: " + dbm.getDriverName() + " " + dbm.getDriverVersion()); Statement stmt = conn.createStatement(); Date d1 = new Date(); stmt.executeQuery("SELECT * FROM TSTATE"); Date d2 = new Date(); stmt.close(); LOGGER.info("Database test query done in " + (d2.getTime() - d1.getTime()) + " milliseconds "); } catch (Exception e) { System.err.println("Problem retrieving meta data"); LOGGER.error("Problem retrieving meta data"); } finally { if (conn != null) { Torque.closeConnection(conn); } } }
From source file:com.edmunds.etm.client.impl.ClientServletContextListener.java
/** * Notification that the web application initialization process is starting. All ServletContextListeners are * notified of context initialization before any filter or servlet in the web application is initialized. * * @param servletContextEvent the servlet context event. *//*from w ww. j av a 2s . c o m*/ @Override public void contextInitialized(ServletContextEvent servletContextEvent) { logger.debug("Starting ETM listener."); ServletContext ctx = servletContextEvent.getServletContext(); final String ipAddress = getIpAddress(); final String contextPath = ctx.getContextPath(); ClientConfigDto clientConfig = readClientConfiguration(); MavenModuleDto mavenModule = clientConfig.getMavenModule(); if (logger.isDebugEnabled()) { logger.debug(String.format("ETM application: %s", clientConfig.getMavenModule())); } // validate IP address and maven module if (StringUtils.isBlank(ipAddress)) { logger.error("Unable to register with ETM: IP address is blank"); return; } else if (mavenModule == null) { logger.error("Unable to register with ETM: Maven artifact information is missing"); return; } final ApplicationContext appCtx = SpringContextLoader.loadClassPathSpringContext(CLIENT_CONTEXT_PATH, getMavenProperties(mavenModule)); final ClientRegistrationHelper helper = (ClientRegistrationHelper) appCtx .getBean("clientRegistrationHelper"); clientManager = (ClientManager) appCtx.getBean("clientManager"); // register with the ETM controller helper.register(ctx.getServerInfo(), ipAddress, contextPath, clientConfig); }
From source file:org.deegree.services.controller.OGCFrontController.java
private Collection<ModuleInfo> extractModulesInfo(ServletContext servletContext) throws IOException, URISyntaxException { if (servletContext.getServerInfo() != null && servletContext.getServerInfo().contains("WebLogic")) { LOG.debug("Running on weblogic. Not extracting module info from classpath, but from WEB-INF/lib."); return ModuleInfo.extractModulesInfo(forWebInfLib(servletContext)); }// w w w . j av a 2 s.co m return ModuleInfo.extractModulesInfo(forClassLoader()); }