/** Resolve all servlet/filter/listener metadata from all sources: descriptors and annotations. */ public void resolve(WebAppContext context) throws Exception { LOG.debug("metadata resolve {}", context); // Ensure origins is fresh _origins.clear(); // Set the ordered lib attribute if (_ordering != null) { List<String> orderedLibs = new ArrayList<String>(); for (Resource webInfJar : _orderedWebInfJars) { // get just the name of the jar file String fullname = webInfJar.getName(); int i = fullname.indexOf(".jar"); int j = fullname.lastIndexOf("/", i); orderedLibs.add(fullname.substring(j + 1, i + 4)); } context.setAttribute(ServletContext.ORDERED_LIBS, orderedLibs); } // set the webxml version if (_webXmlRoot != null) { context.getServletContext().setEffectiveMajorVersion(_webXmlRoot.getMajorVersion()); context.getServletContext().setEffectiveMinorVersion(_webXmlRoot.getMinorVersion()); } for (DescriptorProcessor p : _descriptorProcessors) { p.process(context, getWebDefault()); p.process(context, getWebXml()); for (WebDescriptor wd : getOverrideWebs()) { LOG.debug("process {} {}", context, wd); p.process(context, wd); } } // get an apply the annotations that are not associated with a fragment (and hence for // which no ordering applies List<DiscoveredAnnotation> nonFragAnnotations = _annotations.get(NON_FRAG_RESOURCE); if (nonFragAnnotations != null) { for (DiscoveredAnnotation a : nonFragAnnotations) { LOG.debug("apply {}", a); a.apply(); } } // apply the annotations that are associated with a fragment, according to the // established ordering List<Resource> resources = getOrderedWebInfJars(); for (Resource r : resources) { FragmentDescriptor fd = _webFragmentResourceMap.get(r); if (fd != null) { for (DescriptorProcessor p : _descriptorProcessors) { LOG.debug("process {} {}", context, fd); p.process(context, fd); } } List<DiscoveredAnnotation> fragAnnotations = _annotations.get(r); if (fragAnnotations != null) { for (DiscoveredAnnotation a : fragAnnotations) { LOG.debug("apply {}", a); a.apply(); } } } }