protected void loadConfigurations() throws Exception { //if the configuration instances have been set explicitly, use them if (_configurations.size()>0) return; if (_configurationClasses.size()==0) { _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); } for (String configClass : _configurationClasses) _configurations.add((Configuration)Loader.loadClass(configClass).getDeclaredConstructor().newInstance()); }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+Arrays.hashCode(connectors); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
/** * Configures some well-known properties before the XmlConfiguration reads * the configuration. * @param jetty_config The configuration object. * @param web_inf the WEB-INF location */ private void setupXmlConfiguration(WebAppContext context, XmlConfiguration jetty_config, Resource web_inf) throws IOException { jetty_config.setJettyStandardIdsAndProperties(context.getServer(),null); Map<String,String> props = jetty_config.getProperties(); props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURI().toString()); props.put(PROPERTY_WEB_INF_URI, XmlConfiguration.normalizeURI(web_inf.getURI().toString())); props.put(PROPERTY_WEB_INF, web_inf.toString()); } }
if (useCaches) metaInfResourceCache = (ConcurrentHashMap<Resource, Resource>)context.getServer().getAttribute(CACHED_CONTAINER_RESOURCES); if (metaInfResourceCache == null) context.getServer().setAttribute(CACHED_CONTAINER_RESOURCES, metaInfResourceCache); metaInfFragmentCache = (ConcurrentHashMap<Resource, Resource>)context.getServer().getAttribute(CACHED_CONTAINER_FRAGMENTS); if (metaInfFragmentCache == null) context.getServer().setAttribute(CACHED_CONTAINER_FRAGMENTS, metaInfFragmentCache); metaInfTldCache = (ConcurrentHashMap<Resource, Collection<URL>>)context.getServer().getAttribute(CACHED_CONTAINER_TLDS); if (metaInfTldCache == null) context.getServer().setAttribute(CACHED_CONTAINER_TLDS, metaInfTldCache);
protected void loadSystemClasses() { if (_systemClasses != null) return; //look for a Server attribute with the list of System classes //to apply to every web application. If not present, use our defaults. Server server = getServer(); if (server != null) { Object systemClasses = server.getAttribute(SERVER_SYS_CLASSES); if (systemClasses instanceof String[]) _systemClasses = new ClasspathPattern((String[])systemClasses); else if (systemClasses instanceof ClasspathPattern) _systemClasses = new ClasspathPattern(((ClasspathPattern)systemClasses).getPatterns()); } if (_systemClasses == null) _systemClasses = new ClasspathPattern(__dftSystemClasses); }
protected void loadServerClasses() { if (_serverClasses != null) { return; } // look for a Server attribute with the list of Server classes // to apply to every web application. If not present, use our defaults. Server server = getServer(); if (server != null) { Object serverClasses = server.getAttribute(SERVER_SRV_CLASSES); if (serverClasses instanceof String[]) _serverClasses = new ClasspathPattern((String[])serverClasses); else if (serverClasses instanceof ClasspathPattern) _serverClasses = new ClasspathPattern(((ClasspathPattern)serverClasses).getPatterns()); } if (_serverClasses == null) { _serverClasses = new ClasspathPattern(__dftServerClasses); } }
@Override public void preConfigure(final WebAppContext context) throws Exception { boolean useContainerCache = DEFAULT_USE_CONTAINER_METAINF_CACHE; if (context.getServer() != null) { Boolean attr = (Boolean)context.getServer().getAttribute(USE_CONTAINER_METAINF_CACHE); if (attr != null) useContainerCache = attr.booleanValue(); } if (LOG.isDebugEnabled()) LOG.debug("{} = {}", USE_CONTAINER_METAINF_CACHE, useContainerCache); //pre-emptively create empty lists for tlds, fragments and resources as context attributes //this signals that this class has been called. This differentiates the case where this class //has been called but finds no META-INF data from the case where this class was never called if (context.getAttribute(METAINF_TLDS) == null) context.setAttribute(METAINF_TLDS, new HashSet<URL>()); if (context.getAttribute(METAINF_RESOURCES) == null) context.setAttribute(METAINF_RESOURCES, new HashSet<Resource>()); if (context.getAttribute(METAINF_FRAGMENTS) == null) context.setAttribute(METAINF_FRAGMENTS, new HashMap<Resource, Resource>()); //always scan everything from the container's classpath scanJars(context, context.getMetaData().getContainerResources(), useContainerCache, __allScanTypes); //only look for fragments if web.xml is not metadata complete, or it version 3.0 or greater List<String> scanTypes = new ArrayList<>(__allScanTypes); if (context.getMetaData().isMetaDataComplete() || (context.getServletContext().getEffectiveMajorVersion() < 3) && !context.isConfigurationDiscovered()) scanTypes.remove(METAINF_FRAGMENTS); scanJars(context, context.getMetaData().getWebInfJars(), false, scanTypes); }
public void contextInitialized(ServletContextEvent sce) { WebAppContext ctx = (WebAppContext) sce.getServletContext(); System.out.println("context Base Path" + ctx.getContextPath()); System.out.println("Getting the port is a bit trickier"); System.out.println("One valid Port = " + ctx.getServer().getConnectors()[0].getPort()); }
protected void loadConfigurations() throws Exception { //if the configuration instances have been set explicitly, use them if (_configurations.size()>0) return; if (_configurationClasses.size()==0) _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); for (String configClass : _configurationClasses) _configurations.add((Configuration)Loader.loadClass(this.getClass(), configClass).newInstance()); }
protected void loadConfigurations() throws Exception { //if the configuration instances have been set explicitly, use them if (_configurations.size()>0) return; if (_configurationClasses.size()==0) { _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); } for (String configClass : _configurationClasses) _configurations.add((Configuration)Loader.loadClass(configClass).getDeclaredConstructor().newInstance()); }
protected void loadConfigurations() throws Exception { //if the configuration instances have been set explicitly, use them if (_configurations.size()>0) return; if (_configurationClasses.size()==0) _configurationClasses.addAll(Configuration.ClassList.serverDefault(getServer())); for (String configClass : _configurationClasses) _configurations.add((Configuration)Loader.loadClass(this.getClass(), configClass).newInstance()); }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+Arrays.hashCode(connectors); LOG.info(displayName + " at http://" + connectors[i].toString() + getContextPath()); } }
/** * Configures some well-known properties before the XmlConfiguration reads * the configuration. * @param jetty_config The configuration object. * @param web_inf the WEB-INF location */ private void setupXmlConfiguration(WebAppContext context, XmlConfiguration jetty_config, Resource web_inf) throws IOException { jetty_config.setJettyStandardIdsAndProperties(context.getServer(),null); Map<String,String> props = jetty_config.getProperties(); props.put(PROPERTY_THIS_WEB_INF_URL, web_inf.getURI().toString()); props.put(PROPERTY_WEB_INF_URI, XmlConfiguration.normalizeURI(web_inf.getURI().toString())); props.put(PROPERTY_WEB_INF, web_inf.toString()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
private void dumpUrl() { Connector[] connectors = getServer().getConnectors(); for (int i=0;i<connectors.length;i++) { String connectorName = connectors[i].getName(); String displayName = getDisplayName(); if (displayName == null) displayName = "WebApp@"+connectors.hashCode(); LOG.info(displayName + " at http://" + connectorName + getContextPath()); } }
protected void loadSystemClasses() { if (_systemClasses != null) return; //look for a Server attribute with the list of System classes //to apply to every web application. If not present, use our defaults. Server server = getServer(); if (server != null) { Object systemClasses = server.getAttribute(SERVER_SYS_CLASSES); if (systemClasses != null && systemClasses instanceof String[]) _systemClasses = new ClasspathPattern((String[])systemClasses); } if (_systemClasses == null) _systemClasses = new ClasspathPattern(__dftSystemClasses); }