@@ -34,6 +34,7 @@ import java.util.Map; | |||
import java.util.Properties; | |||
import java.util.Set; | |||
import java.util.Stack; | |||
import java.util.stream.Collectors; | |||
import org.apache.tools.ant.launch.Launcher; | |||
import org.apache.tools.ant.taskdefs.Definer; | |||
@@ -228,7 +229,8 @@ public class ComponentHelper { | |||
public void initSubProject(ComponentHelper helper) { | |||
// add the types of the parent project | |||
@SuppressWarnings("unchecked") | |||
final Hashtable<String, AntTypeDefinition> typeTable = (Hashtable<String, AntTypeDefinition>) helper.antTypeTable.clone(); | |||
final Hashtable<String, AntTypeDefinition> typeTable | |||
= (Hashtable<String, AntTypeDefinition>) helper.antTypeTable.clone(); | |||
synchronized (antTypeTable) { | |||
for (AntTypeDefinition def : typeTable.values()) { | |||
antTypeTable.put(def.getName(), def); | |||
@@ -239,7 +241,8 @@ public class ComponentHelper { | |||
synchronized (this) { | |||
checkedNamespaces.addAll(inheritedCheckedNamespace); | |||
} | |||
Map<String, List<AntTypeDefinition>> inheritedRestrictedDef = helper.getRestrictedDefinition(); | |||
Map<String, List<AntTypeDefinition>> inheritedRestrictedDef | |||
= helper.getRestrictedDefinition(); | |||
synchronized (restrictedDefinitions) { | |||
restrictedDefinitions.putAll(inheritedRestrictedDef); | |||
} | |||
@@ -398,15 +401,11 @@ public class ComponentHelper { | |||
synchronized (antTypeTable) { | |||
if (rebuildTaskClassDefinitions) { | |||
taskClassDefinitions.clear(); | |||
for (Map.Entry<String, AntTypeDefinition> e : antTypeTable.entrySet()) { | |||
final Class<?> clazz = e.getValue().getExposedClass(project); | |||
if (clazz == null) { | |||
continue; | |||
} | |||
if (Task.class.isAssignableFrom(clazz)) { | |||
taskClassDefinitions.put(e.getKey(), e.getValue().getTypeClass(project)); | |||
} | |||
} | |||
antTypeTable.entrySet().stream() | |||
.filter(e -> e.getValue().getExposedClass(project) != null | |||
&& Task.class.isAssignableFrom(e.getValue().getExposedClass(project))) | |||
.forEach(e -> taskClassDefinitions.put(e.getKey(), | |||
e.getValue().getTypeClass(project))); | |||
rebuildTaskClassDefinitions = false; | |||
} | |||
} | |||
@@ -426,15 +425,11 @@ public class ComponentHelper { | |||
synchronized (antTypeTable) { | |||
if (rebuildTypeClassDefinitions) { | |||
typeClassDefinitions.clear(); | |||
for (Map.Entry<String, AntTypeDefinition> e : antTypeTable.entrySet()) { | |||
final Class<?> clazz = e.getValue().getExposedClass(project); | |||
if (clazz == null) { | |||
continue; | |||
} | |||
if (!Task.class.isAssignableFrom(clazz)) { | |||
typeClassDefinitions.put(e.getKey(), e.getValue().getTypeClass(project)); | |||
} | |||
} | |||
antTypeTable.entrySet().stream() | |||
.filter(e -> e.getValue().getExposedClass(project) != null | |||
&& !Task.class.isAssignableFrom(e.getValue().getExposedClass(project))) | |||
.forEach(e -> typeClassDefinitions.put(e.getKey(), | |||
e.getValue().getTypeClass(project))); | |||
rebuildTypeClassDefinitions = false; | |||
} | |||
} | |||
@@ -1077,14 +1072,9 @@ public class ComponentHelper { | |||
* @return the (possibly empty) list of definitions | |||
*/ | |||
private List<AntTypeDefinition> findTypeMatches(String prefix) { | |||
final List<AntTypeDefinition> result = new ArrayList<>(); | |||
synchronized (antTypeTable) { | |||
for (AntTypeDefinition def : antTypeTable.values()) { | |||
if (def.getName().startsWith(prefix)) { | |||
result.add(def); | |||
} | |||
} | |||
return antTypeTable.values().stream().filter(def -> def.getName().startsWith(prefix)) | |||
.collect(Collectors.toList()); | |||
} | |||
return result; | |||
} | |||
} |
@@ -43,10 +43,6 @@ public class RuntimeConfigurable implements Serializable { | |||
/** Serialization version */ | |||
private static final long serialVersionUID = 1L; | |||
/** Empty Hashtable. */ | |||
private static final Hashtable<String, Object> EMPTY_HASHTABLE = | |||
new Hashtable<>(0); | |||
/** Name of the element to configure. */ | |||
private String elementTag = null; | |||
@@ -336,8 +332,7 @@ public class RuntimeConfigurable implements Serializable { | |||
* @since Ant 1.6 | |||
*/ | |||
public synchronized Hashtable<String, Object> getAttributeMap() { | |||
return (attributeMap == null) | |||
? EMPTY_HASHTABLE : new Hashtable<>(attributeMap); | |||
return new Hashtable<>(attributeMap == null ? Collections.emptyMap() : attributeMap); | |||
} | |||
/** | |||
@@ -25,13 +25,13 @@ import java.io.Writer; | |||
import java.nio.file.Files; | |||
import java.nio.file.Paths; | |||
import java.util.Hashtable; | |||
import java.util.Map; | |||
import java.util.Stack; | |||
import javax.xml.parsers.DocumentBuilder; | |||
import javax.xml.parsers.DocumentBuilderFactory; | |||
import org.apache.tools.ant.util.DOMElementWriter; | |||
import org.apache.tools.ant.util.StreamUtils; | |||
import org.apache.tools.ant.util.StringUtils; | |||
import org.w3c.dom.Document; | |||
import org.w3c.dom.Element; | |||
@@ -108,16 +108,16 @@ public class XmlLogger implements BuildLogger { | |||
private Document doc = builder.newDocument(); | |||
/** Mapping for when tasks started (Task to TimedElement). */ | |||
private Hashtable<Task, TimedElement> tasks = new Hashtable<>(); | |||
private Map<Task, TimedElement> tasks = new Hashtable<>(); | |||
/** Mapping for when targets started (Target to TimedElement). */ | |||
private Hashtable<Target, TimedElement> targets = new Hashtable<>(); | |||
private Map<Target, TimedElement> targets = new Hashtable<>(); | |||
/** | |||
* Mapping of threads to stacks of elements | |||
* (Thread to Stack of TimedElement). | |||
*/ | |||
private Hashtable<Thread, Stack<TimedElement>> threadStacks = new Hashtable<>(); | |||
private Map<Thread, Stack<TimedElement>> threadStacks = new Hashtable<>(); | |||
/** | |||
* When the build started. | |||
@@ -345,8 +345,7 @@ public class XmlLogger implements BuildLogger { | |||
if (element != null) { | |||
return element; | |||
} | |||
return StreamUtils.enumerationAsStream(tasks.keys()) | |||
.filter(UnknownElement.class::isInstance) | |||
return tasks.keySet().stream().filter(UnknownElement.class::isInstance) | |||
.filter(key -> ((UnknownElement) key).getTask() == task).findFirst() | |||
.map(key -> tasks.get(key)).orElse(null); | |||
} | |||
@@ -19,11 +19,10 @@ | |||
package org.apache.tools.ant.attribute; | |||
import java.util.HashMap; | |||
import java.util.Hashtable; | |||
import java.util.Map; | |||
import java.util.stream.Collectors; | |||
import org.apache.tools.ant.ProjectComponent; | |||
import org.apache.tools.ant.RuntimeConfigurable; | |||
import org.apache.tools.ant.UnknownElement; | |||
@@ -68,17 +67,10 @@ public abstract class BaseIfAttribute | |||
* @return a map of attributes. | |||
*/ | |||
protected Map<String, String> getParams(UnknownElement el) { | |||
Map<String, String> ret = new HashMap<>(); | |||
RuntimeConfigurable rc = el.getWrapper(); | |||
Hashtable<String, Object> attributes = rc.getAttributeMap(); // This does a copy! | |||
for (Map.Entry<String, Object> entry : attributes.entrySet()) { | |||
String key = entry.getKey(); | |||
if (key.startsWith("ant-attribute:param")) { | |||
int pos = key.lastIndexOf(':'); | |||
ret.put(key.substring(pos + 1), | |||
el.getProject().replaceProperties((String) entry.getValue())); | |||
} | |||
} | |||
return ret; | |||
// this makes a copy! | |||
return el.getWrapper().getAttributeMap().entrySet().stream() | |||
.filter(e -> e.getKey().startsWith("ant-attribute:param")) | |||
.collect(Collectors.toMap(e -> e.getKey().substring(e.getKey().lastIndexOf(':') + 1), | |||
e -> el.getProject().replaceProperties((String) e.getValue()), (a, b) -> b)); | |||
} | |||
} |
@@ -18,6 +18,7 @@ | |||
package org.apache.tools.ant.taskdefs; | |||
import java.util.Hashtable; | |||
import java.util.Map; | |||
import org.apache.tools.ant.BuildEvent; | |||
import org.apache.tools.ant.BuildException; | |||
@@ -66,7 +67,7 @@ public class Recorder extends Task implements SubBuildListener { | |||
/** Strip task banners if true. */ | |||
private boolean emacsMode = false; | |||
/** The list of recorder entries. */ | |||
private static Hashtable<String, RecorderEntry> recorderEntries = new Hashtable<>(); | |||
private static Map<String, RecorderEntry> recorderEntries = new Hashtable<>(); | |||
////////////////////////////////////////////////////////////////////// | |||
// CONSTRUCTORS / INITIALIZERS | |||
@@ -304,11 +305,8 @@ public class Recorder extends Task implements SubBuildListener { | |||
* | |||
* @since Ant 1.7 | |||
*/ | |||
@SuppressWarnings("unchecked") | |||
private void cleanup() { | |||
((Hashtable<String, RecorderEntry>) recorderEntries.clone()).entrySet().stream() | |||
.filter(entry -> entry.getValue().getProject() == getProject()) | |||
.forEach(entry -> recorderEntries.remove(entry.getKey())); | |||
recorderEntries.entrySet().removeIf(e -> e.getValue().getProject() == getProject()); | |||
getProject().removeBuildListener(this); | |||
} | |||
} |
@@ -16,10 +16,8 @@ | |||
* | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
import java.io.BufferedReader; | |||
import java.io.File; | |||
import java.io.IOException; | |||
@@ -31,6 +29,7 @@ import java.util.Collection; | |||
import java.util.Hashtable; | |||
import java.util.List; | |||
import java.util.Map; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.taskdefs.ExecTask; | |||
@@ -41,7 +40,6 @@ import org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.DTDLocation; | |||
import org.apache.tools.ant.types.Commandline; | |||
import org.apache.tools.ant.types.Path; | |||
/** | |||
* BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 and 4.5.1 | |||
* This task generates and compiles the stubs and skeletons for all ejb described into the | |||
@@ -60,7 +58,7 @@ import org.apache.tools.ant.types.Path; | |||
* <li>version (int) : tell what is the Borland appserver version 4 or 5 </li> | |||
* </ul> | |||
* | |||
*<PRE> | |||
*<pre> | |||
* | |||
* <ejbjar srcdir="${build.classes}" | |||
* basejarname="vsmp" | |||
@@ -74,7 +72,7 @@ import org.apache.tools.ant.types.Path; | |||
* <include name="demo\helper\*.class"/> | |||
* </support> | |||
* </ejbjar> | |||
*</PRE> | |||
*</pre> | |||
* | |||
*/ | |||
public class BorlandDeploymentTool extends GenericDeploymentTool | |||
@@ -23,6 +23,7 @@ import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.net.URL; | |||
import java.nio.file.Files; | |||
import java.util.Collections; | |||
import java.util.Hashtable; | |||
import java.util.Map; | |||
@@ -233,7 +234,7 @@ public class DescriptorHandler extends HandlerBase { | |||
* @return the map of files | |||
*/ | |||
public Hashtable<String, File> getFiles() { | |||
return ejbFiles == null ? new Hashtable<>() : ejbFiles; | |||
return new Hashtable<>(ejbFiles == null ? Collections.emptyMap() : ejbFiles); | |||
} | |||
/** | |||
@@ -21,13 +21,16 @@ import java.io.File; | |||
import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.nio.file.Files; | |||
import java.util.Enumeration; | |||
import java.util.Hashtable; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.Vector; | |||
import java.util.jar.JarEntry; | |||
import java.util.jar.JarFile; | |||
import java.util.jar.JarOutputStream; | |||
import java.util.stream.Collectors; | |||
import java.util.zip.ZipEntry; | |||
import javax.xml.parsers.SAXParser; | |||
import javax.xml.parsers.SAXParserFactory; | |||
@@ -36,7 +39,6 @@ import org.apache.tools.ant.AntClassLoader; | |||
import org.apache.tools.ant.BuildException; | |||
import org.apache.tools.ant.Project; | |||
import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.DTDLocation; | |||
import org.apache.tools.ant.types.Environment; | |||
import org.apache.tools.ant.types.Environment.Variable; | |||
import org.apache.tools.ant.types.Path; | |||
@@ -424,9 +426,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
handler.registerDTD(PUBLICID_WEBLOGIC_EJB510, weblogicDTD); | |||
handler.registerDTD(PUBLICID_WEBLOGIC_EJB600, weblogicDTD); | |||
for (DTDLocation dtdLocation : getConfig().dtdLocations) { | |||
handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation()); | |||
} | |||
getConfig().dtdLocations.forEach(l -> handler.registerDTD(l.getPublicId(), l.getLocation())); | |||
return handler; | |||
} | |||
@@ -685,73 +685,62 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
genericJar = new JarFile(genericJarFile); | |||
wlJar = new JarFile(weblogicJarFile); | |||
Hashtable<String, JarEntry> genericEntries = new Hashtable<>(); | |||
Hashtable<String, JarEntry> wlEntries = new Hashtable<>(); | |||
Hashtable<String, JarEntry> replaceEntries = new Hashtable<>(); | |||
Map<String, JarEntry> replaceEntries = new HashMap<>(); | |||
//get the list of generic jar entries | |||
for (Enumeration<JarEntry> e = genericJar.entries(); e.hasMoreElements();) { | |||
JarEntry je = e.nextElement(); | |||
genericEntries.put(je.getName().replace('\\', '/'), je); | |||
} | |||
Map<String, JarEntry> genericEntries = genericJar.stream() | |||
.collect(Collectors.toMap(je -> je.getName().replace('\\', '/'), | |||
je -> je, (a, b) -> b)); | |||
// get the list of WebLogic jar entries | |||
for (Enumeration<JarEntry> e = wlJar.entries(); e.hasMoreElements();) { | |||
JarEntry je = e.nextElement(); | |||
wlEntries.put(je.getName(), je); | |||
} | |||
Map<String, JarEntry> wlEntries = wlJar.stream().collect(Collectors.toMap(ZipEntry::getName, | |||
je -> je, (a, b) -> b)); | |||
// Cycle through generic and make sure its in WebLogic | |||
genericLoader = getClassLoaderFromJar(genericJarFile); | |||
for (Enumeration<String> e = genericEntries.keys(); e.hasMoreElements();) { | |||
String filepath = e.nextElement(); | |||
if (wlEntries.containsKey(filepath)) { | |||
// File name/path match | |||
// Check files see if same | |||
JarEntry genericEntry = genericEntries.get(filepath); | |||
JarEntry wlEntry = wlEntries.get(filepath); | |||
for (String filepath : genericEntries.keySet()) { | |||
if (!wlEntries.containsKey(filepath)) { | |||
// a file doesn't exist rebuild | |||
log("File " + filepath + " not present in weblogic jar", | |||
Project.MSG_VERBOSE); | |||
rebuild = true; | |||
break; | |||
} | |||
// File name/path match | |||
// Check files see if same | |||
JarEntry genericEntry = genericEntries.get(filepath); | |||
JarEntry wlEntry = wlEntries.get(filepath); | |||
if (genericEntry.getCrc() != wlEntry.getCrc() | |||
|| genericEntry.getSize() != wlEntry.getSize()) { | |||
if (genericEntry.getCrc() != wlEntry.getCrc() | |||
|| genericEntry.getSize() != wlEntry.getSize()) { | |||
if (genericEntry.getName().endsWith(".class")) { | |||
//File are different see if its an object or an interface | |||
String classname | |||
= genericEntry.getName() | |||
if (genericEntry.getName().endsWith(".class")) { | |||
//File are different see if its an object or an interface | |||
String classname = genericEntry.getName() | |||
.replace(File.separatorChar, '.') | |||
.replace('/', '.'); | |||
classname = classname.substring(0, classname.lastIndexOf(".class")); | |||
Class<?> genclass = genericLoader.loadClass(classname); | |||
if (genclass.isInterface()) { | |||
//Interface changed rebuild jar. | |||
log("Interface " + genclass.getName() | |||
+ " has changed", Project.MSG_VERBOSE); | |||
rebuild = true; | |||
break; | |||
} | |||
//Object class Changed update it. | |||
replaceEntries.put(filepath, genericEntry); | |||
} else if (!"META-INF/MANIFEST.MF".equals(genericEntry.getName())) { | |||
// it is not the manifest, otherwise we'd ignore it | |||
// File other then class changed rebuild | |||
log("Non class file " + genericEntry.getName() | |||
classname = classname.substring(0, classname.lastIndexOf(".class")); | |||
Class<?> genclass = genericLoader.loadClass(classname); | |||
if (genclass.isInterface()) { | |||
//Interface changed rebuild jar. | |||
log("Interface " + genclass.getName() | |||
+ " has changed", Project.MSG_VERBOSE); | |||
rebuild = true; | |||
break; | |||
} | |||
//Object class Changed update it. | |||
replaceEntries.put(filepath, genericEntry); | |||
} else if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) { | |||
// it is not the manifest, otherwise we'd ignore it | |||
// File other then class changed rebuild | |||
log("Non class file " + genericEntry.getName() | |||
+ " has changed", Project.MSG_VERBOSE); | |||
rebuild = true; | |||
break; | |||
} | |||
} else { | |||
// a file doesn't exist rebuild | |||
log("File " + filepath + " not present in weblogic jar", | |||
Project.MSG_VERBOSE); | |||
rebuild = true; | |||
break; | |||
} | |||
} | |||
@@ -22,6 +22,8 @@ import java.io.IOException; | |||
import java.io.InputStream; | |||
import java.nio.file.Files; | |||
import java.util.Hashtable; | |||
import java.util.HashMap; | |||
import java.util.Map; | |||
import java.util.jar.JarEntry; | |||
import java.util.jar.JarFile; | |||
import java.util.jar.JarOutputStream; | |||
@@ -35,7 +37,6 @@ import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.types.Environment; | |||
import org.apache.tools.ant.types.Path; | |||
import org.apache.tools.ant.util.FileUtils; | |||
import org.apache.tools.ant.util.StreamUtils; | |||
/** | |||
* WebSphere deployment tool that augments the ejbjar task. | |||
@@ -667,21 +668,18 @@ public class WebsphereDeploymentTool extends GenericDeploymentTool { | |||
wasJar = new JarFile(websphereJarFile); | |||
//get the list of generic jar entries | |||
Hashtable<String, JarEntry> genericEntries | |||
= StreamUtils.enumerationAsStream(genericJar.entries()) | |||
Map<String, JarEntry> genericEntries = genericJar.stream() | |||
.collect(Collectors.toMap(je -> je.getName().replace('\\', '/'), | |||
je -> je, (a, b) -> b, Hashtable::new)); | |||
je -> je, (a, b) -> b)); | |||
// get the list of WebSphere jar entries | |||
Hashtable<String, JarEntry> wasEntries | |||
= StreamUtils.enumerationAsStream(wasJar.entries()) | |||
.collect(Collectors.toMap(ZipEntry::getName, | |||
je -> je, (a, b) -> b, Hashtable::new)); | |||
Map<String, JarEntry> wasEntries = wasJar.stream() | |||
.collect(Collectors.toMap(ZipEntry::getName, je -> je, (a, b) -> b)); | |||
// Cycle through generic and make sure its in WebSphere | |||
genericLoader = getClassLoaderFromJar(genericJarFile); | |||
Hashtable<String, JarEntry> replaceEntries = new Hashtable<>(); | |||
Map<String, JarEntry> replaceEntries = new HashMap<>(); | |||
for (String filepath : genericEntries.keySet()) { | |||
if (!wasEntries.containsKey(filepath)) { | |||
// a file doesn't exist rebuild | |||