@Override public String toString() { StringBuilder buf = new StringBuilder(32); buf.append("Name: "); buf.append(getName()); buf.append(", URL: "); buf.append(getURL()); return buf.toString(); }
@Override public String toString() { StringBuilder buf = new StringBuilder(32); buf.append("Name: "); buf.append(getName()); buf.append(", URL: "); buf.append(getURL()); return buf.toString(); }
@Override public String toString() { StringBuilder buf = new StringBuilder(32); buf.append("Name: "); buf.append(getName()); buf.append(", URL: "); buf.append(getURL()); return buf.toString(); }
private boolean mergeLifecycleCallback( Map<String, String> fragmentMap, Map<String, String> tempMap, WebXml fragment, String mapName) { for (Entry<String, String> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals(tempMap.get(key))) { log.error(sm.getString("webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } return true; }
private static <T> boolean mergeLifecycleCallback( Map<String, String> fragmentMap, Map<String, String> tempMap, WebXml fragment, String mapName) { for (Entry<String, String> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals(tempMap.get(key))) { log.error(sm.getString("webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } return true; }
private List<URL> scanForResourceJARs(Set<WebXml> orderedFragments, Collection<WebXml> fragments) throws JasperException { List<URL> resourceJars = new ArrayList<>(); // Build list of potential resource JARs. Use same ordering as ContextConfig Set<WebXml> resourceFragments = new LinkedHashSet<>(); for (WebXml fragment : orderedFragments) { resourceFragments.add(fragment); } for (WebXml fragment : fragments) { if (!resourceFragments.contains(fragment)) { resourceFragments.add(fragment); } } for (WebXml resourceFragment : resourceFragments) { try (Jar jar = JarFactory.newInstance(resourceFragment.getURL())) { if (jar.exists("META-INF/resources/")) { // This is a resource JAR resourceJars.add(resourceFragment.getURL()); } } catch (IOException ioe) { throw new JasperException(ioe); } } return resourceJars; }
private boolean mergeLifecycleCallback( Map<String, String> fragmentMap, Map<String, String> tempMap, WebXml fragment, String mapName) { for (Entry<String, String> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); final String value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals(tempMap.get(key))) { log.error(sm.getString("webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } return true; }
private <T> boolean mergeMap(Map<String,T> fragmentMap, Map<String,T> mainMap, Map<String,T> tempMap, WebXml fragment, String mapName) { for (Entry<String, T> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); if (!mainMap.containsKey(key)) { // Not defined in main web.xml T value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals( tempMap.get(key))) { log.error(sm.getString( "webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } } return true; }
private static <T> boolean mergeMap(Map<String,T> fragmentMap, Map<String,T> mainMap, Map<String,T> tempMap, WebXml fragment, String mapName) { for (Entry<String, T> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); if (!mainMap.containsKey(key)) { // Not defined in main web.xml T value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals( tempMap.get(key))) { log.error(sm.getString( "webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } } return true; }
private <T> boolean mergeMap(Map<String,T> fragmentMap, Map<String,T> mainMap, Map<String,T> tempMap, WebXml fragment, String mapName) { for (Entry<String, T> entry : fragmentMap.entrySet()) { final String key = entry.getKey(); if (!mainMap.containsKey(key)) { // Not defined in main web.xml T value = entry.getValue(); if (tempMap.containsKey(key)) { if (value != null && !value.equals( tempMap.get(key))) { log.error(sm.getString( "webXml.mergeConflictString", mapName, key, fragment.getName(), fragment.getURL())); return false; } } else { tempMap.put(key, value); } } } return true; }
@Override public void scan(File file, String webappPath, boolean isWebapp) throws IOException { InputStream stream = null; WebXml fragment = new WebXml(); fragment.setWebappJar(isWebapp); fragment.setDelegate(delegate); try { File fragmentFile = new File(file, FRAGMENT_LOCATION); if (fragmentFile.isFile()) { stream = new FileInputStream(fragmentFile); InputSource source = new InputSource(fragmentFile.toURI().toURL().toString()); source.setByteStream(stream); if (!webXmlParser.parseWebXml(source, fragment, true)) { ok = false; } } else { // If there is no web.xml, normal folder no impact on // distributable fragment.setDistributable(true); } } finally { fragment.setURL(file.toURI().toURL()); if (fragment.getName() == null) { fragment.setName(fragment.getURL().toString()); } fragment.setJarName(file.getName()); fragments.put(fragment.getName(), fragment); } }
@Override protected void processClasses(final WebXml webXml, final Set<WebXml> orderedFragments) { final ClassLoader loader = context.getLoader().getClassLoader(); orderedFragments.forEach(fragment -> { final WebXml annotations = new WebXml(); annotations.setDistributable(true); final URL url = fragment.getURL(); final Collection<Class<?>> classes = webClasses.get(url.toExternalForm()); if (classes == null) { return; } classes.forEach(clazz -> { try (final InputStream stream = loader.getResourceAsStream(clazz.getName().replace('.', '/') + ".class")) { processClass(annotations, new ClassParser(stream).parse()); } catch (final IOException e) { new LogFacade(MeecrowaveContextConfig.class.getName()).error("Can't parse " + clazz); } }); fragment.merge(singleton(annotations)); }); }
@Override public void scan(File file, String webappPath, boolean isWebapp) throws IOException { WebXml fragment = new WebXml(); fragment.setWebappJar(isWebapp); fragment.setDelegate(delegate); File fragmentFile = new File(file, FRAGMENT_LOCATION); try { if (fragmentFile.isFile()) { try (InputStream stream = new FileInputStream(fragmentFile)) { InputSource source = new InputSource(fragmentFile.toURI().toURL().toString()); source.setByteStream(stream); if (!webXmlParser.parseWebXml(source, fragment, true)) { ok = false; } } } else { // If there is no web.xml, normal folder no impact on // distributable fragment.setDistributable(true); } } finally { fragment.setURL(file.toURI().toURL()); if (fragment.getName() == null) { fragment.setName(fragment.getURL().toString()); } fragment.setJarName(file.getName()); fragments.put(fragment.getName(), fragment); } }
@Override protected void processClasses(final WebXml webXml, final Set<WebXml> orderedFragments) { final ClassLoader loader = context.getLoader().getClassLoader(); orderedFragments.forEach(fragment -> { final WebXml annotations = new WebXml(); annotations.setDistributable(true); final URL url = fragment.getURL(); final Collection<Class<?>> classes = webClasses.get(url.toExternalForm()); if (classes == null) { return; } classes.forEach(clazz -> { try (final InputStream stream = loader.getResourceAsStream(clazz.getName().replace('.', '/') + ".class")) { processClass(annotations, new ClassParser(stream).parse()); } catch (final IOException e) { new LogFacade(MeecrowaveContextConfig.class.getName()).error("Can't parse " + clazz); } }); fragment.merge(singleton(annotations)); }); }
private <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
private <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
private static <T extends ResourceBase> boolean mergeResourceMap( Map<String, T> fragmentResources, Map<String, T> mainResources, Map<String, T> tempResources, WebXml fragment) { for (T resource : fragmentResources.values()) { String resourceName = resource.getName(); if (mainResources.containsKey(resourceName)) { mainResources.get(resourceName).getInjectionTargets().addAll( resource.getInjectionTargets()); } else { // Not defined in main web.xml T existingResource = tempResources.get(resourceName); if (existingResource != null) { if (!existingResource.equals(resource)) { log.error(sm.getString( "webXml.mergeConflictResource", resourceName, fragment.getName(), fragment.getURL())); return false; } } else { tempResources.put(resourceName, resource); } } } return true; }
protected void processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly) { for(WebXml fragment : fragments) { // Only need to scan for @HandlesTypes matches if any of the // following are true: // - it has already been determined only @HandlesTypes is required // (e.g. main web.xml has metadata-complete="true" // - this fragment is for a container JAR (Servlet 3.1 section 8.1) // - this fragment has metadata-complete="true" boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() || fragment.isMetadataComplete(); WebXml annotations = new WebXml(); // no impact on distributable annotations.setDistributable(true); URL url = fragment.getURL(); processAnnotationsUrl(url, annotations, htOnly); Set<WebXml> set = new HashSet<>(); set.add(annotations); // Merge annotations into fragment - fragment takes priority fragment.merge(set); } }
protected void processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache) { for(WebXml fragment : fragments) { // Only need to scan for @HandlesTypes matches if any of the // following are true: // - it has already been determined only @HandlesTypes is required // (e.g. main web.xml has metadata-complete="true" // - this fragment is for a container JAR (Servlet 3.1 section 8.1) // - this fragment has metadata-complete="true" boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() || fragment.isMetadataComplete(); WebXml annotations = new WebXml(); // no impact on distributable annotations.setDistributable(true); URL url = fragment.getURL(); processAnnotationsUrl(url, annotations, htOnly, javaClassCache); Set<WebXml> set = new HashSet<>(); set.add(annotations); // Merge annotations into fragment - fragment takes priority fragment.merge(set); } }
protected void processAnnotations(Set<WebXml> fragments, boolean handlesTypesOnly, Map<String,JavaClassCacheEntry> javaClassCache) { for(WebXml fragment : fragments) { // Only need to scan for @HandlesTypes matches if any of the // following are true: // - it has already been determined only @HandlesTypes is required // (e.g. main web.xml has metadata-complete="true" // - this fragment is for a container JAR (Servlet 3.1 section 8.1) // - this fragment has metadata-complete="true" boolean htOnly = handlesTypesOnly || !fragment.getWebappJar() || fragment.isMetadataComplete(); WebXml annotations = new WebXml(); // no impact on distributable annotations.setDistributable(true); URL url = fragment.getURL(); processAnnotationsUrl(url, annotations, htOnly, javaClassCache); Set<WebXml> set = new HashSet<>(); set.add(annotations); // Merge annotations into fragment - fragment takes priority fragment.merge(set); } }