org.eclipse.jetty.webapp.WebAppContext.getServer()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(10.7k)|赞(0)|评价(0)|浏览(116)

本文整理了Java中org.eclipse.jetty.webapp.WebAppContext.getServer()方法的一些代码示例,展示了WebAppContext.getServer()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebAppContext.getServer()方法的具体详情如下:
包路径:org.eclipse.jetty.webapp.WebAppContext
类名称:WebAppContext
方法名:getServer

WebAppContext.getServer介绍

暂无

代码示例

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

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());
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

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());
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

/**
   * 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());
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

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);

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

Server server=context.getServer();
if (server!=null)
  Connector[] connectors = context.getServer().getConnectors();

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

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);
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

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);
  }
}

代码示例来源:origin: org.eclipse.jetty/jetty-webapp

@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);
}

代码示例来源:origin: stackoverflow.com

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());
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

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());
}

代码示例来源:origin: jenkinsci/winstone

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());
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

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());
}

代码示例来源:origin: com.ovea.tajin.servers/tajin-server-jetty9

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());
  }
}

代码示例来源:origin: com.ovea.tajin.server/tajin-server-jetty9

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());
  }
}

代码示例来源:origin: jenkinsci/winstone

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());
  }
}

代码示例来源:origin: jenkinsci/winstone

/**
   * 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());
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

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());
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-webapp

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());
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-plus

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());
  }
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

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);
}

相关文章

WebAppContext类方法