Refine search
/** * @see org.eclipse.jetty.util.PatternMatcher#matched(java.net.URI) */ @Override public void matched(URI uri) throws Exception { _context.getMetaData().addWebInfJar(Resource.newResource(uri)); }
String defaultsDescriptor = context.getDefaultsDescriptor(); if (defaultsDescriptor != null && defaultsDescriptor.length() > 0) Resource dftResource = Resource.newSystemResource(defaultsDescriptor); if (dftResource == null) dftResource = context.newResource(defaultsDescriptor); context.getMetaData().setDefaults (dftResource); if (webxml != null) context.getMetaData().setWebXml(webxml); context.getServletContext().setEffectiveMajorVersion(context.getMetaData().getWebXml().getMajorVersion()); context.getServletContext().setEffectiveMinorVersion(context.getMetaData().getWebXml().getMinorVersion()); Resource orideResource = Resource.newSystemResource(overrideDescriptor); if (orideResource == null) orideResource = context.newResource(overrideDescriptor); context.getMetaData().addOverride(orideResource);
throws Exception LOG.debug("metadata resolve {}",context); if (getOrdering() != null) orderedWebInfJars = getOrderedWebInfJars(); List<String> orderedLibs = new ArrayList<String>(); for (Resource webInfJar:orderedWebInfJars) context.setAttribute(ServletContext.ORDERED_LIBS, orderedLibs); context.getServletContext().setEffectiveMajorVersion(_webXmlRoot.getMajorVersion()); context.getServletContext().setEffectiveMinorVersion(_webXmlRoot.getMinorVersion()); p.process(context,getWebDefault()); p.process(context,getWebXml()); for (WebDescriptor wd : getOverrideWebs()) LOG.debug("process {} {}",context,wd); p.process(context,wd); if (getOrdering() != null) resources = orderedWebInfJars; else resources = getWebInfJars();
@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); }
switch (context.getMetaData().getOrigin("context-param."+name)) context.getInitParams().put(name, value); context.getMetaData().setOrigin("context-param."+name, descriptor); break; context.getInitParams().put(name, value); context.getMetaData().setOrigin("context-param."+name, descriptor); LOG.warn(new Throwable()); // TODO throw ISE? if (LOG.isDebugEnabled()) LOG.debug("ContextParam: " + name + "=" + value);
connector.setPort(port); server.addConnector(connector); context = new WebAppContext(); context.setResourceBase(webapp.getAbsolutePath()); context.setContextPath("/"); context.setClassLoader(new WebAppClassLoader(classLoader, context)); context.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern", ".*/.+\\.jar$|.*/classes/.*"); File file = new File(url.getFile()); if(file.exists()){ context.getMetaData().addWebInfJar(Resource.newResource(file));
Descriptor originDescriptor = context.getMetaData().getOriginDescriptor(originName); switch (context.getMetaData().getOrigin(originName)) context.getMetaData().setOrigin(originName, descriptor); break; context.getMetaData().setOrigin(originName, descriptor); switch (context.getMetaData().getOrigin(name+".servlet.servlet-class")) context.getMetaData().setOrigin(name+".servlet.servlet-class", descriptor); break; context.getMetaData().setOrigin(name+".servlet.servlet-class", descriptor); switch (context.getMetaData().getOrigin(name+".servlet.load-on-startup")) context.getMetaData().setOrigin(name+".servlet.load-on-startup", descriptor); break; context.getMetaData().setOrigin(name+".servlet.load-on-startup", descriptor); switch (context.getMetaData().getOrigin(name+".servlet.role-name."+roleName)) context.getMetaData().setOrigin(name+".servlet.role-name."+roleName, descriptor); break; context.getMetaData().setOrigin(name+".servlet.role-name."+roleName, descriptor);
if (extension != null) switch (context.getMetaData().getOrigin("extension."+extension)) context.getMimeTypes().addMimeMapping(extension, mimeType); context.getMetaData().setOrigin("extension."+extension, descriptor); break; context.getMimeTypes().addMimeMapping(extension, mimeType); context.getMetaData().setOrigin("extension."+extension, descriptor); LOG.warn(new Throwable()); // TODO throw ISE?
public void configure(WebAppContext context) throws Exception LOG.debug("configure {}",this); if (context.isStarted()) LOG.warn("Cannot configure webapp after it is started"); return; Resource webInf = context.getWebInf(); if (webInf != null && webInf.isDirectory() && context.getClassLoader() instanceof WebAppClassLoader) Resource classes= webInf.addPath("classes/"); if (classes.exists()) ((WebAppClassLoader)context.getClassLoader()).addClassPath(classes); context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor()); context.getMetaData().addDescriptorProcessor(new QuickStartDescriptorProcessor()); context.addBean(starter, true); LOG.debug("configured {}",this);
/** * Setup for an expanded webapp with resource base as a relative path. */ protected void setupForExpandedWar() { if (resourceBase != null) { webapp.setResourceBase(resourceBase); } else { Resource base = Resource.newClassPathResource("/web"); if (base != null && base.exists()) { webapp.setResourceBase(base.toString()); } else { webapp.setBaseResource(new NoResource()); log().debug("No static resources at no resources/web"); } } try { if (webXml == null) { webXml = Resource.newClassPathResource("/META-INF/web.xml"); } if (webXml != null && webXml.exists()) { webapp.getMetaData().setWebXml(webXml); } } catch (Exception e) { throw new RuntimeException(e); } webapp.setParentLoaderPriority(false); }
/** * Look for any web-fragment.xml fragments in META-INF of jars in WEB-INF/lib * * @throws Exception */ public void findWebFragments (final WebAppContext context, final MetaData metaData) throws Exception { @SuppressWarnings("unchecked") List<Resource> frags = (List<Resource>)context.getAttribute(FRAGMENT_RESOURCES); if (frags!=null) { for (Resource frag : frags) { if (frag.isDirectory()) //tolerate the case where the library is a directory, not a jar. useful for OSGi for example { metaData.addFragment(frag, Resource.newResource(frag.getURL()+"/META-INF/web-fragment.xml")); } else //the standard case: a jar most likely inside WEB-INF/lib { metaData.addFragment(frag, Resource.newResource("jar:"+frag.getURL()+"!/META-INF/web-fragment.xml")); } } } } }
/** * Process web-default.xml, web.xml, override-web.xml * */ @Override public void configure (WebAppContext context) throws Exception { // cannot configure if the context is already started if (context.isStarted()) { LOG.debug("Cannot configure webapp after it is started"); return; } context.getMetaData().addDescriptorProcessor(new StandardDescriptorProcessor()); }
if (LOG.isDebugEnabled()) LOG.debug("{} in mapping {} from defaults descriptor is overridden by ",ps,sm,servletName); LOG.warn("Duplicate mapping from {} to {}", p, servletName); context.getMetaData().setOrigin(servletName+".servlet.mapping."+p, descriptor);
base=Resource.newResource(getWar()); if (base.isDirectory()) dir=base; else if (base.toString().toLowerCase(Locale.ENGLISH).endsWith(".war")) dir=Resource.newResource(w.substring(0,w.length()-4)); if (!dir.exists()) LOG.info("Quickstart Extract " + war + " to " + dir); dir.getFile().mkdirs(); JarResource.newJarResource(war).copyTo(dir.getFile()); getMetaData().addDescriptorProcessor(_preconfigProcessor); _startWebapp=false; LOG.info("Quickstart preconfigure: {}(war={},dir={})",this,war,dir); getMetaData().addDescriptorProcessor(_preconfigProcessor); setPreconfigure(true); _startWebapp=true; _startWebapp=true; super.doStart();
@SuppressWarnings("unchecked") @Override public void preConfigure(final WebAppContext context) throws Exception { List<Resource> theResources = (List<Resource>) context.getAttribute(RESOURCE_URLS); context.setAttribute(RESOURCE_URLS, theResources); parent = parent.substring(0, parent.length() - 2); Resource resource = Resource.newResource(url); if (context.getMetaData().getWebXml() == null) { webXml = resource; logger.debug("Setting web.xml from {}", url.toString()); context.getMetaData().setWebXml(webXml); } else { logger.info("web.xml already set, ignoring {}", url.toString()); Resource baseResource = Resource.newResource(url1); resources.add(baseResource); Resource fragmentResource = Resource.newResource(new URL(jarOnlyResource)); context.getMetaData().addWebInfJar(fragmentResource); context.getMetaData().addFragment(fragmentResource, Resource.newResource(url));
String war = context.getWar(); if (war == null || war.length()<=0) throw new IllegalStateException ("No location for webapp"); Resource webApp = context.newResource(war); if (webApp.isAlias()) LOG.debug(webApp + " anti-aliased to " + webApp.getAlias()); webApp = context.newResource(webApp.getAlias()); context.setBaseResource(webApp); LOG.debug("webapp={}",webApp); LOG.debug("quickStartWebXml={}",quickStartWebXml); context.getMetaData().setWebXml(quickStartWebXml);
logger.debug("webapp.scan: found web.xml {}", scanResource.getResolvedUrl().toString()); if (context.getBaseResource() == null) { if (logger.isDebugEnabled()) { logger.debug("webapp.scan: found base directory {}", Resource.newResource(scanResource.offsetUrl).toString()); context.setBaseResource(Resource.newResource(scanResource.offsetUrl)); // add base directory logger.debug("webapp.scan: found web fragment {}", resolvedUrl.toString()); Resource fragmentResource = Resource.newResource(scanResource.offsetUrl); context.getMetaData().addWebInfJar(fragmentResource); context.getMetaData().addFragment(fragmentResource, Resource.newResource(resolvedUrl)); } else if (devMode && isWebResourceBase(scanResource)) { for (URL resolvedUrl : morphDevelopmentResource(scanResource)) {
protected void foundWebXml(ResourceScanListener.ScanResource scanResource, WebAppContext context) throws Exception { if (context.getMetaData().getWebXml() == null) { webXml = Resource.newResource(scanResource.getResolvedUrl()); if (log.isDebugEnabled()) { log.debug("webapp.scan: found web.xml {}", webXml.toString()); } context.getMetaData().setWebXml(webXml); } else { log.info("Found extra web.xml, ignoring {}", scanResource.getResolvedUrl().toString()); } }
switch (context.getMetaData().getOrigin("locale-encoding."+locale)) context.addLocaleEncoding(locale, encoding); context.getMetaData().setOrigin("locale-encoding."+locale, descriptor); break; context.addLocaleEncoding(locale, encoding); context.getMetaData().setOrigin("locale-encoding."+locale, descriptor); LOG.warn(new Throwable()); // TODO throw ISE?
if (!location.startsWith("/")) throw new IllegalStateException("Missing leading '/' for location: " + location); ErrorPageErrorHandler handler = (ErrorPageErrorHandler)context.getErrorHandler(); String originName = "error."+error; switch (context.getMetaData().getOrigin(originName)) else handler.addErrorPage(error,location); context.getMetaData().setOrigin("error."+error, descriptor); break; Descriptor originDescriptor = context.getMetaData().getOriginDescriptor(originName); if (descriptor == originDescriptor) throw new IllegalStateException("Duplicate error-page "+error+" at "+location); else handler.addErrorPage(error,location); context.getMetaData().setOrigin("error."+error, descriptor); LOG.warn(new Throwable()); // TODO throw ISE?