/** * Get the value in the webapp context. * @param name The name of the attribute * @return The value of the attribute */ public Object getAttribute(String name) { return webAppContext.getAttribute(name); }
/** * Get the value in the webapp context. * @param name The name of the attribute * @return The value of the attribute */ public Object getAttribute(String name) { return webAppContext.getAttribute(name); }
/** * Add in fragment descriptors that have already been discovered by MetaInfConfiguration * * @param context the web app context to look in * @param metaData the metadata to populate with fragments * * @throws Exception if unable to find web fragments */ public void addWebFragments (final WebAppContext context, final MetaData metaData) throws Exception { @SuppressWarnings("unchecked") Map<Resource, Resource> frags = (Map<Resource,Resource>)context.getAttribute(FRAGMENT_RESOURCES); if (frags!=null) { for (Resource key : frags.keySet()) { if (key.isDirectory()) //tolerate the case where the library is a directory, not a jar. useful for OSGi for example { metaData.addFragment(key, frags.get(key)); } else //the standard case: a jar most likely inside WEB-INF/lib { metaData.addFragment(key, frags.get(key)); } } } } }
throws Exception String tmp = (String)context.getAttribute(WEBINF_JAR_PATTERN); Pattern webInfPattern = (tmp==null?null:Pattern.compile(tmp));
Object target = context.getAttribute(JavaVersion.JAVA_TARGET_PLATFORM); if (target!=null) targetPlatform = Integer.parseInt(target.toString()); String tmp = (String)context.getAttribute(CONTAINER_JAR_PATTERN); Pattern containerPattern = (tmp==null?null:Pattern.compile(tmp)); ContainerPathNameMatcher containerPathNameMatcher = new ContainerPathNameMatcher(context, containerPattern);
@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); }
File servletTmpDir = asFile(context.getAttribute(WebAppContext.TEMPDIR)); if (servletTmpDir != null) File baseTemp = asFile(context.getAttribute(WebAppContext.BASETEMPDIR)); if (baseTemp != null && baseTemp.isDirectory() && baseTemp.canWrite())
Collection<URL> metaInfTlds = (Collection<URL>)context.getAttribute(METAINF_TLDS); if (metaInfTlds == null)
@Override public void deconfigure(WebAppContext context) throws Exception { //if we're not persisting the temp dir contents delete it if (!context.isPersistTempDirectory()) { IO.delete(context.getTempDirectory()); } //if it wasn't explicitly configured by the user, then unset it Boolean tmpdirConfigured = (Boolean)context.getAttribute(TEMPDIR_CONFIGURED); if (tmpdirConfigured != null && !tmpdirConfigured) context.setTempDirectory(null); //reset the base resource back to what it was before we did any unpacking of resources if (context.getBaseResource() != null) context.getBaseResource().close(); context.setBaseResource(_preUnpackBaseResource); }
@Override protected void doStart() throws Exception { try { _metadata.setAllowDuplicateFragmentNames(isAllowDuplicateFragmentNames()); Boolean validate = (Boolean)getAttribute(MetaData.VALIDATE_XML); _metadata.setValidateXml((validate!=null && validate.booleanValue())); preConfigure(); super.doStart(); postConfigure(); if (isLogUrlOnStart()) dumpUrl(); } catch (Throwable t) { // start up of the webapp context failed, make sure it is not started LOG.warn("Failed startup of context "+this, t); _unavailableException=t; setAvailable(false); // webapp cannot be accessed (results in status code 503) if (isThrowUnavailableOnStartupException()) throw t; } }
Map<Resource, Resource> fragments = (Map<Resource,Resource>)context.getAttribute(METAINF_FRAGMENTS); if (fragments == null)
Set<Resource> dirs = (Set<Resource>)context.getAttribute(METAINF_RESOURCES); if (dirs == null)
Set<Resource> resources = (Set<Resource>)context.getAttribute(RESOURCE_DIRS); if (resources!=null && !resources.isEmpty())
LOG.debug("Configure: "+jetty); Object xml_attr=context.getAttribute(XML_CONFIGURATION); context.removeAttribute(XML_CONFIGURATION); final XmlConfiguration jetty_config = xml_attr instanceof XmlConfiguration?(XmlConfiguration)xml_attr:new XmlConfiguration(jetty.getURI().toURL());
/** * Get the value in the webapp context. * @param name The name of the attribute * @return The value of the attribute */ public Object getAttribute(String name) { return webAppContext.getAttribute(name); }
@Override public void preConfigure(final WebAppContext context) throws Exception { String tmp = (String)context.getAttribute(SERVLET_CONTAINER_INITIALIZER_EXCLUSION_PATTERN); _sciExcludePattern = (tmp==null?null:Pattern.compile(tmp)); }
public void addResource (WebAppContext context, String attribute, Resource jar) { @SuppressWarnings("unchecked") List<Resource> list = (List<Resource>)context.getAttribute(attribute); if (list==null) { list=new ArrayList<Resource>(); context.setAttribute(attribute,list); } if (!list.contains(jar)) list.add(jar); }
public void addResource (WebAppContext context, String attribute, Resource jar) { @SuppressWarnings("unchecked") List<Resource> list = (List<Resource>)context.getAttribute(attribute); if (list==null) { list=new ArrayList<Resource>(); context.setAttribute(attribute,list); } if (!list.contains(jar)) list.add(jar); }
public void addResource (WebAppContext context, String attribute, Resource jar) { @SuppressWarnings("unchecked") List<Resource> list = (List<Resource>)context.getAttribute(attribute); if (list==null) { list=new ArrayList<Resource>(); context.setAttribute(attribute,list); } if (!list.contains(jar)) list.add(jar); }
public void addResource (WebAppContext context, String attribute, Resource jar) { @SuppressWarnings("unchecked") List<Resource> list = (List<Resource>)context.getAttribute(attribute); if (list==null) { list=new ArrayList<Resource>(); context.setAttribute(attribute,list); } if (!list.contains(jar)) list.add(jar); }