summaryrefslogtreecommitdiffstats
path: root/weaver
diff options
context:
space:
mode:
authoracolyer <acolyer>2005-03-23 16:47:55 +0000
committeracolyer <acolyer>2005-03-23 16:47:55 +0000
commit68f63508828d1c1ea7076d051cc77713625f6a03 (patch)
tree40e125609a1fbfe8423f7e439d88da6b997668c4 /weaver
parentef3044a08dd1e5556c03e614ce8d799d61aaf041 (diff)
downloadaspectj-68f63508828d1c1ea7076d051cc77713625f6a03.tar.gz
aspectj-68f63508828d1c1ea7076d051cc77713625f6a03.zip
fix for Bug 84122 - Allow aspectPath to contain directories
Diffstat (limited to 'weaver')
-rw-r--r--weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java57
1 files changed, 41 insertions, 16 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
index 1caa54574..3f1134b6f 100644
--- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
+++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java
@@ -142,10 +142,22 @@ public class BcelWeaver implements IWeaver {
public void addLibraryJarFile(File inFile) throws IOException {
- ZipInputStream inStream = new ZipInputStream(new FileInputStream(inFile)); //??? buffered
+ List addedAspects = null;
+ if (inFile.isDirectory()) {
+ addedAspects = addAspectsFromDirectory(inFile);
+ } else {
+ addedAspects = addAspectsFromJarFile(inFile);
+ }
+ for (Iterator i = addedAspects.iterator(); i.hasNext();) {
+ ResolvedTypeX aspectX = (ResolvedTypeX) i.next();
+ xcutSet.addOrReplaceAspect(aspectX);
+ }
+ }
+
+ private List addAspectsFromJarFile(File inFile) throws FileNotFoundException, IOException {
+ ZipInputStream inStream = new ZipInputStream(new FileInputStream(inFile)); //??? buffered
List addedAspects = new ArrayList();
-
while (true) {
ZipEntry entry = inStream.getNextEntry();
if (entry == null) break;
@@ -154,25 +166,38 @@ public class BcelWeaver implements IWeaver {
continue;
}
- ClassParser parser = new ClassParser(new ByteArrayInputStream(FileUtil.readAsByteArray(inStream)), entry.getName());
- JavaClass jc = parser.parse();
- inStream.closeEntry();
-
- ResolvedTypeX type = world.addSourceObjectType(jc).getResolvedTypeX();
- if (type.isAspect()) {
- addedAspects.add(type);
- }
-
+ addIfAspect(FileUtil.readAsByteArray(inStream), entry.getName(), addedAspects);
+ inStream.closeEntry();
}
-
inStream.close();
+ return addedAspects;
+ }
+
+ private List addAspectsFromDirectory(File dir) throws FileNotFoundException, IOException{
+ List addedAspects = new ArrayList();
+ File[] classFiles = FileUtil.listFiles(dir,new FileFilter(){
- for (Iterator i = addedAspects.iterator(); i.hasNext();) {
- ResolvedTypeX aspectX = (ResolvedTypeX) i.next();
- xcutSet.addOrReplaceAspect(aspectX);
+ public boolean accept(File pathname) {
+ return pathname.getName().endsWith(".class");
+ }
+
+ });
+ for (int i = 0; i < classFiles.length; i++) {
+ FileInputStream fis = new FileInputStream(classFiles[i]);
+ byte[] bytes = FileUtil.readAsByteArray(fis);
+ addIfAspect(bytes,classFiles[i].getAbsolutePath(),addedAspects);
}
+ return addedAspects;
+ }
+
+ private void addIfAspect(byte[] bytes, String name, List toList) throws IOException {
+ ClassParser parser = new ClassParser(new ByteArrayInputStream(bytes),name);
+ JavaClass jc = parser.parse();
+ ResolvedTypeX type = world.addSourceObjectType(jc).getResolvedTypeX();
+ if (type.isAspect()) {
+ toList.add(type);
+ }
}
-
// // The ANT copy task should be used to copy resources across.
// private final static boolean CopyResourcesFromInpathDirectoriesToOutput=false;