Remove obsolete mangen and maven2 modules
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1695266 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/tools/mangen/pom.xml b/tools/mangen/pom.xml
deleted file mode 100644
index d1aa87a..0000000
--- a/tools/mangen/pom.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-<project>
- <parent>
- <groupId>org.apache.felix</groupId>
- <artifactId>felix</artifactId>
- <version>1.4.0</version>
- <relativePath>../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <packaging>jar</packaging>
- <name>Apache Felix Bundle Manifest Generator (mangen)</name>
- <artifactId>org.apache.felix.tool.mangen</artifactId>
- <version>1.0.1</version>
- <dependencies>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>${pom.groupId}</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>asm</groupId>
- <artifactId>asm</artifactId>
- <version>2.2.1</version>
- </dependency>
- <dependency>
- <groupId>bcel</groupId>
- <artifactId>bcel</artifactId>
- <version>5.1</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.felix.tool.mangen.MangenMain</mainClass>
- <addClasspath>true</addClasspath>
- </manifest>
- <manifestEntries/>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- <resources>
- <resource>
- <directory>src/main/resources</directory>
- <filtering>true</filtering>
- </resource>
- </resources>
- </build>
-</project>
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ASMClassScanner.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ASMClassScanner.java
deleted file mode 100644
index 7a92d2b..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ASMClassScanner.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.IOException;
-import org.objectweb.asm.AnnotationVisitor;
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.FieldVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.Type;
-
-/**
- *
- * @version $Revision: 32 $
- * @author <A HREF="mailto:heavy@ungoverned.org">Richard S. Hall</A>
- */
-public class ASMClassScanner implements ClassScanner, ClassVisitor, MethodVisitor
-{
- private static final int DEFAULT_INCREMENT = 10;
-
- private int m_fieldCount = 0;
- private String[] m_fieldNames = new String[DEFAULT_INCREMENT];
- private String[] m_fieldSignatures = new String[DEFAULT_INCREMENT];
- private boolean[] m_fieldSynthFlags = new boolean[DEFAULT_INCREMENT];
-
- private int m_methodCount = 0;
- private String[] m_methodNames = new String[DEFAULT_INCREMENT];
- private String[] m_methodSignatures = new String[DEFAULT_INCREMENT];
- private boolean[] m_methodSynthFlags = new boolean[DEFAULT_INCREMENT];
-
- private int m_classCount = 0;
- private String[] m_classSignatures = new String[DEFAULT_INCREMENT];
-
- public ASMClassScanner()
- {
- }
-
- //
- // Methods for ClassScanner interface.
- //
-
- public void scan(java.io.InputStream is, String name) throws IOException
- {
- ClassReader cr = new ClassReader(is);
- //TODO: below is ASM 3.0 form, will need to use once migrate from 2.2.1
- //cr.accept(this, ClassReader.SKIP_DEBUG + ClassReader.SKIP_FRAMES);
- cr.accept(this, false);
- }
-
- public int getFieldCount()
- {
- return m_fieldCount;
- }
-
- public String getFieldName(int index)
- {
- return m_fieldNames[index];
- }
-
- public String getFieldSignature(int index)
- {
- return m_fieldSignatures[index];
- }
-
- public boolean isSyntheticField(int index)
- {
- return m_fieldSynthFlags[index];
- }
-
- public int getMethodCount()
- {
- return m_methodCount;
- }
-
- public String getMethodName(int index)
- {
- return m_methodNames[index];
- }
-
- public String getMethodSignature(int index)
- {
- return m_methodSignatures[index];
- }
-
- public boolean isSyntheticMethod(int index)
- {
- return m_methodSynthFlags[index];
- }
-
- public int getConstantClassCount()
- {
- return m_classCount;
- }
-
- public String getConstantClassSignature(int index)
- {
- return m_classSignatures[index];
- }
-
- //
- // Methods for ClassVisitor interface.
- //
-
- public void visit(int version, int access, String name, String signature, String superName, String[] interfaces)
- {
- //System.out.println("visit: " + name + " : " + signature + " : " + superName);
- // Capture super type dependency.
- addConstantClass(superName);
- // Capture implemented interface type dependencies.
- for (int i = 0; (interfaces != null) && (i < interfaces.length); i++)
- {
- //System.out.println("visit interfaces: " + interfaces[i]);
- addConstantClass(interfaces[i]);
- }
- // Capture class type itself, since it depends on itself.
- addConstantClass(name);
- }
-
- public void visitAttribute(org.objectweb.asm.Attribute attr)
- {
- }
-
- public FieldVisitor visitField(int access, String name, String desc, String signature, Object value)
- {
- //System.out.println("visitField: " + name + " : " + desc + " : " + signature + " : " + value);
- // Capture field type dependency.
- addField(name, desc, (access & Opcodes.ACC_SYNTHETIC) != 0);
- return null;
- }
-
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
- {
- //System.out.println("visitMethod: " + name + " : " + desc + " : " + signature);
- // Capture declared method exception type dependencies.
- for (int i = 0; (exceptions != null) && (i < exceptions.length); i++)
- {
- //System.out.println("visitField exceptions: " + exceptions[i]);
- addConstantClass(exceptions[i]);
- }
- // Capture declared method signature type dependencies.
- addMethod(name, desc, (access & Opcodes.ACC_SYNTHETIC) != 0);
- return this;
- }
-
- public void visitInnerClass(String name, String outerName, String innerName, int access)
- {
- //System.out.println("visitInnerClass: " + name + " : " + outerName + " : " + innerName);
- }
-
- public AnnotationVisitor visitAnnotation(String desc, boolean visible)
- {
- //System.out.println("visitAnnotation " + desc + " : " + visible);
- return null;
- }
-
- public void visitSource(String source, String debug)
- {
- }
-
- public void visitOuterClass(String owner, String name, String desc)
- {
- //System.out.println("visitOuterClass: " + name + " : " + desc);
- }
-
- public void visitEnd()
- {
- }
-
- //
- // Methods for MethodVisitor interface.
- //
-
- public AnnotationVisitor visitAnnotationDefault()
- {
- return null;
- }
-
-// A method with this name is already provided in the ClassVisitor interface
-// above, but since neither method does anything we can just ignore it.
-//
-// public AnnotationVisitor visitAnnotation(String desc, boolean visible)
-// {
-// return null;
-// }
-
- public AnnotationVisitor visitParameterAnnotation(
- int parameter,
- String desc,
- boolean visible)
- {
- //System.out.println("visitParameterAnnotation: " + desc + " : " + visible);
- return null;
- }
-
-// A method with this name is already provided in the ClassVisitor interface
-// above, but since neither method does anything we can just ignore it.
-//
-// public void visitAttribute(Attribute attr)
-// {
-// }
-
- public void visitCode()
- {
- }
-
- public void visitInsn(int opcode)
- {
- }
-
- public void visitIntInsn(int opcode, int operand)
- {
- }
-
- public void visitVarInsn(int opcode, int var)
- {
- }
-
- public void visitTypeInsn(int opcode, String desc)
- {
- //System.out.println("visitTypeInsn: " + desc);
- // This captures type operation type dependency (e.g., new, instanceof).
- addConstantClass(desc);
- }
-
- public void visitFieldInsn(int opcode, String owner, String name, String desc)
- {
- //System.out.println("visitFieldInsn: " + owner + " : " + name + " : " + desc);
- // This captures the owner type dependency of fields we access.
- addConstantClass(owner);
- }
-
- public void visitMethodInsn(int opcode, String owner, String name, String desc)
- {
- //System.out.println("visitMethodInsn: " + owner + " : " + name + " : " + desc);
- // Capture the owner type dependency of the method we invoke.
- // This is necessary to capture the use of static methods,
- // but it also captures the use of methods on return arguments.
- // Capturing the type of return objects is not strictly necessary,
- // since the type will be captured if assigned to a local variable.
- // However, not all returned objects are assigned to a local
- // variable, so this will capture types of return objects that we use
- // directly (e.g., obj.getFoo().getBar()).
- addConstantClass(owner);
- }
-
- public void visitJumpInsn(int opcode, Label label)
- {
- }
-
- public void visitLabel(Label label)
- {
- }
-
- public void visitLdcInsn(Object cst)
- {
- //System.out.println("visitLdcInsn: " + cst);
- }
-
- public void visitIincInsn(int var, int increment)
- {
- }
-
- public void visitTableSwitchInsn(int min, int max, Label dflt, Label labels[])
- {
- }
-
- public void visitLookupSwitchInsn(Label dflt, int keys[], Label labels[])
- {
- }
-
- public void visitMultiANewArrayInsn(String desc, int dims)
- {
- //System.out.println("visitMultiANewArrayInsn: " + desc);
- }
-
- public void visitTryCatchBlock(Label start, Label end, Label handler, String type)
- {
- }
-
- public void visitLocalVariable(
- String name,
- String desc,
- String signature,
- Label start,
- Label end,
- int index)
- {
- //System.out.println("visitLocalVariable: " + name + " : " + desc + " : " + signature);
- // Capture local variable type dependency, but ignore
- // primitive types.
- if (desc.startsWith("L"))
- {
- // The "desc" variable is in the form "L<class>;", so
- // extract just the class name, since mangen expects
- // a class name only or an array.
- addConstantClass(desc.substring(1, desc.length() - 1));
- }
- else if (desc.indexOf("[L") >= 0)
- {
- addConstantClass(desc);
- }
- }
-
- public void visitLineNumber(int line, Label start)
- {
- }
-
- public void visitMaxs(int maxStack, int maxLocals)
- {
- }
-
- public void visitFrame(int type, int nLocal, Object[] local, int nStack,
- Object[] stack)
- {
- }
-
-// A method with this name is already provided in the ClassVisitor interface
-// above, but since neither method does anything we can just ignore it.
-//
-// public void visitEnd()
-// {
-// }
-
- //
- // Utility methods.
- //
-
- private void addField(String name, String signature, boolean synth)
- {
- m_fieldNames = addToStringArray(m_fieldCount, m_fieldNames, name);
- m_fieldSignatures = addToStringArray(m_fieldCount, m_fieldSignatures, signature);
- m_fieldSynthFlags = addToBooleanArray(m_fieldCount, m_fieldSynthFlags, synth);
- m_fieldCount++;
- }
-
- private void addMethod(String name, String signature, boolean synth)
- {
- m_methodNames = addToStringArray(m_methodCount, m_methodNames, name);
- m_methodSignatures = addToStringArray(m_methodCount, m_methodSignatures, signature);
- m_methodSynthFlags = addToBooleanArray(m_methodCount, m_methodSynthFlags, synth);
- m_methodCount++;
- }
-
- private void addConstantClass(String signature)
- {
- m_classSignatures = addToStringArray(m_classCount, m_classSignatures, signature);
- m_classCount++;
- }
-
- public static boolean[] addToBooleanArray(int count, boolean[] bs, boolean b)
- {
- if (count < bs.length)
- {
- bs[count] = b;
- }
- else
- {
- boolean[] bs2 = new boolean[bs.length + DEFAULT_INCREMENT];
- System.arraycopy(bs, 0, bs2, 0, bs.length);
- bs2[bs.length] = b;
- bs = bs2;
- }
- return bs;
- }
-
- public static String[] addToStringArray(int count, String[] ss, String s)
- {
- if (count < ss.length)
- {
- ss[count] = s;
- }
- else
- {
- String[] ss2 = new String[ss.length + DEFAULT_INCREMENT];
- System.arraycopy(ss, 0, ss2, 0, ss.length);
- ss2[ss.length] = s;
- ss = ss2;
- }
- return ss;
- }
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BCELScanner.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BCELScanner.java
deleted file mode 100644
index 1adbfc7..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BCELScanner.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-import java.util.ArrayList;
-
-import org.apache.bcel.classfile.*;
-
-/**
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class BCELScanner
- implements ClassScanner
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public BCELScanner()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- public JavaClass jc;
- public Constant[] constants = new Constant[0];
- public Method[] methods = new Method[0];
- public Field[] fields = new Field[0];
- public ConstantClass[] constantClasses = new ConstantClass[0];
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - ClassScanner
- //////////////////////////////////////////////////
-
- public void scan(InputStream is, String name)
- throws IOException
- {
- ClassParser parser = new ClassParser(is, name);
- jc = parser.parse();
-
- constants = jc.getConstantPool().getConstantPool();
- methods = jc.getMethods();
- fields = jc.getFields();
-
- // extract out constant classes for later
- ArrayList cls = new ArrayList();
- for(int ix=0; ix < constants.length; ix++)
- {
- if (constants[ix] instanceof ConstantClass)
- {
- cls.add(constants[ix]);
- }
- }
- constantClasses = (ConstantClass[]) cls.toArray(constantClasses);
- }
-
-
- public int getMethodCount()
- {
- return methods.length;
- }
-
-
- public String getMethodName(int index)
- {
- return methods[index].getName();
- }
-
-
- public String getMethodSignature(int index)
- {
- return methods[index].getSignature();
- }
-
-
- public boolean isSyntheticMethod(int index)
- {
- return isSynthetic(methods[index]);
- }
-
-
- public int getFieldCount()
- {
- return fields.length;
- }
-
-
- public String getFieldName(int index)
- {
- return fields[index].getName();
- }
-
-
- public String getFieldSignature(int index)
- {
- return fields[index].getSignature();
- }
-
- public boolean isSyntheticField(int index)
- {
- return isSynthetic(fields[index]);
- }
-
-
- public int getConstantClassCount()
- {
- return constantClasses.length;
- }
-
-
- public String getConstantClassSignature(int index)
- {
- int nameIndex = constantClasses[index].getNameIndex();
- return ((ConstantUtf8) constants[nameIndex]).getBytes();
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Scan any attributes present and return true if the Synthetic attribute
- * is found.
- */
- protected boolean isSynthetic(FieldOrMethod fOrM)
- {
- boolean found = false;
-
- Attribute[] att = fOrM.getAttributes();
- for (int ix = 0; ix < att.length && !found; ix++)
- {
- if (att[ix] instanceof Synthetic)
- {
- found = true;
- }
- }
-
- return found;
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BundleJar.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BundleJar.java
deleted file mode 100644
index c13fd95..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/BundleJar.java
+++ /dev/null
@@ -1,701 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.JarInputStream;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import java.util.zip.ZipEntry;
-
-import org.osgi.framework.Constants;
-
-/**
- *
- * @version $Revision: 26 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class BundleJar
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- /** class scanner {@link Property} key */
- public static final String SCANNER_KEY = "mangen.scanner.class";
- /** Default ClassScanner implementation class name */
- public static final String DLFT_SCANNER_CLASS = "org.apache.felix.tool.mangen.BCELScanner";
-
- /** Crude match pattern for L<classname>; signatures */
- public static Pattern classnamePattern = Pattern.compile("L[^;]+?;");
-
- /** Buffer for jar copying is static. No need to sweat the GC. */
- public static byte[] copyBuf = new byte[32767];
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Gets a {@link ClassScanner} instance usinng the configured scanner implementation
- * class.
- */
- public static ClassScanner getScanner()
- throws Exception
- {
- String name = PropertyManager.getProperty(SCANNER_KEY, DLFT_SCANNER_CLASS);
- Class scanClass = Class.forName(name);
- return (ClassScanner) scanClass.newInstance();
- }
-
- /**
- * Put the supplied key and value in the specified {@link Attributes}
- * if the value is not an empty {@link String}, otherwise remove the key
- * from the {@link Attributes}.
- */
- public static void putValueIfNotEmpty(Attributes atts, String key, String val)
- {
- if (!val.trim().equals(""))
- {
- atts.putValue(key, val);
- }
- else
- {
- // Note that Attributes entry keys are not Strings, so we have to remove
- // them using the correct object type.
- Attributes.Name nm = new Attributes.Name(key);
- atts.remove(nm);
- }
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- /** bundle JAR file */
- public JarFile jarFile;
- /** {@link Manifest} from existing bundle JAR */
- public Manifest manifest;
- /** Main {@link Attributes} entry from existing bundle JAR */
- public Attributes mainAttributes;
- /** mangen {@link Attributes} entry from existing bundle JAR */
- public Attributes mangenAttributes;
- /** Set of inner JARs processed from the bundle JAR */
- public Set currentInnerJars = new HashSet();
-
- public Set possibleExports = OsgiPackage.getNewSet();
- public Set possibleImports = OsgiPackage.getNewSet();
- /** Record of all inner classes, used for tracking awkward synthetic references to inner classes */
- public Set innerClasses = new HashSet();
- /** Sun javac synthetic class references */
- public Set syntheticClasses = new HashSet();
-
- public RuleHandler bundleRuleHandler;
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- /**
- * Create a new bundle JAR instance. Processing will only be performed if
- * a rule calls the {@see #process()} method.
- */
- public BundleJar(String filename)
- throws Exception
- {
- jarFile = new JarFile(filename);
- processManifest();
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- /**
- * Gets the name of this jar.
- */
- public String getName()
- {
- return jarFile.getName();
- }
-
- /**
- * Returns the set of possible export packages.
- */
- public Set getPossibleExports()
- {
- return possibleExports;
- }
-
- /**
- * Returns the set of possible import packages.
- */
- public Set getPossibleImports()
- {
- return possibleImports;
- }
-
- /**
- * Returns the set of current Manifest export packages.
- */
- public Set getCurrentExports()
- {
- return OsgiPackage.createFromHeaders(mainAttributes.getValue(Constants.EXPORT_PACKAGE), true);
- }
-
- /**
- * Returns the set of current Manifest import packages.
- */
- public Set getCurrentImports()
- {
- return OsgiPackage.createFromHeaders(mainAttributes.getValue(Constants.IMPORT_PACKAGE), false);
- }
-
- /**
- * Returns the set of "fixed" export packages. These use the same manifest key
- * but specified in the mangen attributes section.
- */
- public Set getFixedExports()
- {
- return OsgiPackage.createFromHeaders(mangenAttributes.getValue(Constants.EXPORT_PACKAGE), true);
- }
-
- /**
- * Returns the set of "fixed" imports packages. These use the same manifest key
- * but specified in the mangen attributes section.
- */
- public Set getFixedImports()
- {
- return OsgiPackage.createFromHeaders(mangenAttributes.getValue(Constants.IMPORT_PACKAGE), false);
- }
-
- /**
- * Returns a specified Manifest header value, optionally checking the mangen
- * attribute set first before the main attribute set.
- */
- public String getManifestHeader(String key, boolean checkMangenAtts)
- {
- String retval = null;
-
- if (checkMangenAtts)
- {
- retval = mangenAttributes.getValue(key);
- }
-
- if (retval == null)
- {
- retval = mainAttributes.getValue(key);
- }
-
- return retval != null ? retval : "";
- }
-
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Process the bundle JAR. Every class's package name will be added to the
- * list of possible exports. Class files will be parsed, and the packages
- * for all referenced classes contained within them will be added to the
- * list of possible imports.
- */
- public void process()
- throws Exception
- {
- processJarEntries();
- processSunJDKSyntheticClassRefs();
- // final step is to execute our own local rules
- executeBundleRules();
- }
-
- /**
- * Update the bundle jar's manifest to contain the optimised set of imports
- * and exports. Note that because of limitations in the standard JDK classes,
- * this requires copying to a new jar at present and renaming over the current
- * jar.
- */
- public void update(boolean overwrite)
- throws IOException
- {
- Manifest newManifest = updateHeaders();
- String origName = getName();
-
- File newJar = new File(origName + ".new.jar");
- JarOutputStream jos = new JarOutputStream(new FileOutputStream(newJar), newManifest);
-
- Enumeration en = jarFile.entries();
- while (en.hasMoreElements())
- {
- ZipEntry ze = (ZipEntry) en.nextElement();
- if (ze.getName().compareToIgnoreCase("META-INF/MANIFEST.MF") != 0)
- {
- jos.putNextEntry(ze);
- copy(jarFile.getInputStream(ze), jos);
- }
- }
-
- jos.close();
-
- // replace existing file if needed
- if (overwrite)
- {
- jarFile.close();
- File origFile = new File(origName);
-
- if (!origFile.delete())
- {
- throw new IOException("delete of original JAR failed");
- }
-
- if (!newJar.renameTo(origFile))
- {
- throw new IOException("rename of new JAR failed");
- }
- }
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Process the Manifest for this Jar file. Need to retrieve any existing
- * imports and exports for this Jar file and also determine which inner
- * jars we should scan.
- */
- protected void processManifest()
- throws IOException
- {
- manifest = jarFile.getManifest();
- if (manifest == null)
- {
- manifest = new Manifest();
- }
-
- mainAttributes = manifest.getMainAttributes();
- if (mainAttributes == null)
- {
- mainAttributes = new Attributes();
- }
-
- String val = mainAttributes.getValue(Constants.BUNDLE_CLASSPATH);
- if (val != null)
- {
- parseBundleClassPath(val, currentInnerJars);
- }
-
- // look for mangen rules in manifest
- mangenAttributes = manifest.getAttributes("com/ascert/openosgi/mangen");
- if (mangenAttributes == null)
- {
- mangenAttributes = new Attributes();
- }
-
- bundleRuleHandler = new RuleHandler(mangenAttributes);
- }
-
- /**
- * Parse the OSGi bundle classpath and add all jars to set of inner jars
- */
- public void parseBundleClassPath(String path, Set innerJars)
- {
- StringTokenizer tok = new StringTokenizer(path, ",");
- while (tok.hasMoreTokens())
- {
- String name = tok.nextToken();
- if (name.endsWith(".jar"))
- {
- innerJars.add(name.trim());
- }
- }
- }
-
- /**
- * Process the set of entries in the main Jar file. Every .class entry will
- * have it's package name added to the list of possible exports if needed, and
- * will be parsed to determine if it contains new imports.
- */
- protected void processJarEntries()
- throws Exception
- {
- Enumeration en = jarFile.entries();
- while (en.hasMoreElements())
- {
- ZipEntry ze = (ZipEntry) en.nextElement();
- String name = ze.getName();
- if (name.endsWith(".class"))
- {
- addPossibleExport(name);
- InputStream is = jarFile.getInputStream(ze);
- processClassEntry(is, name);
- is.close();
- }
- else if (name.endsWith(".jar"))
- {
- JarInputStream jis = new JarInputStream(jarFile.getInputStream(ze));
- processInnerJar(jis, name);
- jis.close();
- }
- }
- }
-
- /**
- * Parse and process an inner jar in the supplied InputStream.
- *
- * At present we only process inner jars that are on the current bundle classpath.
- * Since we're a manifest generator, we could also have rules to automatically
- * process matching inner jars we find and also generate an appropriate
- * bundle classpath.
- */
- public void processInnerJar(JarInputStream jis, String jarName)
- throws Exception
- {
- if (currentInnerJars.contains(jarName))
- {
- // Loop through JAR entries.
- for (JarEntry je = jis.getNextJarEntry(); je != null; je = jis.getNextJarEntry())
- {
- String name = je.getName();
- if (name.endsWith(".class"))
- {
- addPossibleExport(name);
- processClassEntry(jis, name);
- }
- }
- }
- }
-
- /**
- * Parse and process a class entry in the supplied InputStream.
- *
- */
- public void processClassEntry(InputStream is, String name)
- throws Exception
- {
- // need to track inner classes for Sun synthetic class name handling
- if (name.indexOf('$') != -1)
- {
- addToInnerClasses(name);
- }
-
- ClassScanner scanner = getScanner();
- scanner.scan(is, name);
- scanConstantsClasses(scanner);
- scanFields(scanner);
- scanMethods(scanner);
- }
-
- /**
- * Map the supplied name into a package name and add to the target set if
- * it is a new package name.
- */
- protected void addToPackageSet(String itemName, Set targetSet)
- {
- int lastPathSep = itemName.lastIndexOf('/');
- if (lastPathSep != -1)
- {
- String pkg = itemName.substring(0, lastPathSep);
- pkg = pkg.replace('/', '.');
-
- if (!targetSet.contains(pkg))
- {
- targetSet.add(OsgiPackage.createStringPackage(pkg));
- }
- }
- }
-
-
- /**
- * Add name possible exports if it contains a new package name.
- */
- protected void addPossibleExport(String name)
- {
- addToPackageSet(name, possibleExports);
- }
-
- /**
- * Add classname to list of inner classes
- */
- protected void addToInnerClasses(String name)
- {
- int suffix = name.lastIndexOf(".class");
- String justName = name.substring(0, suffix);
-
- if (!innerClasses.contains(justName))
- {
- innerClasses.add(justName);
- }
- }
-
- /**
- * Parse the supplied signature string, extract all L<class>; format
- * class references and adding them to the specified set.
- */
- protected boolean extractClassesFromSignature(String signature, Set set)
- {
- boolean matched = false;
- Matcher m = classnamePattern.matcher(signature);
-
- while (m.find())
- {
- matched = true;
- String classname = m.group();
- //System.out.println("match: " + classname);
- addToPackageSet(classname.substring(1, classname.length() - 1), set);
- }
-
- return matched;
- }
-
-
- /**
- * Scan the constant pool of the parsed java class for any ConstantClass references.
- * Add any found into the list of possible import packages.
- */
- protected void scanConstantsClasses(ClassScanner scanner)
- {
- for(int ix=0; ix < scanner.getConstantClassCount(); ix++)
- {
- String classRef = scanner.getConstantClassSignature(ix);
-
- MangenMain.trace("ConstantClass : " + classRef);
-
- if (classRef.startsWith("["))
- {
- // array classname
- extractClassesFromSignature(classRef, possibleImports);
- }
- else
- {
- // simple classname
- addToPackageSet(classRef, possibleImports);
- }
- }
- }
-
- /**
- * Scan the fields of the parsed java class for all class references.
- * Add any found into the list of possible import packages.
- */
- protected void scanFields(ClassScanner scanner)
- {
- for(int ix=0; ix < scanner.getFieldCount(); ix++)
- {
- String name = scanner.getFieldName(ix);
- String sig = scanner.getFieldSignature(ix);
-
- MangenMain.trace("Field : name=" + name + ", sig=" + sig);
-
- if (scanner.isSyntheticField(ix))
- {
- handleSunJDKSyntheticClassRefs(name);
- }
- extractClassesFromSignature(sig, possibleImports);
- }
- }
-
- /**
- * Scan the methods of the parsed java class for all class references.
- * Add any found into the list of possible import packages.
- */
- protected void scanMethods(ClassScanner scanner)
- {
- for(int ix=0; ix < scanner.getMethodCount(); ix++)
- {
- String name = scanner.getMethodName(ix);
- String sig = scanner.getMethodSignature(ix);
-
- MangenMain.trace("Method : name=" + name + ", sig=" + sig);
-
- extractClassesFromSignature(sig, possibleImports);
- }
- }
-
- /**
- * The Sun JDK javac generates synthetic fields with a name of
- * class$packagename$classname for classes that are directly referenced
- * in code as opposed to being used in methods and fields.
- *
- * First stage is to store all of these references ready for post-processing.
- */
- protected void handleSunJDKSyntheticClassRefs(String name)
- {
- if (name.startsWith("class$"))
- {
- syntheticClasses.add(name.substring(6));
- }
- }
-
- /**
- * Post-processing of Sun JDK javac generated synthetic fields.
- *
- * The general case is to handle these by unmangling the generated name and
- * create an import reference for it. A special case exists for inner class
- * references which need the last inner class reference removed.
- *
- * Not a perfect solution, but since this is a special case of dynamic
- * classloading without actually executing the bytecode or looking for code
- * patterns it's a reasonable compromise.
- */
- protected void processSunJDKSyntheticClassRefs()
- {
- for(Iterator i = syntheticClasses.iterator(); i.hasNext(); )
- {
- String name = (String) i.next();
-
- // check for inner class case
- int lastSep = name.lastIndexOf('$');
- if (lastSep != -1)
- {
- String possInnerClass = name.substring(0, lastSep).replace('$','/') +
- name.substring(lastSep);
-
- if (innerClasses.contains(possInnerClass))
- {
- // strip off last $ component, which is the inner class name
- name = name.substring(0, lastSep);
- }
- }
-
- String classname = name.replace('$','/');
- addToPackageSet(classname, possibleImports);
- }
- }
-
- /**
- * Execute any local i.e. bundle specific rules.
- */
- protected void executeBundleRules()
- {
- if (bundleRuleHandler != null)
- {
- ArrayList dummyList = new ArrayList();
- dummyList.add(this);
- bundleRuleHandler.executeRules(dummyList);
- }
- }
-
- /**
- * Copy inputstream to output stream. Main use is Jar updating to create new
- * jar.
- */
- protected void copy(InputStream is, OutputStream os)
- throws IOException
- {
- int len = 0;
-
- while(len != -1)
- {
- len = is.read(copyBuf, 0, copyBuf.length);
- if (len > 0)
- {
- os.write(copyBuf, 0, len);
- }
- }
- }
-
- /**
- * Update the manifest headers based on the processed state of imports,
- * exports etc.
- */
- protected Manifest updateHeaders()
- {
- Manifest newManifest = new Manifest(manifest);
- Attributes newAtts = newManifest.getMainAttributes();
-
- // First determine whether to mark for R3 or R4 usage
- String val = PropertyManager.getProperty("mangen.osgi.level", "3");
- if (val.equals("4"))
- {
- newAtts.putValue(Constants.BUNDLE_MANIFESTVERSION, "2");
- }
- else
- {
- newAtts.putValue(Constants.BUNDLE_MANIFESTVERSION, "1");
- }
-
- putValueIfNotEmpty(newAtts, Constants.EXPORT_PACKAGE, getAsHeaderValue(possibleExports));
- putValueIfNotEmpty(newAtts, Constants.IMPORT_PACKAGE, getAsHeaderValue(possibleImports));
- //TODO: implement generation of bundle classpath if mangen.innerjar.auto set
-
- return newManifest;
- }
-
- /**
- * Get the specified set of packages as a String of values suitable for use in
- * a manifest header.
- */
- protected String getAsHeaderValue(Set set)
- {
- StringBuffer str = new StringBuffer();
- boolean first = true;
-
- for(Iterator i = set.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- if (first)
- {
- str.append(pkg.toString());
- first = false;
- }
- else
- {
- str.append(", " + pkg.toString());
- }
- }
-
- return str.toString();
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ClassScanner.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ClassScanner.java
deleted file mode 100644
index 15e93e4..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ClassScanner.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.InputStream;
-import java.io.IOException;
-
-/**
- * Wrapper interface to class bytecode scanning tools. This interface exposes
- * just the methods required by mangen for class scanning. Specific implementations
- * should be created for different scanners e.g. ASM, BCEL etc.
- * <p>
- * At present the interface has been deliberately kept small and simple. It would be
- * possible to use a {@link java.util.Collection#toArray()} or {@link java.util.Iterator} style models
- * for retrieving class information but in both cases these would be likely to require
- * additional object creation with possibly detrimental performance impacts.
- * <p>
- * The ordering of return values for each of the methods taking an <code>index</code> is not
- * important. All that matters is that the method can be called with an index of <code>0</code>
- * up to <code>getXXCount()</code> times to retrieve the complete set of values.
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- * @see <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/VMSpecTOC.doc.html">The JavaTM Virtual Machine Specification, Second Edition</a>
- */
-public interface ClassScanner
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // SIGNATURES
- //////////////////////////////////////////////////
-
- /**
- * Scan the class bytes by reading the supplied {@link InputStream} The name field
- * specifies the name of the class to be scanned, and may not be needed
- * by all scanners.
- */
- public void scan(InputStream is, String name)
- throws IOException;
-
- /**
- * Return the number of methods for the scanned class
- */
- public int getMethodCount();
-
- /**
- * Return the name of the specific method index.
- */
- public String getMethodName(int index);
-
- /**
- * Return the signature of the specific method index.
- * <p>
- * Method signatures should be returned in the form as specified in
- * <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#7035">section 4.3.3</a>
- * of the VM spec.
- */
- public String getMethodSignature(int index);
-
- /**
- * Determines whether the specified method has a Synthetic attribute present.
- * <p>
- * Section <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#80128">section 4.7.6</a>
- * describes the <code>Synthetic</code> attribute. A typical use of this is to mark
- * methods and fields generated by the Java compiler which weren't actually present in
- * the source code. There are a few cases where <code>mangen</code> uses these to
- * look for <i>generated name</i> patterns to detect class references that would
- * otherwise be missed.
- */
- public boolean isSyntheticMethod(int index);
-
- /**
- * Return the number of fields for the scanned class
- */
- public int getFieldCount();
-
- /**
- * Return the name of the specific field index.
- */
- public String getFieldName(int index);
-
- /**
- * Return the signature of the specific method index.
- * <p>
- * Field signatures should be returned in the form as specified in
- * <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#14152">section 4.3.2</a>
- * of the VM spec.
- */
- public String getFieldSignature(int index);
-
- /**
- * Determines whether the specified field has a Synthetic attribute present.
- * {@see #getMethodSignature(int)}
- */
- public boolean isSyntheticField(int index);
-
- /**
- * Return the number of constant classes for the scanned class. Depending on the
- * approach taking by specific scanner implementations it may be possible to detect all
- * required class references without accessing the constant classes. If so,
- * the implementation of this method should return 0.
- */
- public int getConstantClassCount();
-
- /**
- * Return the signature of the specific constant class.
- * <p>
- * ConstantClass signatures should be returned in the form as specified in
- * <a href="http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html#1221">section 4.4.1</a>
- * of the VM spec.
- * <p>
- * <i>Note:</i> in general, a simple class name should be returned as a name string rather
- * than an <code>L<classname>;</code> signature string. However, if an implementation
- * has a signature format and wishes to avoid parsing it then simply pre-pending a <code>[</code> will
- * force the {@link BundleJar} calling method to treat it as a signature and perform the
- * parsing.
- */
- public String getConstantClassSignature(int index);
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandler.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandler.java
deleted file mode 100644
index dcc7755..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandler.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Properties;
-
-import java.util.jar.Attributes;
-
-/**
- * The GenericHandler class provides a general purpose mechanism for providing
- * an extensible set of classname based handler items.
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public abstract class GenericHandler
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- /** List of usable handler items in order of their declaration */
- public ArrayList handlerList = new ArrayList();
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- /**
- * For every property which matches the name itemKey.<n> create a handler
- * item and check the handler item class matches the specified class. Handler items
- * should contain either fully qualified classnames or classnames relative to the
- * supplied defaultPkg.
- */
- public GenericHandler(String itemKey, Class clazz, String defaultPkg)
- {
- int ix = 0;
- String itemString = PropertyManager.getProperty(itemKey + ix++);
- while (itemString != null)
- {
- handlerList.add(create(itemString, clazz, defaultPkg));
- itemString = PropertyManager.getProperty(itemKey + ix++);
- }
- }
-
- /**
- * Create a handler list based on a set of manifest attributes.
- */
- public GenericHandler(Attributes atts, String itemKey, Class clazz, String defaultPkg)
- {
- int ix = 0;
- String itemString = atts.getValue(itemKey + ix++);
- while (itemString != null)
- {
- GenericHandlerItem item = create(itemString, clazz, defaultPkg);
- if (item != null)
- {
- handlerList.add(item);
- }
- itemString = atts.getValue(itemKey + ix++);
- }
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Create the handler item object for the specified itemString.
- * HandlerItems are in the following format
- *
- * <item-class> : <item-options>
- *
- * <item-class> is either a fully qualified classname, or a classname within
- * defaultPkg.
- * <item-options> is a free-format string of item specific options.
- *
- */
- protected GenericHandlerItem create(String itemString, Class clazz, String defaultPkg)
- {
- GenericHandlerItem item = null;
- String itemName = itemString;
- String itemOptions = "";
-
- int itemSepPos = itemString.indexOf(' ');
- if (itemSepPos != -1)
- {
- itemName = itemString.substring(0, itemSepPos).trim();
- itemOptions = itemString.substring(itemSepPos+1).trim();
- }
-
- try
- {
- Class itemClass;
-
- if (itemName.indexOf('.') == -1)
- {
- itemClass = Class.forName(defaultPkg + "." + itemName);
- }
- else
- {
- itemClass = Class.forName(itemName);
- }
-
- if (! clazz.isAssignableFrom(itemClass))
- {
- throw new ClassCastException("mismatched class type");
- }
-
- item = (GenericHandlerItem) itemClass.newInstance();
- item.setOptions(itemOptions);
- }
- catch (ClassNotFoundException cnfe)
- {
- System.err.println("Unable to load class for handler item: " + itemName);
- }
- catch (Exception e)
- {
- System.err.println("Exception creating handler item object: " + itemName
- + "(" + e + ")");
- }
-
- return item;
- }
-
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItem.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItem.java
deleted file mode 100644
index 809dc54..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItem.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-/**
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public interface GenericHandlerItem
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // SIGNATURES
- //////////////////////////////////////////////////
-
- public void setOptions(String options);
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItemImpl.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItemImpl.java
deleted file mode 100644
index d72fb40..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/GenericHandlerItemImpl.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Holder for common item handler methods, such as standard option processing
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public abstract class GenericHandlerItemImpl
- implements GenericHandlerItem
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Makes perfect sense that JDK Set would have no "get" operation since,
- * in theory to do a contains(), you must alreay have the Object. Since we
- * subvert that a little by allowing comparisons with different object types,
- * it doesn't quite work for our case though.
- */
- public static OsgiPackage getPackageFromSet(OsgiPackage pkg, Set set)
- {
- OsgiPackage retval = null;
- // do search based on package name only, to ensure we find occurences of
- // different types
- String name = pkg.getName();
-
- for(Iterator i = set.iterator(); retval == null && i.hasNext(); )
- {
- OsgiPackage setPkg = (OsgiPackage) i.next();
- if (setPkg.equals(name))
- {
- retval = setPkg;
- }
- }
-
- return retval;
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- /** Map contain parsed options */
- public Map optionMap = new HashMap();
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public GenericHandlerItemImpl()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Test whether the supplied package matches one of the set of patterns
- * for the specified qualifier.
- */
- protected boolean isPackageMatch(OsgiPackage pkg, String qualName)
- {
- return getMatchingPatternString(pkg, qualName, false) != null ? true : false;
- }
-
- /**
- * Get's the pattern string that matches the supplied package in the specified
- * qualifier set. Optionally, the matching algorithm can be instructed to only
- * match on package name, which will exclude matching any package attributes
- * after the ";" specifier.
- */
- protected String getMatchingPatternString(OsgiPackage pkg, String qualName, boolean nameMatchOnly)
- {
- String pattString = null;
- Set pattSet = (Set) optionMap.get(qualName);
-
- if (pattSet != null)
- {
- for(Iterator i = pattSet.iterator(); pattString == null && i.hasNext(); )
- {
- Pattern origPatt = (Pattern) i.next();
- Pattern patt = origPatt;
- String matchString = pkg.toString();
-
- if (nameMatchOnly)
- {
- matchString = pkg.getName();
- // need to strip off any attributes and recompile pattern
- String fullStr = patt.pattern();
- int delim = fullStr.indexOf(';');
- if (delim != -1)
- {
- patt = Pattern.compile(fullStr.substring(0, delim));
- }
-
- }
-
- Matcher matcher = patt.matcher(matchString);
- if (matcher.matches())
- {
- pattString = origPatt.pattern();
- }
- }
- }
-
- return pattString;
- }
-
- /**
- * Test whether the supplied jar name matches one of the set of patterns
- * for the specified qualifier.
- */
- protected boolean isJarNameMatch(String jarName, String qualName)
- {
- boolean found = false;
- Set pattSet = (Set) optionMap.get(qualName);
-
- if (pattSet != null)
- {
- for(Iterator i = pattSet.iterator(); !found && i.hasNext(); )
- {
- Pattern patt = (Pattern) i.next();
-
- Matcher matcher = patt.matcher(jarName);
- if (matcher.matches())
- {
- found = true;
- }
- }
- }
-
- return found;
- }
-
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - GenericHandlerItem
- //////////////////////////////////////////////////
-
- /**
- * Process the option set. The GenericRule will parse and separate a space
- * separated list of qualifiers in the following format.
- *
- * qual1(<qual1-options>) qual2(<qual2-options>)
- */
- public void setOptions(String options)
- {
- for (StringTokenizer tok = new StringTokenizer(options, " "); tok.hasMoreTokens(); )
- {
- String qualifier = tok.nextToken().trim();
- if (qualifier.startsWith("sys-packages") ||
- qualifier.startsWith("imports") ||
- qualifier.startsWith("exports") ||
- qualifier.startsWith("skip-jars") )
- {
- processStandardQualifier(qualifier);
- }
- else
- {
- processNonStandardQualifier(qualifier);
- }
- }
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Hook for subclasses to include own qualifier processing if they wish to
- * use this model with non-standard qualifiers
- */
- protected void processNonStandardQualifier(String qual)
- {
- }
-
- /**
- * Process a standard qualifier. This will contain a qualifier keyword, followed
- * by a comma separated list of patterns enclosed in brackets:
- *
- * qual1(patt1, patt2, patt3)
- *
- */
- protected void processStandardQualifier(String qual)
- {
- int start = qual.indexOf('(');
- int end = qual.lastIndexOf(')');
-
- if (start == -1 || end == -1)
- {
- throw new IllegalArgumentException("badly formed rule qualifier: " + qual);
- }
-
- String qualName = qual.substring(0, start).trim();
-
- // Process the comma separated list of packages
- String list = qual.substring(start+1, end);
-
- // get any existing set for this option name, create new set if none
- Set pattSet = (Set) optionMap.get(qualName);
- if (pattSet == null)
- {
- pattSet = new HashSet();
- }
-
- for (StringTokenizer tok = new StringTokenizer(list, ","); tok.hasMoreTokens(); )
- {
- Pattern patt = Pattern.compile(tok.nextToken().trim());
- pattSet.add(patt);
- }
-
- optionMap.put(qualName, pattSet);
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/MangenMain.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/MangenMain.java
deleted file mode 100644
index 881d07c..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/MangenMain.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.File;
-import java.io.PrintStream;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class MangenMain
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- public static final String PROP_FILE = "mangen.properties";
-
- public static ArrayList jarList = new ArrayList();
- public static HashMap fileMap = new HashMap();
-
- public static RuleHandler[] ruleSets;
- public static ReportHandler reportHandler;
-
- public static boolean optTrace;
- public static boolean optFailOnError;
- public static boolean optFailOnWarning;
-
- public static int errorCount = 0;
- public static int warningCount = 0;
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Main entry point to mangen from command line. Argument list is expected to
- * be a list of jars, or directories which will be scanned for jar, or a
- * combination of both.
- */
- public static void main(String[] args)
- throws Exception
- {
- long start = System.currentTimeMillis();
-
- PropertyManager.initProperties(PROP_FILE);
- processOptions();
-
- ruleSets = RuleHandler.initRuleSets();
- reportHandler = new ReportHandler();
-
- initBundleJarList(args);
-
- RuleHandler.runRuleSets(ruleSets, jarList);
- reportHandler.runReports(System.out, jarList);
-
- long stop = System.currentTimeMillis();
- System.out.println("Time elapsed: " + ((double) (stop - start)/1000));
-
- int exitCode = 0;
- if (optFailOnError && errorCount > 0)
- {
- exitCode = 3;
- }
- else if (optFailOnWarning && warningCount > 0)
- {
- exitCode = 5;
- }
-
- System.exit(exitCode);
- }
-
- /**
- * Increment count of errors raised and send string to output stream. Also
- * show message on <code>stderr</code> if set to fail on errors.
- */
- public static void error(PrintStream out, String msg)
- {
- errorCount++;
- out.println(msg);
-
- if (optFailOnError)
- {
- System.err.println(msg);
- }
- }
-
- /**
- * Increment count of warnings raised and send string to output stream. Also
- * show message on <code>stderr</code> if set to fail on warnings.
- */
- public static void warning(PrintStream out, String msg)
- {
- warningCount++;
- out.println(msg);
-
- if (optFailOnWarning)
- {
- System.err.println(msg);
- }
- }
-
- /**
- * Generate trace output if enabled
- */
- public static void trace(String msg)
- {
- if (optTrace)
- {
- System.out.println("TRACE - " + msg);
- }
- }
-
- //////////////////////////////////////////////////
- // STATIC PRIVATE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Process each of the command line arguments. Any files ending .jar are treated
- * as bundle jars. Any directories will be descended into to
- * process any .jar files contained in the directory tree beneath.
- */
- private static void initBundleJarList(String[] args)
- throws Exception
- {
- // params are an array of jar files which may have partially compelete manifests
- for (int ix = 0; ix < args.length; ix++)
- {
- if (args[ix].endsWith(".jar"))
- {
- initJar(args[ix]);
- }
- else
- {
- File f = new File(args[ix]);
- if (f.isDirectory())
- {
- processDir(f);
- }
- }
- }
- }
-
- /**
- * Process a directory argument. Process all files and subdirectories.
- */
- private static void processDir(File dir)
- throws Exception
- {
- //TODO: exception handling cases?
- String[] files = dir.list();
- for (int ix = 0; ix < files.length; ix++)
- {
- files[ix] = dir.getPath() + File.separator + files[ix];
- }
- initBundleJarList(files);
- }
-
- /**
- * Create a new {@see BundleJar} and add it to the list of bundle JARs.
- */
- private static void initJar(String jarName)
- throws Exception
- {
- try
- {
- // normalize path separators for checking
- String absName = new File(jarName).getAbsolutePath();
- if (!fileMap.containsKey(absName))
- {
- BundleJar bund = new BundleJar(absName);
- fileMap.put(absName, bund);
- jarList.add(bund);
- }
- else
- {
- trace("skipping repeated filename: " + absName);
- }
- }
- catch (RuntimeException re)
- {
- System.err.println("Exception: " + re + ", skipping bundle jar: " + jarName);
- re.printStackTrace(System.err);
- }
- catch (Exception e)
- {
- System.err.println("Exception: " + e + ", skipping bundle jar: " + jarName);
- }
- }
-
- /**
- * Process runtime options and defaults.
- */
- private static void processOptions()
- {
- String opt = PropertyManager.getProperty("mangen.trace", "off");
- if (opt.compareToIgnoreCase("on") == 0)
- {
- optTrace = true;
- }
- else
- {
- optTrace = false;
- }
-
- opt = PropertyManager.getProperty("mangen.failonerror", "on");
- if (opt.compareToIgnoreCase("on") == 0)
- {
- optFailOnError = true;
- }
- else
- {
- optFailOnError = false;
- }
-
- opt = PropertyManager.getProperty("mangen.failonwarning", "off");
- if (opt.compareToIgnoreCase("on") == 0)
- {
- optFailOnWarning = true;
- }
- else
- {
- optFailOnWarning = false;
- }
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiPackage.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiPackage.java
deleted file mode 100644
index e8a5f6b..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiPackage.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.util.*;
-
-import org.apache.felix.framework.util.manifestparser.R4Package;
-import org.apache.felix.framework.util.manifestparser.ManifestParser;
-import org.osgi.framework.Version;
-
-/**
- * The OsgiPackage class is a wrapper for either simple string based package
- * names or full Osgi package objects containing attributes and versions etc.
- *
- * @version $Revision: 31 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public abstract class OsgiPackage
- implements Comparable
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- public static Comparator pkgComparator = new PackageComparator();
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Create a package wrapper for a simple package name string.
- */
- public static OsgiPackage createStringPackage(String pkgName)
- {
- return new OsgiStringPackage(pkgName);
- }
-
- /**
- * Create a set of OSGi package wrappers by parsing the supplied import
- * or export headers. At present, we only create true R4 packages for header
- * strings which contain ";" (the header attribute separator char). All
- * others we create as simple string packages
- */
- public static Set createFromHeaders(String headers, boolean export)
- {
- Set set = getNewSet();
-
- if (headers != null)
- {
- for (StringTokenizer tok = new StringTokenizer(headers, ","); tok.hasMoreTokens(); )
- {
- String pkgString = tok.nextToken().trim();
-
- // look for presence of package attribute separator ';'
- if (pkgString.indexOf(';') != -1)
- {
- // parse and add all R4 packages contained (can be multiple)
- R4Package[] pkgs = ManifestParser.parseImportExportHeader(pkgString, export);
- for (int ix = 0; ix < pkgs.length; ix++)
- {
- set.add(new OsgiR4Package(pkgs[ix]));
- }
- }
- else
- {
- // treat as a simple string package name
- set.add(new OsgiStringPackage(pkgString));
- }
- }
- }
-
- return set;
- }
-
- /**
- * Creates and returns a new Set for holding package entries.
- */
- public static Set getNewSet()
- {
- return new TreeSet(pkgComparator);
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- /**
- * Return simple package name form without attributes
- */
- public abstract String getName();
-
- /**
- * Return specified package version, or <code>null</code> if none defined.
- */
- public abstract Version getVersion();
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Very important to override standard equals method, since set based operations
- * work using this method for comparisons
- */
- public boolean equals(Object o)
- {
- return compareTo(o) == 0 ? true : false;
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Comparable
- //////////////////////////////////////////////////
-
- /**
- * Just used for sorting in reports
- */
- public int compareTo(Object o)
- {
- return -1;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- public static class PackageComparator
- implements Comparator
- {
- public int compare(Object o1, Object o2)
- {
- int retval = -1;
-
- if (o1 instanceof OsgiPackage)
- {
- retval = ((Comparable) o1).compareTo(o2);
- }
- else if (o2 instanceof OsgiPackage)
- {
- retval = ((Comparable) o2).compareTo(o1);
- }
- else
- {
- throw new ClassCastException("can't compare, neither o1 or o2 is an OsgiPackage");
- }
-
- return retval;
- }
- }
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiR4Package.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiR4Package.java
deleted file mode 100644
index d82e619..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiR4Package.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.felix.framework.util.manifestparser.*;
-import org.osgi.framework.Constants;
-import org.osgi.framework.Version;
-
-//TODO: need to look at VersionRange handling to see whether version checking
-// should be modified to cater for version ranges.
-/**
- * Wrapper for a full R4 package name
- *
- * @version $Revision: 31 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class OsgiR4Package
- extends OsgiPackage
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- public static String verString;
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Compare two sets of packages versions.
- */
- public static int compareVersions(Version v1, Version v2)
- {
- int retval = -1;
-
- if (v1 != null)
- {
- v1.compareTo(v2);
- }
- else if (v2 != null)
- {
- v2.compareTo(v1);
- }
- else
- {
- retval = 0;
- }
-
- return retval;
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- public R4Package pkg;
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public OsgiR4Package(R4Package pkg)
- {
- this.pkg = pkg;
-
- if (verString == null)
- {
- String val = PropertyManager.getProperty("mangen.osgi.level", "3");
- if (val.equals("4"))
- {
- verString = Constants.VERSION_ATTRIBUTE;
- }
- else
- {
- verString = Constants.PACKAGE_SPECIFICATION_VERSION;
- }
- }
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- /**
- * Return the wrapped Oscar R4 package.
- */
- public R4Package getPackage()
- {
- return pkg;
- }
-
-
- public String getName()
- {
- return pkg.getName();
- }
-
-
- public Version getVersion()
- {
- Version ver = null;
-
- // use 'version' attribute if present, fallback to getVersion if not
- R4Attribute verAttr = getAttribute(verString);
-
- if (verAttr != null)
- {
- String sVer = verAttr.getValue().toString();
- ver = new Version(sVer);
- }
- else
- {
- Version v = pkg.getVersion();
- if (!v.equals(Version.emptyVersion))
- {
- ver = v;
- }
- }
-
- return ver;
- }
-
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Important to override standard toString method for pattern matching and
- * manifest header value generation.
- */
- public String toString()
- {
- StringBuffer str = new StringBuffer(pkg.getName());
-
- // bit over the top this - but ensures we preserve a version attribute
- // specified as 1.2 rather than converting it to 1.2.0
- R4Attribute verAttr = getAttribute(verString);
- String sVer = null;
-
- if (verAttr != null)
- {
- sVer = verAttr.getValue().toString();
- }
- else
- {
- Version v = getVersion();
- if (v != null)
- {
- sVer = v.toString();
- }
- }
-
- if (sVer != null)
- {
- str.append(";" + verString + "=");
- str.append("\"" + sVer + "\"");
- }
-
- return str.toString();
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Comparable
- //////////////////////////////////////////////////
-
- /**
- * The Comparable interface is used as the basis for the OsgiPackage default
- * implementation of equals() and also for the Comparator interface used to
- * determine whether set members are present.
- */
- public int compareTo(Object o)
- {
- int retval = -1;
-
- if (o instanceof OsgiR4Package)
- {
- OsgiR4Package otherPkg = (OsgiR4Package) o;
- // first check for name match
- retval = getName().compareTo(otherPkg.getName());
-
- // check low versions match
- if (retval == 0)
- {
- retval = compareVersions(getVersion(),
- otherPkg.getVersion());
- }
- //TODO: Original Oscar2 mangen handled version ranges, may need to
- // revisit this
- // check high versions match
- //if (retval == 0)
- //{
- // retval = compareVersions(pkg.getVersionHigh(),
- // otherPkg.getVersionHigh());
- //}
- }
- else if (o instanceof OsgiStringPackage || o instanceof String)
- {
- // simple package name comparison
- retval = getName().compareTo(o.toString());
- }
- else
- {
- // prob won't do any better a job than we do, but fallback just in case
- retval = super.compareTo(o);
- }
-
- return retval;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Get a specific attribute of the package.
- */
- public R4Attribute getAttribute(String name)
- {
- R4Attribute attrib = null;
- R4Attribute[] attrs = pkg.getAttributes();
-
- if (attrs != null)
- {
- for (int i = 0; (attrib == null) && (i < attrs.length); i++)
- {
- if (attrs[i].getName().equals(name))
- {
- attrib = attrs[i];
- }
- }
- }
-
- return attrib;
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiStringPackage.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiStringPackage.java
deleted file mode 100644
index ad76a55..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/OsgiStringPackage.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.util.Iterator;
-import java.util.Properties;
-
-import org.apache.felix.framework.searchpolicy.*;
-import org.osgi.framework.Version;
-
-/**
- * Wrapper for a simple string based package name.
- *
- * @version $Revision: 31 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class OsgiStringPackage
- extends OsgiPackage
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- public String pkgname;
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public OsgiStringPackage(String pkgname)
- {
- this.pkgname = pkgname;
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- public String getName()
- {
- return pkgname;
- }
-
- public Version getVersion()
- {
- return null;
- }
-
-
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Important to override standard toString method for pattern matching and
- * manifest header value generation.
- */
- public String toString()
- {
- return pkgname;
- }
-
- /**
- * Important to override for hash table/set key lookups. Basically just need
- * to return hashcode of our underlying object.
- */
- public int hashCode()
- {
- return pkgname.hashCode();
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Comparable
- //////////////////////////////////////////////////
-
- /**
- * The Comparable interface is used as the basis for the OsgiPackage default
- * implementation of equals() and also for the Comparator interface used to
- * determine whether set members are present.
- */
- public int compareTo(Object o)
- {
- int retval = -1;
-
- if (o instanceof OsgiR4Package)
- {
- // R4 package comparison is complicated, so invert the compare and
- // let the R4 package do the work
- retval = ((OsgiR4Package) o).compareTo(this);
- }
- else if (o instanceof OsgiStringPackage || o instanceof String)
- {
- // simple string compare will suffice
- retval = pkgname.compareTo(o.toString());
- }
- else
- {
- // prob won't do any better a job than we do, but fallback just in case
- retval = super.compareTo(o);
- }
-
- return retval;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/PropertyManager.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/PropertyManager.java
deleted file mode 100644
index 9823fa7..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/PropertyManager.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.File;
-import java.io.FileInputStream;
-
-import java.util.Properties;
-
-/**
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class PropertyManager
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- private static final String DELIM_START = "${";
- private static final char DELIM_STOP = '}';
- private static final int DELIM_START_LEN = 2;
- private static final int DELIM_STOP_LEN = 1;
-
- public static Properties props = new Properties();
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Initialise the properties either from a file specified by -Dmangen.properties
- * or if this is not specified, from the default lib\mangen.properties file.
- */
- public static void initProperties(String propFileKey)
- throws Exception
- {
- String propsFile = System.getProperty(propFileKey);
-
- if (propsFile != null)
- {
- props.load(new FileInputStream(propsFile));
- }
- else
- {
- getDefaultProperties(propFileKey);
- }
-
- if (props.size() == 0)
- {
- System.err.println("Warning: no mangen properties specified.");
- }
- }
-
- /**
- * Get the default mangen properties from lib\mangen.properties
- */
- public static void getDefaultProperties(String propFileKey)
- {
- // Determine where mangen.jar is located by looking at the system class path.
- String jarLoc = null;
- String classpath = System.getProperty("java.class.path");
- int index = classpath.toLowerCase().indexOf("mangen.jar");
- int start = classpath.lastIndexOf(File.pathSeparator, index) + 1;
- if (index > start)
- {
- jarLoc = classpath.substring(start, index);
- if (jarLoc.length() == 0)
- {
- jarLoc = ".";
- }
- }
-
- // see if we can load from a default mangen.properties file
- try
- {
- props.load(new FileInputStream(jarLoc + propFileKey));
- }
- catch (Exception e)
- {
- // ok to ignore, we'll report error in caller
- }
- }
-
- /**
- * Provides a wrapper into either System properties, if the specified
- * property is present there, or our mangen.properties if not. As with the
- * standartd getProperty call the default value is returned if the key is not
- * present in either of these property sets. Variable substitution using
- * ${var} style markers is also supported.
- */
- public static String getProperty(String key, String def)
- {
- String retval = null;
-
- retval = System.getProperty(key);
- if (retval == null)
- {
- retval = props.getProperty(key, def);
- }
-
- if (retval != null)
- {
- retval = substVars(retval, key);
- }
-
- return retval;
- }
-
- /**
- * No default wrapper for getProperty.
- */
- public static String getProperty(String key)
- {
- return getProperty(key, null);
- }
-
-
- /**
- * <p>
- * This method performs property variable substitution on the
- * specified string value. If the specified string contains the
- * syntax <code>${<system-prop-name>}</code>, then the corresponding
- * system property value is substituted for the marker.
- * </p>
- * @param val The string on which to perform system property substitution.
- * @param currentKey The current key name, used to detect recursion
- * @return The value of the specified string after system property substitution.
- * @throws IllegalArgumentException If there was a syntax error in the
- * system property variable marker syntax or recursion will occur.
- **/
- public static String substVars(String val, String currentKey)
- throws IllegalArgumentException
- {
- StringBuffer sbuf = new StringBuffer();
-
- if (val == null)
- {
- return val;
- }
-
- int i = 0;
- int j, k;
-
- while (true)
- {
- j = val.indexOf(DELIM_START, i);
- if (j == -1)
- {
- if (i == 0)
- {
- return val;
- }
- else
- {
- sbuf.append(val.substring(i, val.length()));
- return sbuf.toString();
- }
- }
- else
- {
- sbuf.append(val.substring(i, j));
- k = val.indexOf(DELIM_STOP, j);
- if (k == -1)
- {
- throw new IllegalArgumentException(
- '"' + val +
- "\" has no closing brace. Opening brace at position "
- + j + '.');
- }
- else
- {
- j += DELIM_START_LEN;
- String key = val.substring(j, k);
-
- if (key.equals(currentKey))
- {
- throw new IllegalArgumentException("recursive property substitution in: " + currentKey);
- }
- // Try system properties.
- String replacement = getProperty(key, null);
- if (replacement != null)
- {
- sbuf.append(replacement);
- }
- i = k + DELIM_STOP_LEN;
- }
- }
- }
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Report.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Report.java
deleted file mode 100644
index 8c9337d..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Report.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public interface Report
- extends GenericHandlerItem
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // SIGNATURES
- //////////////////////////////////////////////////
-
- /**
- * Run Report for the specified list of BundleJars, generating output to
- * specified PrintStream.
- */
- public void run(PrintStream rpt, List jarList)
- throws IOException;
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ReportHandler.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ReportHandler.java
deleted file mode 100644
index 97f4d92..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/ReportHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Properties;
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class ReportHandler
- extends GenericHandler
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- /** Classname prefix for basic report classes. */
- public static final String REPORT_PACKAGE = "org.apache.felix.tool.mangen.report";
- /** Report property prefix. **/
- public static final String REPORT_KEY = "mangen-report-";
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- /**
- * Initialise the set of reports based on the REPORT_KEY.<n> properties defined.
- * Each reports is either a full classname implementing the Report interface, or a
- * classname in REPORT_PACKAGE. The actual work to process the properties and
- * create the report objects is done by our parent class, GenericHandler.
- */
- public ReportHandler()
- {
- super(REPORT_KEY, Report.class, REPORT_PACKAGE);
- }
-
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Retrieve each defined report and run it.
- */
- public void runReports(PrintStream rpt, List jarList)
- throws IOException
- {
- for(Iterator i = handlerList.iterator(); i.hasNext(); )
- {
- Report report = (Report) i.next();
- report.run(rpt, jarList);
- }
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Rule.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Rule.java
deleted file mode 100644
index 11e4f25..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/Rule.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public interface Rule
- extends GenericHandlerItem
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // SIGNATURES
- //////////////////////////////////////////////////
-
- /**
- * Execute the Rule on the supplied list of BundleJars.
- */
- public void execute(List jarList);
-
- /**
- * Send any output for the Rule to the specified PrintStream.
- */
- public void report(PrintStream rpt)
- throws IOException;
-
- /**
- * Should return true if Rule can be used globally (i.e. in mangen.properties).
- */
- public boolean isUsableGlobally();
-
- /**
- * Should return true if Rule can be used locally (i.e. in a bundle's manifest).
- */
- public boolean isUsableLocally();
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/RuleHandler.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/RuleHandler.java
deleted file mode 100644
index c70b03c..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/RuleHandler.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import java.util.jar.Attributes;
-
-/**
- *
- * @version $Revision: 31 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class RuleHandler
- extends GenericHandler
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- /** Classname prefix for basic rule classes */
- public static final String RULE_PACKAGE = "org.apache.felix.tool.mangen.rule";
- /** Rule set property **/
- public static final String RULESET_KEY = "mangen.rulesets";
- /** Default rule property prefix **/
- public static final String RULE_KEY = "mangen-rule-";
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- /**
- * Initialise a set of rules to be run, based on the value of the
- * mangen.rule property if present, or the default rule key if not.
- */
- public static RuleHandler[] initRuleSets()
- {
- String rulesetStr = PropertyManager.getProperty(RULESET_KEY, RULE_KEY);
-
- StringTokenizer tok = new StringTokenizer(rulesetStr, ",");
- RuleHandler[] handlers = new RuleHandler[tok.countTokens()];
- for (int ix = 0; ix < handlers.length; ix++)
- {
- handlers[ix] = new RuleHandler(tok.nextToken().trim());
- }
-
- return handlers;
- }
-
- /**
- * Run each specified ruleset.
- */
- public static void runRuleSets(RuleHandler[] handlers, List jarList)
- {
- for (int ix = 0; ix < handlers.length; ix++)
- {
- handlers[ix].executeRules(jarList);
- }
- }
-
- /**
- *
- * Run reports for each specified ruleset.
- */
- public static void runRuleSetReports(RuleHandler[] handlers, PrintStream rpt, boolean header)
- throws IOException
- {
- for (int ix = 0; ix < handlers.length; ix++)
- {
- handlers[ix].runReports(rpt, header);
- }
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- public boolean isGlobalRule;
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- /**
- * Initialise a rule handler usng the default RULE_KEY.
- */
- public RuleHandler()
- {
- this(RULE_KEY);
- }
-
- /**
- * Initialise the set of rules based on the RULE_KEY.<n> properties defined.
- * Each rule is either a full classname implementing the Rule interface, or a
- * classname in RULE_PACKAGE. The actual work to process the properties and
- * create the rule objects is done by our parent class, GenericHandler.
- */
- public RuleHandler(String key)
- {
- super(key, Rule.class, RULE_PACKAGE);
- // for now, safe to assume Property set based rules are global
- this.isGlobalRule = true;
- }
-
- /**
- * Initialise a rule handler based on a set of Manifest attributes.
- */
- public RuleHandler(Attributes atts)
- {
- super(atts, RULE_KEY, Rule.class, RULE_PACKAGE);
- // for now, safe to assume Attribute set based rules are local
- this.isGlobalRule = false;
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Retrieve each defined rule and apply it. At present we take the approach that
- * each rule will be applied in it's entirety before proceeding to the next rule.
- * For simple rules, this will result in multiple passes over
- * the jarList set for simowhich obviously incurs a processing overhead, but it is felt
- * that this simpler approach will have fewer nasty side-effects for more complex
- * rules that span multiple bundle jars.
- */
- public void executeRules(List jarList)
- {
- for(Iterator i = handlerList.iterator(); i.hasNext(); )
- {
- Rule rule = (Rule) i.next();
-
- if (isGlobalRule && !rule.isUsableGlobally())
- {
- throw new IllegalArgumentException("rule cannot be used globally: "
- + rule.getClass().getName());
- }
-
- if (!isGlobalRule && !rule.isUsableLocally())
- {
- throw new IllegalArgumentException("rule cannot be used locally: "
- + rule.getClass().getName());
- }
-
- rule.execute(jarList);
- }
- }
-
- /**
- * Run report for each rule. Bit of a hack for now!
- */
- public void runReports(PrintStream rpt, boolean header)
- throws IOException
- {
- for(Iterator i = handlerList.iterator(); i.hasNext(); )
- {
- Rule rule = (Rule) i.next();
-
- if (header)
- {
- rpt.println("");
- rpt.println("============================================================");
- rpt.println("Rule: " + rule.getClass().getName());
- rpt.println("============================================================");
- rpt.println("");
- }
- else
- {
- rpt.println("Rule: " + rule.getClass().getName());
- }
-
- rule.report(rpt);
- }
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/BundleReport.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/BundleReport.java
deleted file mode 100644
index ffe3efb..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/BundleReport.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.report;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import java.util.regex.Pattern;
-
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.OsgiPackage;
-import org.apache.felix.tool.mangen.Report;
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class BundleReport
- implements Report
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- public static Pattern[] pkgPatterns;
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- public boolean optShowDiffs = false;
- public boolean optShowLocalRules = false;
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public BundleReport()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Report
- //////////////////////////////////////////////////
-
- /**
- */
- public void run(PrintStream rpt, List jarList)
- throws IOException
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- doReport(rpt, bund);
- }
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - GenericHandlerItem
- //////////////////////////////////////////////////
-
- /**
- * Process the option set as a a space separated list of options.
- *
- * opt1 opt2
- */
- public void setOptions(String options)
- {
- for (StringTokenizer tok = new StringTokenizer(options, " "); tok.hasMoreTokens(); )
- {
- String opt = tok.nextToken().trim();
- if (opt.compareToIgnoreCase("show-differences") == 0)
- {
- optShowDiffs = true;
- }
- else if (opt.compareToIgnoreCase("show-local-rules") == 0)
- {
- optShowLocalRules = true;
- }
- }
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Produce a simple report on the current state of the imports and exports
- * for the specified bundle's jar.
- */
- protected void doReport(PrintStream rpt, BundleJar bund)
- throws IOException
- {
- rpt.println("");
- rpt.println("============================================================");
- rpt.println(bund.getName());
- rpt.println("============================================================");
- rpt.println("");
-
- if (optShowLocalRules && bund.bundleRuleHandler != null)
- {
- rpt.println("Local bundle rules:");
- bund.bundleRuleHandler.runReports(rpt, false);
- }
-
- if (optShowDiffs)
- {
- rpt.println("");
- rpt.println("mangen import differences:");
- showDiffs(bund.getPossibleImports(), bund.getCurrentImports(), rpt);
-
- rpt.println("");
- rpt.println("mangen export differences:");
- showDiffs(bund.getPossibleExports(), bund.getCurrentExports(), rpt);
- }
- else
- {
- rpt.println("");
- rpt.println("mangen proposed imports:");
- Set imports = bund.getPossibleImports();
- for(Iterator i = imports.iterator(); i.hasNext(); )
- {
- rpt.println(" " + (OsgiPackage) i.next());
- }
-
- rpt.println("");
- rpt.println("mangen proposed exports:");
- Set exports = bund.getPossibleExports();
- for(Iterator i = exports.iterator(); i.hasNext(); )
- {
- rpt.println(" " + (OsgiPackage) i.next());
- }
-
- rpt.println("");
- }
- }
-
- /**
- * Show the differences in the generated Set of packages and the current Set.
- */
- protected void showDiffs(Set genSet, Set currSet, PrintStream rpt)
- {
- for(Iterator i = genSet.iterator(); i.hasNext(); )
- {
- OsgiPackage newPkg = (OsgiPackage) i.next();
- if (!currSet.contains(newPkg))
- {
- rpt.println(" +++ ADDED :" + newPkg);
- }
- }
-
- for(Iterator i = currSet.iterator(); i.hasNext(); )
- {
- OsgiPackage oldPkg = (OsgiPackage) i.next();
- if (!genSet.contains(oldPkg))
- {
- rpt.println(" --- REMOVED :" + oldPkg);
- }
- }
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/ObrReport.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/ObrReport.java
deleted file mode 100644
index e749be1..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/ObrReport.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.report;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.GenericHandlerItemImpl;
-import org.apache.felix.tool.mangen.OsgiPackage;
-import org.apache.felix.tool.mangen.PropertyManager;
-import org.apache.felix.tool.mangen.Report;
-
-/**
- *
- * Produce a report for each bundle that can be used as an OBR descriptor
- *
- * @version $Revision: 14 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class ObrReport
- extends GenericHandlerItemImpl
- implements Report
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- public static String getObrProperty(String key)
- {
- String descrKey = key + "." + PropertyManager.getProperty("mangen.obr.ver", "1");
- return PropertyManager.getProperty(descrKey, "");
- }
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public ObrReport()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Report
- //////////////////////////////////////////////////
-
- /**
- */
- public void run(PrintStream rpt, List jarList)
- throws IOException
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- // only process JARs that don't match exclusion names
- if (!isJarNameMatch(bund.getName(), "skip-jars"))
- {
- doReport(rpt, bund);
- }
- }
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Produce a simple report on the current state of the imports and exports
- * for the specified bundle's jar.
- */
- protected void doReport(PrintStream rpt, BundleJar bund)
- throws IOException
- {
- String descrText = getObrProperty("mangen.obr.descr");
- rpt.println(expandTags(descrText, bund, null));
- }
-
- /**
- * Expands the tags in the OBR descriptor text. General method for
- * tag expansion. Will be called either from main bundle iteration
- * loop to expand the complete OBR descriptor template, and also recursively from
- * within individual tags to expand package specific template details.
- */
- protected String expandTags(String descr, BundleJar bund, OsgiPackage pkg)
- {
- StringBuffer expanded = new StringBuffer();
-
- int off = 0;
- int tagPos = descr.indexOf("@@", off);
-
- while (tagPos != -1)
- {
- expanded.append(descr.substring(off, tagPos));
- off = descr.indexOf("@@", tagPos+2);
- processTag(descr.substring(tagPos+2, off), expanded, bund, pkg);
- off += 2;
- tagPos = descr.indexOf("@@", off);
- }
- // final segment
- expanded.append(descr.substring(off));
- return expanded.toString();
- }
-
-
- /**
- * Expand single tag in the OBR descriptor text
- */
- protected void processTag(String tag, StringBuffer buf, BundleJar bund, OsgiPackage pkg)
- {
- String tagVal = "";
-
- if (tag.startsWith("hdr:"))
- {
- tagVal = bund.getManifestHeader(tag.substring(4), true);
- }
- else if (tag.equals("imports"))
- {
- Set imports = bund.getPossibleImports();
- String template = getObrProperty("mangen.obr.import");
- tagVal = expandPackageRefs(imports, template);
- }
- else if (tag.equals("exports"))
- {
- Set exports = bund.getPossibleExports();
- String template = getObrProperty("mangen.obr.export");
- tagVal = expandPackageRefs(exports, template);
- }
- else if (tag.equals("import-ver"))
- {
- // only include this if the version is non-null
- if (pkg != null && pkg.getVersion() != null)
- {
- // recurse for version template
- String template = getObrProperty("mangen.obr.import.ver");
- tagVal = expandTags(template, null, pkg);
- }
- }
- else if (tag.equals("export-ver"))
- {
- if (pkg != null && pkg.getVersion() != null)
- {
- // recurse for version template
- String template = getObrProperty("mangen.obr.export.ver");
- tagVal = expandTags(template, null, pkg);
- }
- }
- else if (tag.equals("pkg:name"))
- {
- // this tag should only appear in templates where we've a package
- if (pkg != null)
- {
- tagVal = pkg.getName();
- }
- }
- else if (tag.equals("pkg:ver"))
- {
- // this tag should only appear in templates where we've a package
- if (pkg != null && pkg.getVersion() != null)
- {
- tagVal = pkg.getVersion().toString();
- }
- }
-
- if (tagVal != null)
- {
- buf.append(tagVal);
- }
- }
-
- /**
- * Iterate over a set of package refs and expand each one using the
- * supplied template.
- */
- protected String expandPackageRefs(Set pkgSet, String template)
- {
- StringBuffer expanded = new StringBuffer();
-
- for(Iterator i = pkgSet.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- // recurse to expand tags, but this time only need to supply package
- expanded.append(expandTags(template, null, pkg));
- }
-
- return expanded.toString();
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/RuleReport.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/RuleReport.java
deleted file mode 100644
index a1d2475..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/report/RuleReport.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.report;
-
-import java.io.IOException;
-import java.io.PrintStream;
-
-import java.util.List;
-
-import java.util.regex.Pattern;
-
-import org.apache.felix.tool.mangen.MangenMain;
-import org.apache.felix.tool.mangen.Report;
-import org.apache.felix.tool.mangen.RuleHandler;
-
-/**
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class RuleReport
- implements Report
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- public static Pattern[] pkgPatterns;
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public RuleReport()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Report
- //////////////////////////////////////////////////
-
- /**
- */
- public void run(PrintStream rpt, List jarList)
- throws IOException
- {
- //TODO: bit of a hack for now!
- RuleHandler.runRuleSetReports(MangenMain.ruleSets, rpt, true);
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - GenericHandlerItem
- //////////////////////////////////////////////////
-
- /**
- */
- public void setOptions(String options)
- {
- //TODO: including checking of wildcard matching options
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/AttributeStamp.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/AttributeStamp.java
deleted file mode 100644
index a87f40d..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/AttributeStamp.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.MangenMain;
-import org.apache.felix.tool.mangen.OsgiPackage;
-import org.apache.felix.tool.mangen.OsgiStringPackage;
-import org.apache.felix.tool.mangen.OsgiR4Package;
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.Rule;
-
-/**
- * Rule to match package name strings against a wildcard pattern and them stamp the
- * package with additional OSGi attributes e.g. version information.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class AttributeStamp
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public AttributeStamp()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundles and for each bundle remove any import
- * which matches an export in the same bundle.
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " :");
-
- stampPackages(bund.getPossibleImports(), "imports", false);
- stampPackages(bund.getPossibleExports(), "exports", true);
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule can be used locally.
- */
- public boolean isUsableLocally()
- {
- return true;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Any string packages from the specified set which match package patterns in the
- * specified qualifier set will have the additional OSGi attributes "stamped"
- * onto their package specification. Packages that already have attributes which
- * match will generate warnings and be skipped.
- *
- */
- protected void stampPackages(Set set, String qualName, boolean export)
- {
- rptOut.println("");
- rptOut.println("... stamping packages in " + qualName);
- for(Iterator i = set.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- String stamp = getMatchingPatternString(pkg, qualName, true);
- if (stamp != null)
- {
- stamp(pkg, stamp, set, export);
- }
- }
- }
-
- /**
- * Stamp the supplied package with the specified attributes. This will be
- * an error if the package is already an R4 pakage with conflicting attributes.
- */
- protected void stamp(OsgiPackage pkg, String stamp, Set set, boolean export)
- {
- int delim = stamp.indexOf(";");
-
- if (delim == -1)
- {
- MangenMain.warning(rptOut, "*** WARNING *** stamp has no attributes: " + stamp);
- return;
- }
-
- // simple thing is to rebuild an OSGi header with attributes and use OsgiPackage
- // methods to parse this into an R4 package.
- String hdr = pkg.getName() + stamp.substring(delim);
- OsgiPackage[] newPkgs = (OsgiPackage[]) OsgiPackage.createFromHeaders(hdr, export).toArray(new OsgiPackage[0]);
- if (newPkgs.length != 1)
- {
- MangenMain.error(rptOut, "*** ERROR *** stamp doesn't create a single package : " + stamp);
- return;
- }
- OsgiPackage stampedPkg = newPkgs[0];
-
- // replace a simple string package with the stamped package
- if (pkg instanceof OsgiStringPackage)
- {
- set.remove(pkg);
- set.add(stampedPkg);
- rptOut.println(" > replacing : " + pkg + " with : " + stampedPkg);
- return;
-
- }
-
- // it's an error to try and stamp an existing package with different details
- if (pkg instanceof OsgiR4Package && pkg.compareTo(stampedPkg) != 0)
- {
- MangenMain.error(rptOut, "*** ERROR *** stamp has conflicting package details: " + pkg
- + " != " + stampedPkg);
- return;
- }
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/DontImportOwnExports.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/DontImportOwnExports.java
deleted file mode 100644
index 58054f7..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/DontImportOwnExports.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.OsgiPackage;
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.Rule;
-
-/**
- * Rule to exclude each bundle's own exports from it's list of possible imports.
- * <p>
- * Any packages which are exported by a bundle in general do not need to also
- * be imported and hence can be excluded from the list of possible imports.
- * <p>
- * Note that with OSGi R4 comes support for a bundle to import versions of it's
- * own packages from an alternate bundle. This may require enhancements to this
- * rule, or possibly extra rules.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class DontImportOwnExports
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public DontImportOwnExports()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundles and for each bundle remove any import
- * which matches an export in the same bundle.
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " :");
-
- Set exports = bund.getPossibleExports();
- Set imports = bund.getPossibleImports();
- for(Iterator j = exports.iterator(); j.hasNext(); )
- {
- remove(imports, (OsgiPackage) j.next());
- }
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule can be used locally.
- */
- public boolean isUsableLocally()
- {
- return true;
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - GenericHandlerItem
- //////////////////////////////////////////////////
-
- /**
- * No required options for this rule.
- */
- public void setOptions(String options)
- {
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Removes any import which is an exact match for the supplied package.
- */
- protected void remove(Set set, OsgiPackage pkg)
- {
- if (set.contains(pkg))
- {
- rptOut.println("... removing import of own export: " + pkg);
- set.remove(pkg);
- }
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Force.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Force.java
deleted file mode 100644
index 297ab3a..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Force.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import java.util.regex.Pattern;
-
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.OsgiPackage;
-
-/**
- * Force a set of imports or exports globally.
- * <p>
- * Package names that match any of a list of regex based package name patterns
- * will be excluded from the list of possible imports.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class Force
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public Force()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundle jars, removing any imports
- * which match any of the specific package name Patterns
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " :");
-
- forcePackages(bund.getPossibleImports(), "imports");
- forcePackages(bund.getPossibleExports(), "exports");
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule can be used locally.
- */
- public boolean isUsableLocally()
- {
- return true;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Force a set of packages into the list
- */
- public void forcePackages(Set set, String qualName)
- {
- Set pkgs = (Set) optionMap.get(qualName);
- if (set != null && pkgs != null)
- {
- for(Iterator i = pkgs.iterator(); i.hasNext(); )
- {
- Pattern patt = (Pattern) i.next();
- set.add(OsgiPackage.createStringPackage(patt.pattern()));
- }
- }
- }
-
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/GenericRule.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/GenericRule.java
deleted file mode 100644
index c0ed6ef..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/GenericRule.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.PrintStream;
-
-import org.apache.felix.tool.mangen.GenericHandlerItemImpl;
-import org.apache.felix.tool.mangen.Rule;
-
-/**
- * Holder for common Rule handling methods, such as reporting
- *
- * @version $Revision: 27 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public abstract class GenericRule
- extends GenericHandlerItemImpl
- implements Rule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- /** Holds buffered rule output in case a rule report is requested */
- public ByteArrayOutputStream rptBuf = new ByteArrayOutputStream();
- public PrintStream rptOut = new PrintStream(rptBuf);
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public GenericRule()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- public void report(PrintStream rpt)
- throws IOException
- {
- rptBuf.writeTo(rpt);
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Ignore.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Ignore.java
deleted file mode 100644
index 07f6900..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Ignore.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.OsgiPackage;
-
-/**
- * Rule to exclude specific packages from each bundle's possible imports.
- * <p>
- * Package names that match any of a list of regex based package name patterns
- * will be excluded from the list of possible imports.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class Ignore
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public Ignore()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundle jars, removing any imports
- * which match any of the specific package name Patterns
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " :");
-
- removeMatchingPackages(bund.getPossibleImports(), "imports");
- removeMatchingPackages(bund.getPossibleExports(), "exports");
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule can be used locally.
- */
- public boolean isUsableLocally()
- {
- return true;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Removes all packages from the set which match package patterns in the
- * specified qualifier set.
- */
- public void removeMatchingPackages(Set set, String qualName)
- {
- for(Iterator i = set.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- if (isPackageMatch(pkg, qualName))
- {
- rptOut.println("... removing ignored package from " + qualName + " : " + pkg);
- i.remove();
- }
- }
- }
-
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Merge.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Merge.java
deleted file mode 100644
index 60e8cae..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/Merge.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.OsgiPackage;
-import org.apache.felix.tool.mangen.OsgiStringPackage;
-import org.apache.felix.tool.mangen.OsgiR4Package;
-
-/**
- * Rule to merge the current mangenn mangen created import and/or export package sets
- * with some other package set.
- * <p>
- * At present the possible other package sets are:
- * <ul>
- * <li> existing - existing <code>Export-Package</code> or <code>Import-Package</code> statements in the
- * current manifest
- * <li> fixed - <code>Export-Package</code> or <code>Import-Package</code> in the mangen section of
- * the current manifest
- * </ul>
- * Package names that match any of a list of regex based package name patterns
- * will be merged into the mangen generated list of possible imports or exports
- * (as appropriate).
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class Merge
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public Merge()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- public boolean existing = false;
-
- public boolean fixed = false;
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundle jars, removing any imports
- * which match any of the specific package name Patterns
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
-
- if (existing)
- {
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " existing package set:");
- mergePackages(bund.getCurrentImports(), "imports", bund.getPossibleImports());
- mergePackages(bund.getCurrentExports(), "exports", bund.getPossibleExports());
- }
-
- if (fixed)
- {
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " fixed package set:");
- mergePackages(bund.getFixedImports(), "imports", bund.getPossibleImports());
- mergePackages(bund.getFixedExports(), "exports", bund.getPossibleExports());
- }
-
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule can be used locally.
- */
- public boolean isUsableLocally()
- {
- return true;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Overrides superclass version to look for 'existing' and 'fixed' option
- * qualifiers
- */
- protected void processNonStandardQualifier(String qual)
- {
- if (qual.compareToIgnoreCase("existing") == 0 )
- {
- existing = true;
- }
- else if (qual.compareToIgnoreCase("fixed") == 0)
- {
- fixed = true;
- }
- }
-
- /**
- * Any packages from the specified current set which match package patterns in the
- * specified qualifier set will be merged into the specified mangen set.
- *
- * In the case where the current package does not already exist in the mangen set,
- * merging is a simple matter of adding the package.
- *
- * In the case where the current package is already present in the mangen set, then
- * a decision is needed on how to merge any version information present on the
- * package entry in either set.
- */
- protected void mergePackages(Set currentSet, String qualName, Set mangenSet)
- {
- rptOut.println("");
- rptOut.println("... merge to " + qualName);
- for(Iterator i = currentSet.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- if (isPackageMatch(pkg, qualName))
- {
- merge(pkg, mangenSet);
- }
- }
- }
-
- /**
- * Merge the supplied package into the specified set.
- */
- protected void merge(OsgiPackage pkgToMerge, Set set)
- {
- // oops, set doesn't have a "get". Guess we could move to using Map
- // but Sets are working for most other cases, so find by hand for now.
- OsgiPackage existingPkg = getPackageFromSet(pkgToMerge, set);
-
- // if not present in any form, then we can add
- if (existingPkg == null)
- {
- set.add(pkgToMerge);
- rptOut.println(" > adding : " + pkgToMerge);
- return;
- }
-
- // There's no added value in merging string packages to anything already present
- // since they carry no extra package attributes
- if (pkgToMerge instanceof OsgiStringPackage)
- {
- return;
- }
-
- // string packages can be replaced with R4 package, which will have
- // extended package attributes.
- if (existingPkg instanceof OsgiStringPackage)
- {
- set.remove(existingPkg);
- set.add(pkgToMerge);
- rptOut.println(" > replacing : " + existingPkg + " with : " + pkgToMerge);
- return;
- }
-
- // if present and don't match then throw error
- if (existingPkg instanceof OsgiR4Package && existingPkg.compareTo(pkgToMerge) != 0)
- {
- rptOut.println("*** ERROR *** can't merge conflicting package details: " + pkgToMerge
- + " != " + existingPkg);
- return;
- }
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ProcessBundles.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ProcessBundles.java
deleted file mode 100644
index e957a95..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ProcessBundles.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.io.IOException;
-
-import java.util.List;
-import java.util.Iterator;
-
-import org.apache.felix.tool.mangen.MangenMain;
-import org.apache.felix.tool.mangen.BundleJar;
-
-/**
- * Rule to caused each Bundle JAR to be processed. This will involved scanning
- * the classes and inner jars within each bundle JAR to determine the range of
- * possible imports and exports.
- *
- * @version $Revision: 18 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class ProcessBundles
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public ProcessBundles()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundles and ask each bundle to process it's
- * contained classes and inner JARs.
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- try
- {
- bund.process();
- }
- catch (RuntimeException re)
- {
- MangenMain.error(rptOut, "Exception: " + re + ", skipping bundle jar: " + bund.getName());
- re.printStackTrace(rptOut);
- }
- catch (Exception e)
- {
- MangenMain.error(rptOut, "Exception: " + e + ", skipping bundle jar: " + bund.getName());
- }
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule cannot be used locally.
- */
- public boolean isUsableLocally()
- {
- return false;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ResolveImportsToExports.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ResolveImportsToExports.java
deleted file mode 100644
index 7213254..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/ResolveImportsToExports.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.util.List;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.felix.tool.mangen.MangenMain;
-import org.apache.felix.tool.mangen.BundleJar;
-import org.apache.felix.tool.mangen.OsgiPackage;
-
-/**
- * Rule to resolve the set of imports and exports across all bundles.
- * <p>
- * Exports that are not required to satisfy any bundle import will be removed. Imports
- * which have no matching exports will be reported, as will duplicate exports.
- * <p>
- * At present duplicate package names are detected solely on name. In future this
- * needs to be extended to include a version, or version range match.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class ResolveImportsToExports
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- public Set allImports = OsgiPackage.getNewSet();
- public Set resolvedImports = OsgiPackage.getNewSet();
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public ResolveImportsToExports()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
-
- public void execute(List jarList)
- {
- // build up complete set of required imports
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- allImports.addAll(bund.getPossibleImports());
- }
-
- // for each bundle, resolve exports to imports and remove exports
- // that don't match a required import
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- rptOut.println("");
- rptOut.println("> " + bund.getName() + " :");
-
- Set exports = bund.getPossibleExports();
- for(Iterator j = exports.iterator(); j.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) j.next();
- if (allImports.contains(pkg))
- {
- // exports matches imports, move it to resolved list or report
- // duplicate if already there
- allImports.remove(pkg);
- resolvedImports.add(pkg);
- rptOut.println(" ... resolved export: " + pkg);
- }
- else if (resolvedImports.contains(pkg))
- {
- MangenMain.warning(rptOut, "*** WARNING *** duplicate export, removing: " + pkg);
- //TODO: for now we'll suppress the duplicate, which means first
- // seen becomes the exporter. Probably need to handle
- // better e.g. using versions or wilcard rules in manifest
- // to decide who exports
- j.remove();
- }
- else
- {
- // export doesn't match any imports, so remove it
- rptOut.println(" ... removing un-needed export: " + pkg);
- j.remove();
- }
- }
- }
-
- rptOut.println("");
-
- // report any unresolved imports
- for(Iterator i = allImports.iterator(); i.hasNext(); )
- {
- OsgiPackage pkg = (OsgiPackage) i.next();
- if (!isPackageMatch(pkg, "sys-packages"))
- {
- MangenMain.warning(rptOut, "*** WARNING *** unresolved import: " + pkg);
- }
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule cannot be used locally.
- */
- public boolean isUsableLocally()
- {
- return false;
- }
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/UpdateBundles.java b/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/UpdateBundles.java
deleted file mode 100644
index 59bc7ef..0000000
--- a/tools/mangen/src/main/java/org/apache/felix/tool/mangen/rule/UpdateBundles.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tool.mangen.rule;
-
-import java.io.IOException;
-
-import java.util.List;
-import java.util.Iterator;
-
-import org.apache.felix.tool.mangen.MangenMain;
-import org.apache.felix.tool.mangen.BundleJar;
-
-/**
- * Rule to request each bundle to update it's manifest, based on the mangen
- * rule-based set of imports and exports.
- *
- * @version $Revision: 29 $
- * @author <A HREF="mailto:robw@ascert.com">Rob Walker</A>
- */
-public class UpdateBundles
- extends GenericRule
-{
- //////////////////////////////////////////////////
- // STATIC VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC PUBLIC METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // INSTANCE VARIABLES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // CONSTRUCTORS
- //////////////////////////////////////////////////
-
- public UpdateBundles()
- {
- }
-
- //////////////////////////////////////////////////
- // ACCESSOR METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // PUBLIC INSTANCE METHODS
- //////////////////////////////////////////////////
-
- public boolean overwrite = false;
-
- //////////////////////////////////////////////////
- // INTERFACE METHODS - Rule
- //////////////////////////////////////////////////
-
- /**
- * Iterate over the list of bundles and ask each bundle to update itself.
- */
- public void execute(List jarList)
- {
- for(Iterator i = jarList.iterator(); i.hasNext(); )
- {
- BundleJar bund = (BundleJar) i.next();
- try
- {
- rptOut.println("Updating bundle: " + bund.getName() + " :");
- bund.update(overwrite);
- }
- catch (IOException ioe)
- {
- MangenMain.error(rptOut, "IO Exception occured during update: " + ioe);
- }
- }
- }
-
- /**
- * This rule can be used globally.
- */
- public boolean isUsableGlobally()
- {
- return true;
- }
-
- /**
- * This rule cannot be used locally.
- */
- public boolean isUsableLocally()
- {
- return false;
- }
-
- //////////////////////////////////////////////////
- // PROTECTED INSTANCE METHODS
- //////////////////////////////////////////////////
-
- /**
- * Overrides superclass version to look for 'overwrite' option qualifiers
- */
- protected void processNonStandardQualifier(String qual)
- {
- if (qual.compareToIgnoreCase("overwrite") == 0 )
- {
- overwrite = true;
- }
- }
-
- //////////////////////////////////////////////////
- // PRIVATE INSTANCE METHODS
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
- //////////////////////////////////////////////////
- // NON-STATIC INNER CLASSES
- //////////////////////////////////////////////////
-
-}
diff --git a/tools/mangen/src/main/manifest/Manifest.mf b/tools/mangen/src/main/manifest/Manifest.mf
deleted file mode 100644
index e43931d..0000000
--- a/tools/mangen/src/main/manifest/Manifest.mf
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: org.apache.felix.tool.mangen.MangenMain
-Class-Path: bcel.jar asm.jar felix.main.jar felix.framework.jar org.osgi.core.jar
diff --git a/tools/mangen/src/main/resources/mangen.properties b/tools/mangen/src/main/resources/mangen.properties
deleted file mode 100644
index 446d13d..0000000
--- a/tools/mangen/src/main/resources/mangen.properties
+++ /dev/null
@@ -1,102 +0,0 @@
-# ------------------------------------------------------------------
-# General mangen properties example
-# ------------------------------------------------------------------
-
-# Determines which OSGi release level to create the bundle jars against. Current
-# valid values are '3' and '4' (default is '3')
-mangen.osgi.level=3
-
-
-# Determines whether to automatically process any inner jars found, including
-# generation of a suitable "Bundle-Classpath" header. Valid values are 'true' or
-# 'false' (default is 'false').
-#TODO: not implemented yet
-#mangen.innerjar.auto=true
-
-# Default is to fail (exit code = 3) on errors, can be disabled
-#mangen.failonerror=off
-# Optionally can be made to fail (exit code = 5) if there are warnings
-#mangen.failonwarning=on
-
-#
-# The concept of rulesets is to make it easier to group whole sets of rules for
-# use e.g. here it's used to separate general rules, OSGi R3 vs. OSGi R4
-# specific rules, and an app. specific rule to ignore all Ant packages found
-# in packages. Without rulesets, the sequential numbering means that mixing
-# and matching various rules requires a lot of manual renumbering.
-#
-# Note also the use of ${var} expansion, which follows the same model as used
-# for Oscar properties (http://oscar.objectweb.org/)
-#
-mangen.rulesets=mangen-rule-initial- , mangen-rule-R${mangen.osgi.level}- , mangen-rule- , mangen-rule-final-
-
-# Standard JDK javax.* packages
-mangen.jdk.javax.packages=javax\\.accessibility,javax\\.crypto,javax\\.crypto\\.interfaces,javax\\.crypto\\.spec,javax\\.imageio,javax\\.imageio\\.event,javax\\.imageio\\.metadata,javax\\.imageio\\.plugins\\.jpeg,javax\\.imageio\\.spi,javax\\.imageio\\.stream,javax\\.naming,javax\\.naming\\.directory,javax\\.naming\\.event,javax\\.naming\\.ldap,javax\\.naming\\.spi,javax\\.net,javax\\.net\\.ssl,javax\\.print,javax\\.print\\.attribute,javax\\.print\\.attribute\\.standard,javax\\.print\\.event,javax\\.rmi,javax\\.rmi\\.CORBA,javax\\.security\\.auth,javax\\.security\\.auth\\.callback,javax\\.security\\.auth\\.kerberos,javax\\.security\\.auth\\.login,javax\\.security\\.auth\\.spi,javax\\.security\\.auth\\.x500,javax\\.security\\.cert,javax\\.sound\\.midi,javax\\.sound\\.midi\\.spi,javax\\.sound\\.sampled,javax\\.sound\\.sampled\\.spi,javax\\.sql,javax\\.swing,javax\\.swing\\.border,javax\\.swing\\.colorchooser,javax\\.swing\\.event,javax\\.swing\\.filechooser,javax\\.swing\\.plaf,javax\\.swing\\.plaf\\.basic,javax\\.swing\\.plaf\\.metal,javax\\.swing\\.plaf\\.multi,javax\\.swing\\.table,javax\\.swing\\.text,javax\\.swing\\.text\\.html,javax\\.swing\\.text\\.html\\.parser,javax\\.swing\\.text\\.rtf,javax\\.swing\\.tree,javax\\.swing\\.undo,javax\\.transaction,javax\\.transaction\\.xa,javax\\.xml\\.parsers,javax\\.xml\\.transform,javax\\.xml\\.transform\\.dom,javax\\.xml\\.transform\\.sax,javax\\.xml\\.transform\\.stream,org\\.ietf\\.jgss,org\\.omg\\.CORBA,org\\.omg\\.CORBA_2_3,org\\.omg\\.CORBA_2_3\\.portable,org\\.omg\\.CORBA\\.DynAnyPackage,org\\.omg\\.CORBA\\.ORBPackage,org\\.omg\\.CORBA\\.portable,org\\.omg\\.CORBA\\.TypeCodePackage,org\\.omg\\.CosNaming,org\\.omg\\.CosNaming\\.NamingContextExtPackage,org\\.omg\\.CosNaming\\.NamingContextPackage,org\\.omg\\.Dynamic,org\\.omg\\.DynamicAny,org\\.omg\\.DynamicAny\\.DynAnyFactoryPackage,org\\.omg\\.DynamicAny\\.DynAnyPackage,org\\.omg\\.IOP,org\\.omg\\.IOP\\.CodecFactoryPackage,org\\.omg\\.IOP\\.CodecPackage,org\\.omg\\.Messaging,org\\.omg\\.PortableInterceptor,org\\.omg\\.PortableInterceptor\\.ORBInitInfoPackage,org\\.omg\\.PortableServer,org\\.omg\\.PortableServer\\.CurrentPackage,org\\.omg\\.PortableServer\\.POAManagerPackage,org\\.omg\\.PortableServer\\.POAPackage,org\\.omg\\.PortableServer\\.portable,org\\.omg\\.PortableServer\\.ServantLocatorPackage,org\\.omg\\.SendingContext,org\\.omg\\.stub\\.java\\.rmi,org\\.w3c\\.dom,org\\.xml\\.sax,org\\.xml\\.sax\\.ext,org\\.xml\\.sax\\.helpers
-# R3 treats any standard JDK classes as system packages
-mangen.R3.syspackages=java\\..*,sun\\..*,com\\.sun\\..*,${mangen.jdk.javax.packages}
-# R4 system packages are only considered to be java.*
-mangen.R4.syspackages=java\\..*
-
-# Initial rule to "process" each bundle's JAR. Without this, no class scanning
-# will be done. Hence this will nearly always be the first rule.
-mangen-rule-initial-0=ProcessBundles
-# App specific rule to ignore Ant packages
-mangen-rule-initial-1=Ignore imports(org\\.apache\\.tools\\.ant.*)
-
-
-# R3 rule to ignore all standard JDK classes.
-#
-# The rule contains an option, in this case imports(), which contains a comma
-# separate list of option qualifiers, in this case a set of regex patterns to
-# match against package name.
-#
-# Care needs to be taken with delimitter chars - ',' and space (' ') should
-# not be used except as shown since the tokenizer needs them for parsing.
-#
-mangen-rule-R3-0=Ignore imports(${mangen.R3.syspackages})
-mangen-rule-R3-1=DontImportOwnExports
-mangen-rule-R3-2=ResolveImportsToExports sys-packages(${mangen.R3.syspackages})
-
-# R4 rule is only to ignore java.* classes
-mangen-rule-R4-0=Ignore imports(${mangen.R4.syspackages})
-mangen-rule-R4-1=DontImportOwnExports
-mangen-rule-R4-2=ResolveImportsToExports sys-packages(${mangen.R4.syspackages})
-
-# General rules. These use the default rule name and will also be used if no
-# "mangen.rulesets" property is specified.
-#mangen-rule-0=Merge existing imports(.*) exports(.*)
-mangen-rule-0=Merge fixed imports(.*) exports(.*)
-
-# The AttribuetStamp rule allows atrtibutes to be supplied to be include with
-# mangen generated package names. Shown commented out here to give an example
-#
-#mangen-rule-1=AttributeStamp imports(org\\.osgi\\.framework;version="1.2.0") exports(org\\.osgi\\.service\\.cm;version="2.0.0")
-
-# Final rules. We use these here to run a rule that will force an update to the
-# bundle manifests. The "overwrite" option tells mangen to overwrite the bundle
-# with the new version.
-#
-mangen-rule-final-0=UpdateBundles
-#mangen-rule-final-0=UpdateBundles overwrite
-
-#
-# Details of which mangen reports need to be run
-#
-mangen-report-0=RuleReport
-#mangen-report-1=BundleReport show-local-rules show-differences
-mangen-report-1=BundleReport show-local-rules
-
-#-----------------------------------------------------------------------------
-#
-# Properties below this section should not be changed without a good
-# understanding of mangen's internal operation
-#
-
-# Specifies which scanner class to use.
-#mangen.scanner.class=org.apache.felix.tool.mangen.BCELScanner
-mangen.scanner.class=org.apache.felix.tool.mangen.ASMClassScanner
-
-# Diagnostic tracing
-#mangen.trace=on
-
-
diff --git a/tools/mangen/src/main/resources/obr.properties b/tools/mangen/src/main/resources/obr.properties
deleted file mode 100644
index 22fed88..0000000
--- a/tools/mangen/src/main/resources/obr.properties
+++ /dev/null
@@ -1,100 +0,0 @@
-# ------------------------------------------------------------------
-# Example mangen properties for generation of OBR descriptors
-# ------------------------------------------------------------------
-
-#
-# We don't use a ProcessBundles rule, hence no imports/exports will be generated
-# Rather than assume this will always be the case, we use a "Merge" rule to
-# merge the current imports/exports into the mangen set. This allows the
-# ObrReport to use the mangen generated set, and ensures that
-# descriptors can be created either from existing import/exports or generated
-# imports/exports.
-#
-mangen.rulesets=mangen-rule-
-mangen-rule-0=Merge existing imports(.*) exports(.*)
-
-#
-# Create the OBR descriptor report
-#
-mangen-report-0=ObrReport skip-jars(.*-src\\.jar)
-
-#-----------------------------------------------------------------------------
-#
-# Properties below this section should not be changed without a good
-# understanding of mangen's internal operation
-#
-
-# Specifies which scanner class to use.
-mangen.scanner.class=com.ascert.openosgi.mangen.BCELScanner
-#mangen.scanner.class=org.ungoverned.osgi.mangen.ASMClassScanner
-
-#
-# Controls which format of OBR descriptor to create
-#
-mangen.obr.ver=1
-
-#
-# Formats for OBR 1 descriptor
-#
-mangen.obr.descr.1=\
-<bundle>\n \
- <bundle-name>@@hdr:Bundle-Name@@</bundle-name>\n \
- <bundle-description>@@hdr:Bundle-Description@@</bundle-description>\n \
- <bundle-updatelocation>@@hdr:Bundle-UpdateLocation@@</bundle-updatelocation>\n \
- <bundle-sourceurl>@@hdr:Bundle-SourceUrl@@</bundle-sourceurl>\n \
- <bundle-version>@@hdr:Bundle-Version@@</bundle-version>\n \
- <bundle-docurl>@@hdr:Bundle-DocURL@@</bundle-docurl>\n \
- <bundle-category>@@hdr:Bundle-Category@@</bundle-category>\n \
- @@imports@@\
- @@exports@@\n\
-</bundle>
-
-mangen.obr.import.1=<import-package package="@@pkg:name@@" @@import-ver@@/>\n
-mangen.obr.import.ver.1=specification-version="@@pkg:ver@@"
-
-mangen.obr.export.1=<export-package package="@@pkg:name@@" @@export-ver@@/>\n
-mangen.obr.export.ver.1=specification-version="@@pkg:ver@@"
-
-#
-# Formats for OBR 2 descriptor
-#
-mangen.obr.descr.2=\
-<bundle>\n \
- <bundle-name>@@hdr:Bundle-Name@@</bundle-name>\n \
- <bundle-symbolicname>@@hdr:Bundle-SymbolicName@@</bundle-symbolicname>\n \
- <bundle-description>@@hdr:Bundle-Description@@</bundle-description>\n \
- <bundle-url>@@hdr:Bundle-URL@@</bundle-url>\n \
- <bundle-sourceurl>@@hdr:Bundle-SourceUrl@@</bundle-sourceurl>\n \
- <bundle-version>@@hdr:Bundle-Version@@</bundle-version>\n \
- <bundle-docurl>@@hdr:Bundle-DocURL@@</bundle-docurl>\n \
- <bundle-category>@@hdr:Bundle-Category@@</bundle-category>\n \
- @@imports@@ \
- @@exports@@\n\
-</bundle>
-
-mangen.obr.import.2= \
- <requirement>\n \
- <![CDATA[\n \
- (&(type=Export-Package)\n \
- (name=@@pkg:name@@)\n \
- @@import-ver@@)\n \
- ]]>\n \
- </requirement>\n
-mangen.obr.import.ver.2=(version>=@@pkg:ver@@)
-
-mangen.obr.export.2= \
- <capability>\n \
- <property name="type"\n \
- type="java.lang.String"\n \
- value="Export-Package"/>\n \
- <property name="name"\n \
- type="java.lang.String"\n \
- value="@@pkg:name@@"/>\n \
- @@export-ver@@\
- </capability>
-mangen.obr.export.ver.2=\
- <property name="version"\n \
- type="org.ungoverned.osgi.bundle.bundlerepository.R4Version"\n \
- value="@@pkg:ver@@"/>\n \
-
-
diff --git a/tools/maven2/felix-archetype/pom.xml b/tools/maven2/felix-archetype/pom.xml
deleted file mode 100644
index 6a5578e..0000000
--- a/tools/maven2/felix-archetype/pom.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix.archetypes</groupId>
- <artifactId>felix-archetype</artifactId>
- <packaging>maven-plugin</packaging>
- <version>0.9.0-SNAPSHOT</version>
- <name>Felix Archetype</name>
-</project>
diff --git a/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml b/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml
deleted file mode 100644
index 73b3df3..0000000
--- a/tools/maven2/felix-archetype/src/main/resources/META-INF/archetype.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<archetype>
- <id>felix-archetype</id>
- <sources>
- <source>src/main/java/Activator.java</source>
- </sources>
-</archetype>
\ No newline at end of file
diff --git a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml
deleted file mode 100644
index 57faa23..0000000
--- a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/pom.xml
+++ /dev/null
@@ -1,68 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <packaging>osgi-bundle</packaging>
- <version>${version}</version>
- <name>Simple Bundle Project</name>
- <url>http://felix.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>0.9.0-incubator-SNAPSHOT</version>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-
- <build>
- <!-- Uncomment to override default bundle jar naming convention
- <finalName>my-bundle</finalName>
- -->
-
- <plugins>
- <plugin>
- <groupId>org.apache.felix.plugins</groupId>
- <artifactId>maven-felix-plugin</artifactId>
- <executions>
- <execution>
- <id>run</id>
- <configuration>
- <felixCacheDir>${basedir}/target/.felix</felixCacheDir>
- <exclusions>
- <exclusion>junit:junit</exclusion>
- </exclusions>
- </configuration>
- <goals>
- <goal>run</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix.plugins</groupId>
- <artifactId>maven-osgi-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <!-- Uncomment to specify a manifest file to merge
- <manifestFile>path/to/manifest.mf</manifestFile>
- -->
- <osgiManifest>
- <bundleName>Simple Bundle</bundleName>
- <bundleActivator>${groupId}.Activator</bundleActivator>
- <bundleVendor>Apache Software Foundation</bundleVendor>
- </osgiManifest>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java b/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
deleted file mode 100644
index 558c419..0000000
--- a/tools/maven2/felix-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package ${groupId};
-
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-
-
-/**
- * This class implements a simple bundle that utilizes the OSGi
- * framework's event mechanism to listen for service events.
- *
- * Upon receiving a service event, it prints out the event's details.
- */
-public class Activator implements BundleActivator, ServiceListener
-{
- /**
- * Put your bundle initialization code here...
- *
- * Implements <code>BundleActivator.start()</code>. Prints a message
- * and adds itself to the bundle context as a service listener.
- *
- * @param bundleContext the framework context for the bundle
- * @throws Exception
- */
- public void start( BundleContext bundleContext ) throws Exception
- {
- System.out.println( "SimpleBundle: Starting to listen for service events." );
- bundleContext.addServiceListener( this );
- }
-
-
- /**
- * Put your bundle finalization code here...
- *
- * Implements <code>BundleActivator.stop()</code>. Prints a message
- * and removes itself from the bundle context as a service listener.
- *
- * @param bundleContext the framework context for the bundle
- * @throws Exception
- */
- public void stop( BundleContext bundleContext ) throws Exception
- {
- bundleContext.removeServiceListener( this );
- System.out.println( "SimpleBundle: Stopped listening for service events." );
-
- // Note: It is not required that we remove the listener here, since
- // the framework will do it automatically anyway.
- }
-
-
- /**
- * Implements <code>ServiceListener.serviceChanges()</code>. Prints the
- * details of any service event from the framework.
- *
- * @param event the fired service event
- */
- public void serviceChanged( ServiceEvent event )
- {
- String[] objectClass = ( String[] ) event.getServiceReference().getProperty( "objectClass" );
-
- switch( event.getType() )
- {
- case( ServiceEvent.REGISTERED ):
- System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " registered." );
- break;
- case( ServiceEvent.UNREGISTERING ):
- System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " unregistering." );
- break;
- case( ServiceEvent.MODIFIED ):
- System.out.println( "SimpleBundle: Service of type " + objectClass[0] + " modified." );
- break;
- default:
- break;
- }
- }
-}
diff --git a/tools/maven2/maven-felix-plugin/pom.xml b/tools/maven2/maven-felix-plugin/pom.xml
deleted file mode 100644
index 254d253..0000000
--- a/tools/maven2/maven-felix-plugin/pom.xml
+++ /dev/null
@@ -1,48 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>felix</artifactId>
- <groupId>org.apache.felix</groupId>
- <version>1.4.0</version>
- <relativePath>../../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix.plugins</groupId>
- <artifactId>maven-felix-plugin</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
- <name>Maven Felix Plugin</name>
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.0.5</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.framework</artifactId>
- <version>1.0.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
-</project>
diff --git a/tools/maven2/maven-felix-plugin/src/main/java/org/apache/felix/tools/maven/felix/plugin/FelixRunMojo.java b/tools/maven2/maven-felix-plugin/src/main/java/org/apache/felix/tools/maven/felix/plugin/FelixRunMojo.java
deleted file mode 100644
index ac89c5f..0000000
--- a/tools/maven2/maven-felix-plugin/src/main/java/org/apache/felix/tools/maven/felix/plugin/FelixRunMojo.java
+++ /dev/null
@@ -1,757 +0,0 @@
-/*
- * Copyright 2006 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package org.apache.felix.tools.maven.felix.plugin;
-
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.framework.Felix;
-import org.apache.felix.framework.util.StringMap;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.util.FileUtils;
-
-
-/**
- * Starts up Felix, installs this module's bundle artifact with dependent
- * bundles, and starts them.
- *
- * @goal run
- * @phase integration-test
- */
-public class FelixRunMojo extends AbstractMojo
-{
- private static final String JRE_1_3_PACKAGES =
- "javax.accessibility;" +
- "javax.accessibility.resources;" +
- "javax.naming;" +
- "javax.naming.directory;" +
- "javax.naming.event;" +
- "javax.naming.ldap;" +
- "javax.naming.spi;" +
- "javax.rmi;" +
- "javax.rmi.CORBA;" +
- "javax.sound.midi;" +
- "javax.sound.midi.spi;" +
- "javax.sound.sampled;" +
- "javax.sound.sampled.spi;" +
- "javax.swing;" +
- "javax.swing.border;" +
- "javax.swing.colorchooser;" +
- "javax.swing.event;" +
- "javax.swing.filechooser;" +
- "javax.swing.plaf;" +
- "javax.swing.plaf.basic;" +
- "javax.swing.plaf.basic.resources;" +
- "javax.swing.plaf.metal;" +
- "javax.swing.plaf.metal.resources;" +
- "javax.swing.plaf.multi;" +
- "javax.swing.table;" +
- "javax.swing.text;" +
- "javax.swing.text.html;" +
- "javax.swing.text.html.parser;" +
- "javax.swing.text.rtf;" +
- "javax.swing.tree;" +
- "javax.swing.undo;" +
- "javax.transaction;" +
- "org.omg.CORBA;" +
- "org.omg.CORBA_2_3;" +
- "org.omg.CORBA_2_3.portable;" +
- "org.omg.CORBA.DynAnyPackage;" +
- "org.omg.CORBA.ORBPackage;" +
- "org.omg.CORBA.portable;" +
- "org.omg.CORBA.TypeCodePackage;" +
- "org.omg.CosNaming;" +
- "org.omg.CosNaming.NamingContextPackage;" +
- "org.omg.SendingContext;" +
- "org.omg.stub.java.rmi;version=\"1.3.0\"";
-
- private static final String JRE_1_4_PACKAGES =
- "javax.accessibility;" +
- "javax.imageio;" +
- "javax.imageio.event;" +
- "javax.imageio.metadata;" +
- "javax.imageio.plugins.jpeg;" +
- "javax.imageio.spi;" +
- "javax.imageio.stream;" +
- "javax.naming;" +
- "javax.naming.directory;" +
- "javax.naming.event;" +
- "javax.naming.ldap;" +
- "javax.naming.spi;" +
- "javax.print;" +
- "javax.print.attribute;" +
- "javax.print.attribute.standard;" +
- "javax.print.event;" +
- "javax.rmi;" +
- "javax.rmi.CORBA;" +
- "javax.security.auth;" +
- "javax.security.auth.callback;" +
- "javax.security.auth.kerberos;" +
- "javax.security.auth.login;" +
- "javax.security.auth.spi;" +
- "javax.security.auth.x500;" +
- "javax.sound.midi;" +
- "javax.sound.midi.spi;" +
- "javax.sound.sampled;" +
- "javax.sound.sampled.spi;" +
- "javax.sql;" +
- "javax.swing;" +
- "javax.swing.border;" +
- "javax.swing.colorchooser;" +
- "javax.swing.event;" +
- "javax.swing.filechooser;" +
- "javax.swing.plaf;" +
- "javax.swing.plaf.basic;" +
- "javax.swing.plaf.metal;" +
- "javax.swing.plaf.multi;" +
- "javax.swing.table;" +
- "javax.swing.text;" +
- "javax.swing.text.html;" +
- "javax.swing.text.html.parser;" +
- "javax.swing.text.rtf;" +
- "javax.swing.tree;" +
- "javax.swing.undo;" +
- "javax.transaction;" +
- "javax.transaction.xa;" +
- "javax.xml.parsers;" +
- "javax.xml.transform;" +
- "javax.xml.transform.dom;" +
- "javax.xml.transform.sax;" +
- "javax.xml.transform.stream;" +
- "org.apache.crimson.jaxp;" +
- "org.apache.crimson.parser;" +
- "org.apache.crimson.parser.resources;" +
- "org.apache.crimson.tree;" +
- "org.apache.crimson.tree.resources;" +
- "org.apache.crimson.util;" +
- "org.apache.xalan;" +
- "org.apache.xalan.client;" +
- "org.apache.xalan.extensions;" +
- "org.apache.xalan.lib;" +
- "org.apache.xalan.lib.sql;" +
- "org.apache.xalan.processor;" +
- "org.apache.xalan.res;" +
- "org.apache.xalan.serialize;" +
- "org.apache.xalan.templates;" +
- "org.apache.xalan.trace;" +
- "org.apache.xalan.transformer;" +
- "org.apache.xalan.xslt;" +
- "org.apache.xml.dtm;" +
- "org.apache.xml.dtm.ref;" +
- "org.apache.xml.dtm.ref.dom2dtm;" +
- "org.apache.xml.dtm.ref.sax2dtm;" +
- "org.apache.xml.utils;" +
- "org.apache.xml.utils.res;" +
- "org.apache.xml.utils.synthetic;" +
- "org.apache.xml.utils.synthetic.reflection;" +
- "org.apache.xpath;" +
- "org.apache.xpath.axes;" +
- "org.apache.xpath.compiler;" +
- "org.apache.xpath.functions;" +
- "org.apache.xpath.objects;" +
- "org.apache.xpath.operations;" +
- "org.apache.xpath.patterns;" +
- "org.apache.xpath.res;" +
- "org.ietf.jgss;" +
- "org.omg.CORBA;" +
- "org.omg.CORBA_2_3;" +
- "org.omg.CORBA_2_3.portable;" +
- "org.omg.CORBA.DynAnyPackage;" +
- "org.omg.CORBA.ORBPackage;" +
- "org.omg.CORBA.portable;" +
- "org.omg.CORBA.TypeCodePackage;" +
- "org.omg.CosNaming;" +
- "org.omg.CosNaming.NamingContextExtPackage;" +
- "org.omg.CosNaming.NamingContextPackage;" +
- "org.omg.Dynamic;" +
- "org.omg.DynamicAny;" +
- "org.omg.DynamicAny.DynAnyFactoryPackage;" +
- "org.omg.DynamicAny.DynAnyPackage;" +
- "org.omg.IOP;" +
- "org.omg.IOP.CodecFactoryPackage;" +
- "org.omg.IOP.CodecPackage;" +
- "org.omg.Messaging;" +
- "org.omg.PortableInterceptor;" +
- "org.omg.PortableInterceptor.ORBInitInfoPackage;" +
- "org.omg.PortableServer;" +
- "org.omg.PortableServer.CurrentPackage;" +
- "org.omg.PortableServer.POAManagerPackage;" +
- "org.omg.PortableServer.POAPackage;" +
- "org.omg.PortableServer.portable;" +
- "org.omg.PortableServer.ServantLocatorPackage;" +
- "org.omg.SendingContext;" +
- "org.omg.stub.java.rmi;" +
- "org.w3c.dom;" +
- "org.w3c.dom.css;" +
- "org.w3c.dom.events;" +
- "org.w3c.dom.html;" +
- "org.w3c.dom.stylesheets;" +
- "org.w3c.dom.traversal;" +
- "org.w3c.dom.views;" +
- "org.xml.sax;" +
- "org.xml.sax.ext;" +
- "org.xml.sax.helpers;" +
- "version=\"1.4.0\"";
-
- private static final String JRE_1_5_PACKAGES =
- "javax.accessibility;" +
- "javax.activity;" +
- "javax.imageio;" +
- "javax.imageio.event;" +
- "javax.imageio.metadata;" +
- "javax.imageio.plugins.bmp;" +
- "javax.imageio.plugins.jpeg;" +
- "javax.imageio.spi;" +
- "javax.imageio.stream;" +
- "javax.management;" +
- "javax.management.loading;" +
- "javax.management.modelmbean;" +
- "javax.management.monitor;" +
- "javax.management.openmbean;" +
- "javax.management.relation;" +
- "javax.management.remote;" +
- "javax.management.remote.rmi;" +
- "javax.management.timer;" +
- "javax.naming;" +
- "javax.naming.directory;" +
- "javax.naming.event;" +
- "javax.naming.ldap;" +
- "javax.naming.spi;" +
- "javax.print;" +
- "javax.print.attribute;" +
- "javax.print.attribute.standard;" +
- "javax.print.event;" +
- "javax.rmi;" +
- "javax.rmi.CORBA;" +
- "javax.rmi.ssl;" +
- "javax.security.auth;" +
- "javax.security.auth.callback;" +
- "javax.security.auth.kerberos;" +
- "javax.security.auth.login;" +
- "javax.security.auth.spi;" +
- "javax.security.auth.x500;" +
- "javax.security.sasl;" +
- "javax.sound.midi;" +
- "javax.sound.midi.spi;" +
- "javax.sound.sampled;" +
- "javax.sound.sampled.spi;" +
- "javax.sql;" +
- "javax.sql.rowset;" +
- "javax.sql.rowset.serial;" +
- "javax.sql.rowset.spi;" +
- "javax.swing;" +
- "javax.swing.border;" +
- "javax.swing.colorchooser;" +
- "javax.swing.event;" +
- "javax.swing.filechooser;" +
- "javax.swing.plaf;" +
- "javax.swing.plaf.basic;" +
- "javax.swing.plaf.metal;" +
- "javax.swing.plaf.multi;" +
- "javax.swing.plaf.synth;" +
- "javax.swing.table;" +
- "javax.swing.text;" +
- "javax.swing.text.html;" +
- "javax.swing.text.html.parser;" +
- "javax.swing.text.rtf;" +
- "javax.swing.tree;" +
- "javax.swing.undo;" +
- "javax.transaction;" +
- "javax.transaction.xa;" +
- "javax.xml;" +
- "javax.xml.datatype;" +
- "javax.xml.namespace;" +
- "javax.xml.parsers;" +
- "javax.xml.transform;" +
- "javax.xml.transform.dom;" +
- "javax.xml.transform.sax;" +
- "javax.xml.transform.stream;" +
- "javax.xml.validation;" +
- "javax.xml.xpath;" +
- "org.ietf.jgss;" +
- "org.omg.CORBA;" +
- "org.omg.CORBA_2_3;" +
- "org.omg.CORBA_2_3.portable;" +
- "org.omg.CORBA.DynAnyPackage;" +
- "org.omg.CORBA.ORBPackage;" +
- "org.omg.CORBA.portable;" +
- "org.omg.CORBA.TypeCodePackage;" +
- "org.omg.CosNaming;" +
- "org.omg.CosNaming.NamingContextExtPackage;" +
- "org.omg.CosNaming.NamingContextPackage;" +
- "org.omg.Dynamic;" +
- "org.omg.DynamicAny;" +
- "org.omg.DynamicAny.DynAnyFactoryPackage;" +
- "org.omg.DynamicAny.DynAnyPackage;" +
- "org.omg.IOP;" +
- "org.omg.IOP.CodecFactoryPackage;" +
- "org.omg.IOP.CodecPackage;" +
- "org.omg.Messaging;" +
- "org.omg.PortableInterceptor;" +
- "org.omg.PortableInterceptor.ORBInitInfoPackage;" +
- "org.omg.PortableServer;" +
- "org.omg.PortableServer.CurrentPackage;" +
- "org.omg.PortableServer.POAManagerPackage;" +
- "org.omg.PortableServer.POAPackage;" +
- "org.omg.PortableServer.portable;" +
- "org.omg.PortableServer.ServantLocatorPackage;" +
- "org.omg.SendingContext;" +
- "org.omg.stub.java.rmi;" +
- "org.omg.stub.javax.management.remote.rmi;" +
- "org.w3c.dom;" +
- "org.w3c.dom.bootstrap;" +
- "org.w3c.dom.css;" +
- "org.w3c.dom.events;" +
- "org.w3c.dom.html;" +
- "org.w3c.dom.ls;" +
- "org.w3c.dom.ranges;" +
- "org.w3c.dom.stylesheets;" +
- "org.w3c.dom.traversal;" +
- "org.w3c.dom.views;" +
- "org.xml.sax;" +
- "org.xml.sax.ext;" +
- "org.xml.sax.helpers;" +
- "version=\"1.5.0\"";
-
- private static final String JRE_1_6_PACKAGES =
- "java.applet;" +
- "java.awt;" +
- "java.awt.color;" +
- "java.awt.datatransfer;" +
- "java.awt.dnd;" +
- "java.awt.dnd.peer;" +
- "java.awt.event;" +
- "java.awt.font;" +
- "java.awt.geom;" +
- "java.awt.im;" +
- "java.awt.image;" +
- "java.awt.image.renderable;" +
- "java.awt.im.spi;" +
- "java.awt.peer;" +
- "java.awt.print;" +
- "java.beans;" +
- "java.beans.beancontext;" +
- "java.io;" +
- "java.lang;" +
- "java.lang.annotation;" +
- "java.lang.instrument;" +
- "java.lang.management;" +
- "java.lang.ref;" +
- "java.lang.reflect;" +
- "java.math;" +
- "java.net;" +
- "java.nio;" +
- "java.nio.channels;" +
- "java.nio.channels.spi;" +
- "java.nio.charset;" +
- "java.nio.charset.spi;" +
- "java.rmi;" +
- "java.rmi.activation;" +
- "java.rmi.dgc;" +
- "java.rmi.registry;" +
- "java.rmi.server;" +
- "java.security;" +
- "java.security.acl;" +
- "java.security.cert;" +
- "java.security.interfaces;" +
- "java.security.spec;" +
- "java.sql;" +
- "java.text;" +
- "java.text.spi;" +
- "java.util;" +
- "java.util.concurrent;" +
- "java.util.concurrent.atomic;" +
- "java.util.concurrent.locks;" +
- "java.util.jar;" +
- "java.util.logging;" +
- "java.util.prefs;" +
- "java.util.regex;" +
- "java.util.spi;" +
- "java.util.zip;" +
- "javax.accessibility;" +
- "javax.activation;" +
- "javax.activity;" +
- "javax.annotation;" +
- "javax.annotation.processing;" +
- "javax.imageio;" +
- "javax.imageio.event;" +
- "javax.imageio.metadata;" +
- "javax.imageio.plugins.bmp;" +
- "javax.imageio.plugins.jpeg;" +
- "javax.imageio.spi;" +
- "javax.imageio.stream;" +
- "javax.jws;" +
- "javax.jws.soap;" +
- "javax.lang.model;" +
- "javax.lang.model.element;" +
- "javax.lang.model.type;" +
- "javax.lang.model.util;" +
- "javax.management;" +
- "javax.management.loading;" +
- "javax.management.modelmbean;" +
- "javax.management.monitor;" +
- "javax.management.openmbean;" +
- "javax.management.relation;" +
- "javax.management.remote;" +
- "javax.management.remote.rmi;" +
- "javax.management.timer;" +
- "javax.naming;" +
- "javax.naming.directory;" +
- "javax.naming.event;" +
- "javax.naming.ldap;" +
- "javax.naming.spi;" +
- "javax.print;" +
- "javax.print.attribute;" +
- "javax.print.attribute.standard;" +
- "javax.print.event;" +
- "javax.rmi;" +
- "javax.rmi.CORBA;" +
- "javax.rmi.ssl;" +
- "javax.script;" +
- "javax.security.auth;" +
- "javax.security.auth.callback;" +
- "javax.security.auth.kerberos;" +
- "javax.security.auth.login;" +
- "javax.security.auth.spi;" +
- "javax.security.auth.x500;" +
- "javax.security.sasl;" +
- "javax.smartcardio;" +
- "javax.sound.midi;" +
- "javax.sound.midi.spi;" +
- "javax.sound.sampled;" +
- "javax.sound.sampled.spi;" +
- "javax.sql;" +
- "javax.sql.rowset;" +
- "javax.sql.rowset.serial;" +
- "javax.sql.rowset.spi;" +
- "javax.swing;" +
- "javax.swing.border;" +
- "javax.swing.colorchooser;" +
- "javax.swing.event;" +
- "javax.swing.filechooser;" +
- "javax.swing.plaf;" +
- "javax.swing.plaf.basic;" +
- "javax.swing.plaf.metal;" +
- "javax.swing.plaf.multi;" +
- "javax.swing.plaf.synth;" +
- "javax.swing.table;" +
- "javax.swing.text;" +
- "javax.swing.text.html;" +
- "javax.swing.text.html.parser;" +
- "javax.swing.text.rtf;" +
- "javax.swing.tree;" +
- "javax.swing.undo;" +
- "javax.tools;" +
- "javax.transaction;" +
- "javax.transaction.xa;" +
- "javax.xml;" +
- "javax.xml.bind;" +
- "javax.xml.bind.annotation;" +
- "javax.xml.bind.annotation.adapters;" +
- "javax.xml.bind.attachment;" +
- "javax.xml.bind.helpers;" +
- "javax.xml.bind.util;" +
- "javax.xml.crypto;" +
- "javax.xml.crypto.dom;" +
- "javax.xml.crypto.dsig;" +
- "javax.xml.crypto.dsig.dom;" +
- "javax.xml.crypto.dsig.keyinfo;" +
- "javax.xml.crypto.dsig.spec;" +
- "javax.xml.datatype;" +
- "javax.xml.namespace;" +
- "javax.xml.parsers;" +
- "javax.xml.soap;" +
- "javax.xml.stream;" +
- "javax.xml.stream.events;" +
- "javax.xml.stream.util;" +
- "javax.xml.transform;" +
- "javax.xml.transform.dom;" +
- "javax.xml.transform.sax;" +
- "javax.xml.transform.stax;" +
- "javax.xml.transform.stream;" +
- "javax.xml.validation;" +
- "javax.xml.ws;" +
- "javax.xml.ws.handler;" +
- "javax.xml.ws.handler.soap;" +
- "javax.xml.ws.http;" +
- "javax.xml.ws.soap;" +
- "javax.xml.ws.spi;" +
- "javax.xml.xpath;" +
- "org.ietf.jgss;" +
- "org.jcp.xml.dsig.internal;" +
- "org.jcp.xml.dsig.internal.dom;" +
- "org.omg.CORBA;" +
- "org.omg.CORBA_2_3;" +
- "org.omg.CORBA_2_3.portable;" +
- "org.omg.CORBA.DynAnyPackage;" +
- "org.omg.CORBA.ORBPackage;" +
- "org.omg.CORBA.portable;" +
- "org.omg.CORBA.TypeCodePackage;" +
- "org.omg.CosNaming;" +
- "org.omg.CosNaming.NamingContextExtPackage;" +
- "org.omg.CosNaming.NamingContextPackage;" +
- "org.omg.Dynamic;" +
- "org.omg.DynamicAny;" +
- "org.omg.DynamicAny.DynAnyFactoryPackage;" +
- "org.omg.DynamicAny.DynAnyPackage;" +
- "org.omg.IOP;" +
- "org.omg.IOP.CodecFactoryPackage;" +
- "org.omg.IOP.CodecPackage;" +
- "org.omg.Messaging;" +
- "org.omg.PortableInterceptor;" +
- "org.omg.PortableInterceptor.ORBInitInfoPackage;" +
- "org.omg.PortableServer;" +
- "org.omg.PortableServer.CurrentPackage;" +
- "org.omg.PortableServer.POAManagerPackage;" +
- "org.omg.PortableServer.POAPackage;" +
- "org.omg.PortableServer.portable;" +
- "org.omg.PortableServer.ServantLocatorPackage;" +
- "org.omg.SendingContext;" +
- "org.omg.stub.java.rmi;" +
- "org.omg.stub.javax.management.remote.rmi;" +
- "org.w3c.dom;" +
- "org.w3c.dom.bootstrap;" +
- "org.w3c.dom.css;" +
- "org.w3c.dom.events;" +
- "org.w3c.dom.html;" +
- "org.w3c.dom.ls;" +
- "org.w3c.dom.ranges;" +
- "org.w3c.dom.stylesheets;" +
- "org.w3c.dom.traversal;" +
- "org.w3c.dom.views;" +
- "org.w3c.dom.xpath;" +
- "org.xml.sax;" +
- "org.xml.sax.ext;" +
- "org.xml.sax.helpers;" +
- "version=\"1.6.0\"";
-
- /**
- * The name of the felix cache profile.
- *
- * @parameter expression=”${run.felix.cache.profile}” default-value="test"
- * @description the felix.cache.profile property value
- */
- private String felixCacheProfile;
-
- /**
- * The location of the felix bundle cache directory.
- *
- * @parameter expression=”${run.felix.cache.dir}” default-value="${basedir}/target/.felix"
- * @description the felix.cache.dir property value
- */
- private File felixCacheDir;
-
- /**
- * The location of the test bundle.
- *
- * @parameter expression="${run.felix.test.bundle}"
- * default-value="${basedir}/target/${project.artifactId}-${project.version}.jar"
- */
- private File felixTestBundle;
-
- /**
- * @parameter default-value="${project}"
- */
- private MavenProject project;
-
- /**
- * @parameter
- */
- private List exclusions;
-
- /**
- * The felix container used to run the integration tests.
- */
- private Felix felixContainer;
-
-
- public void execute() throws MojoExecutionException, MojoFailureException
- {
- // -------------------------------------------------------------------
- // Clean out the old cache directory if it exists
- // -------------------------------------------------------------------
-
- if ( felixCacheDir.exists() )
- {
- try
- {
- FileUtils.forceDelete( felixCacheDir );
- }
- catch ( IOException e )
- {
- throw new MojoFailureException( "failed to delete old Felix cache directory: "
- + felixCacheDir.getAbsolutePath() );
- }
- }
-
- // -------------------------------------------------------------------
- // Build the properties we will stuff into the resolver
- // -------------------------------------------------------------------
-
- Properties props = new Properties();
- props.put( "felix.cache.dir", felixCacheDir.getAbsolutePath() );
- props.put( "felix.cache.profile", felixCacheProfile );
- props.put( "felix.embedded.execution", "true" );
-
- StringBuffer buf = new StringBuffer();
- buf.append( "org.osgi.framework; version=1.3.0, " );
- buf.append( "org.osgi.service.packageadmin; version=1.2.0, " );
- buf.append( "org.osgi.service.startlevel; version=1.0.0, " );
- buf.append( "org.osgi.service.url; version=1.0.0, " );
-
- String version = System.getProperty( "java.version" );
- if ( version.indexOf( "1.3" ) != -1 )
- {
- buf.append( JRE_1_3_PACKAGES );
- }
- else if ( version.indexOf( "1.4" ) != -1 )
- {
- buf.append( JRE_1_4_PACKAGES );
- }
- else if ( version.indexOf( "1.5" ) != -1 )
- {
- buf.append( JRE_1_5_PACKAGES );
- }
- else if ( version.indexOf( "1.6" ) != -1 )
- {
- buf.append( JRE_1_6_PACKAGES );
- }
- else
- {
- throw new IllegalStateException( "java.version = " + version + " is not recognized" );
- }
-
- props.put( "org.osgi.framework.system.packages", buf.toString() );
- try
- {
- props.put( "felix.auto.start.1", getAutoStart() );
- }
- catch ( MalformedURLException e )
- {
- e.printStackTrace();
- }
-
- // -------------------------------------------------------------------
- // Start up Felix with resolver and shut it down
- // -------------------------------------------------------------------
-
- felixContainer = new Felix(new StringMap(props, false), null);
- try
- {
- felixContainer.start();
- }
- catch (Exception ex)
- {
- // TODO: find out what to do.
- }
- getLog().info( "-=============================-" );
- getLog().info( "| Felix: successfully started |" );
- getLog().info( "-=============================-" );
- try
- {
- felixContainer.stop();
- }
- catch (Exception ex)
- {
- // TODO: find out what to do.
- }
- getLog().info( "-==============================-" );
- getLog().info( "| Felix: successfully shutdown |" );
- getLog().info( "-==============================-" );
- }
-
-
- public String getAutoStart() throws MalformedURLException
- {
- List included = new ArrayList();
- List excluded = new ArrayList();
- if ( exclusions == null )
- {
- exclusions = Collections.EMPTY_LIST;
- }
-
- StringBuffer buf = new StringBuffer();
- StringBuffer keyBuf = new StringBuffer();
- for ( Iterator ii = project.getDependencyArtifacts().iterator(); ii.hasNext(); /**/)
- {
- Artifact dep = ( Artifact ) ii.next();
- keyBuf.setLength( 0 );
- keyBuf.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() );
- String depKey = keyBuf.toString();
-
- // -------------------------------------------------------------------
- // Add only provided dependent artifacts that have not been excluded
- // -------------------------------------------------------------------
-
- if ( dep.getScope().equalsIgnoreCase( "provided" ) )
- {
- if ( dep.getArtifactId().equalsIgnoreCase( "org.osgi.core" ) ||
- exclusions.contains( depKey ) )
- {
- excluded.add( depKey );
- continue;
- }
-
- included.add( depKey );
- buf.append( dep.getFile().toURL() );
- buf.append( " " );
- }
- }
-
- keyBuf.setLength( 0 );
- keyBuf.append( project.getGroupId() ).append( ":" ).append( project.getArtifactId() );
- String depKey = keyBuf.toString();
- included.add( depKey );
- buf.append( felixTestBundle.toURL() );
-
- // -------------------------------------------------------------------
- // Report what was included and what was excluded
- // -------------------------------------------------------------------
-
- getLog().info( "" );
- getLog().info( "\t\tJars/Bundles Included for Autostart" );
- getLog().info( "\t\t-----------------------------------" );
- getLog().info( "" );
- for ( Iterator ii = included.iterator(); ii.hasNext(); /**/ )
- {
- getLog().info( "\t\t" + ( String ) ii.next() );
- }
- getLog().info( "" );
- getLog().info( "" );
- getLog().info( "\t\tJars/Bundles Excluded from Autostart" );
- getLog().info( "\t\t------------------------------------" );
- getLog().info( "" );
- for ( Iterator ii = excluded.iterator(); ii.hasNext(); /**/ )
- {
- getLog().info( "\t\t" + ( String ) ii.next() );
- }
- getLog().info( "" );
- getLog().info( "" );
- return buf.toString();
- }
-}
diff --git a/tools/maven2/maven-osgi-plugin/README.txt b/tools/maven2/maven-osgi-plugin/README.txt
deleted file mode 100644
index ceb86d0..0000000
--- a/tools/maven2/maven-osgi-plugin/README.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-For the latest information about installing, running, and configuring the Felix
-OSGi Plugin for Maven 2.0, please refer to:
-
-http://docs.safehaus.org/display/OSGI/OSGi+Plugin+for+Maven+2.0
-
-For tracking and submitting development or documentation issues, please refer
-to:
-
-http://issues.apache.org/jira/browse/FELIXM2
-
-NOTE: This plugin is only for Maven 2. It will not work with Maven 1.x
-versions.
diff --git a/tools/maven2/maven-osgi-plugin/pom.xml b/tools/maven2/maven-osgi-plugin/pom.xml
deleted file mode 100644
index d45dd2d..0000000
--- a/tools/maven2/maven-osgi-plugin/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<project>
- <parent>
- <artifactId>felix</artifactId>
- <groupId>org.apache.felix</groupId>
- <version>1.0.4</version>
- <relativePath>../../../pom/pom.xml</relativePath>
- </parent>
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix.plugins</groupId>
- <artifactId>maven-osgi-plugin</artifactId>
- <version>0.9.0-SNAPSHOT</version>
- <packaging>maven-plugin</packaging>
- <name>Maven OSGi Plugin</name>
-
- <repositories>
- <!-- For snapshots (no release jars or non-apache jars) -->
- <repository>
- <id>apache.snapshots</id>
- <name>Apache Snapshot Repository</name>
- <url>http://people.apache.org/repo/m2-snapshot-repository</url>
- </repository>
- </repositories>
-
-<!--
- <pluginRepositories>
- <pluginRepository>
- <id>snapshots</id>
- <name>snapshot plugins</name>
- <url>http://snapshots.maven.codehaus.org/maven2</url>
- </pluginRepository>
- <pluginRepository>
- <id>apache.snapshots</id>
- <name>Apache Snapshot Plugins</name>
- <url>http://people.apache.org/repo/m2-snapshot-repository</url>
- </pluginRepository>
- </pluginRepositories>
--->
-
- <distributionManagement>
- <snapshotRepository>
- <id>apache.snapshots</id>
- <url>
- scp://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository
- </url>
- </snapshotRepository>
- <repository>
- <name>ASF Mirrored M2 Distributions</name>
- <id>apache.snapshots</id>
- <url>
- scp://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository
- </url>
- </repository>
-
- </distributionManagement>
-
- <dependencies>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-plugin-api</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-archiver</artifactId>
- <version>2.2</version>
- </dependency>
- <dependency>
- <groupId>org.codehaus.plexus</groupId>
- <artifactId>plexus-utils</artifactId>
- <version>1.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0</version>
- </dependency>
- </dependencies>
-</project>
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Clazz.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Clazz.java
deleted file mode 100644
index cb02713..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Clazz.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.tools.maven.plugin;
-
-import java.io.*;
-import java.util.*;
-
-public class Clazz {
- static byte SkipTable[] = {0, // 0 non existent
- -1, // 1 CONSTANT_utf8 UTF 8, handled in
- // method
- -1, // 2
- 4, // 3 CONSTANT_Integer
- 4, // 4 CONSTANT_Float
- 8, // 5 CONSTANT_Long (index +=2!)
- 8, // 6 CONSTANT_Double (index +=2!)
- -1, // 7 CONSTANT_Class
- 2, // 8 CONSTANT_String
- 4, // 9 CONSTANT_FieldRef
- 4, // 10 CONSTANT_MethodRef
- 4, // 11 CONSTANT_InterfaceMethodRef
- 4, // 12 CONSTANT_NameAndType
- };
-
- Set imports = new HashSet();
- String path;
- Jar jar;
-
- public Clazz(Jar jar, String path, InputStream in) throws IOException {
- this.path = path;
- this.jar = jar;
- DataInputStream din = new DataInputStream(in);
- parseClassFile(din);
- }
-
-
- void parseClassFile(DataInputStream in)
- throws IOException {
- Set classes = new HashSet();
- Set descriptors = new HashSet();
- Hashtable pool = new Hashtable();
- try {
- int magic = in.readInt();
- if (magic != 0xCAFEBABE)
- throw new IOException(
- "Not a valid class file (no CAFEBABE header)");
- in.readShort(); // minor version
- in.readShort(); // major version
- int count = in.readUnsignedShort();
- process: for (int i = 1; i < count; i++) {
- byte tag = in.readByte();
- switch (tag) {
- case 0 :
- break process;
- case 1 :
- // CONSTANT_Utf8
- String name = in.readUTF();
- pool.put(new Integer(i), name);
- break;
- // A Class constant is just a short reference in
- // the constant pool
- case 7 :
- // CONSTANT_Class
- Integer index = new Integer(in.readShort());
- classes.add(index);
- break;
- // For some insane optimization reason are
- // the long and the double two entries in the
- // constant pool. See 4.4.5
- case 5 :
- // CONSTANT_Long
- case 6 :
- // CONSTANT_Double
- in.skipBytes(8);
- i++;
- break;
-
- // Interface Method Ref
- case 12 :
- in.readShort(); // Name index
- int descriptorIndex = in.readShort();
- descriptors.add(new Integer(descriptorIndex));
- break;
-
- // We get the skip count for each record type
- // from the SkipTable. This will also automatically
- // abort when
- default :
- if (tag == 2)
- throw new IOException("Invalid tag " + tag);
- in.skipBytes(SkipTable[tag]);
- break;
- }
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- return;
- }
- //
- // Now iterate over all classes we found and
- // parse those as well. We skip duplicates
- //
-
- for (Iterator e = classes.iterator(); e.hasNext();) {
- Integer n = (Integer) e.next();
- String next = (String) pool.get(n);
- if (next != null) {
- String normalized = normalize(next);
- if (normalized != null) {
- // For purposes of trying to guess the activator class, we assume
- // that any class that references the BundleActivator interface
- // must be a BundleActivator implementation.
- if ( normalized.startsWith("org/osgi/framework/BundleActivator")) {
- String cname = path.replace('/', '.');
- cname = cname.substring(0,cname.length()-".class" .length());
- jar.addActivator(cname);
- }
- String pack = getPackage(normalized);
- if (!pack.startsWith("java."))
- imports.add(pack);
- }
- }
- else
- throw new IllegalArgumentException("Invalid class, parent=");
- }
- for (Iterator e = descriptors.iterator(); e.hasNext();) {
- Integer n = (Integer) e.next();
- String prototype = (String) pool.get(n);
- if (prototype != null)
- parseDescriptor(prototype);
- }
- }
-
- void parseDescriptor(String prototype) {
- addReference(prototype);
- StringTokenizer st = new StringTokenizer(prototype, "(;)", true);
- while (st.hasMoreTokens()) {
- if (st.nextToken().equals("(")) {
- String token = st.nextToken();
- while (!token.equals(")")) {
- addReference(token);
- token = st.nextToken();
- }
- token = st.nextToken();
- addReference(token);
- }
- }
- }
-
- private void addReference(String token) {
- if (token.startsWith("L")) {
- String clazz = normalize(token.substring(1));
- if (clazz.startsWith("java/"))
- return;
- String pack = getPackage(clazz);
- imports.add(pack);
- }
- }
-
- static String normalize(String s) {
- if (s.startsWith("[L"))
- return normalize(s.substring(2));
- if (s.startsWith("["))
- if (s.length() == 2)
- return null;
- else
- return normalize(s.substring(1));
- if (s.endsWith(";"))
- return normalize(s.substring(0, s.length() - 1));
- return s + ".class";
- }
-
- static String getPackage(String clazz) {
- int n = clazz.lastIndexOf('/');
- if (n < 0)
- return ".";
- return clazz.substring(0, n).replace('/', '.');
- }
-
-
- public Collection getReferred() {
- return imports;
- }
-
-
- public Object getPath() {
- return path;
- }
-
-
-}
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Jar.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Jar.java
deleted file mode 100644
index 214815e..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/Jar.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.tools.maven.plugin;
-
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import java.util.zip.*;
-
-public class Jar {
- Map resources = new TreeMap();
- Map imports = new HashMap();
- Map exports = new HashMap();
- Manifest manifest;
- boolean manifestFirst;
- String name;
- Jar parent;
- List activators = new ArrayList();
-
- public Jar(Jar parent, String name, InputStream in) throws IOException {
- this.name = name;
- this.parent = parent;
- ZipInputStream jar = new ZipInputStream(in);
- ZipEntry entry = jar.getNextEntry();
- boolean first = true;
- while (entry != null) {
- String path = entry.getName();
-
- if (path.endsWith(".class")) {
- Clazz clazz = new Clazz(this, path, jar);
- resources.put(path, clazz);
- }
- else if (path.endsWith(".jar")) {
- Jar pool = new Jar(this, path, jar);
- resources.put(path, pool);
- }
- else if (path.endsWith("/packageinfo")
- && !path.startsWith("OSGI-OPT")) {
- String version = parsePackageInfo(jar, exports);
- resources.put(path, version);
- }
- else if (path.equals("META-INF/MANIFEST.MF")) {
- manifestFirst = first;
- manifest = new Manifest(jar);
- }
- else
- resources.put(path, null);
-
- entry = jar.getNextEntry();
- if (!path.endsWith("/"))
- first = false;
- }
- }
-
- public Jar(Jar parent, String name, File rootDir) throws IOException {
- this.name = name;
- this.parent = parent;
- traverse(rootDir.getAbsolutePath().length(), rootDir, rootDir.list());
- }
-
- void traverse(int root, File dir, String list[]) throws IOException {
- for (int i = 0; i < list.length; i++) {
- File sub = new File(dir, list[i]);
- if (sub.isDirectory())
- traverse(root, sub, sub.list());
- else {
- String path = sub.getAbsolutePath().substring(root + 1)
- .replace(File.separatorChar, '/');
- FileInputStream in = new FileInputStream(sub);
-
- if (path.endsWith(".class")) {
- Clazz clazz = new Clazz(this, path, in);
- resources.put(path, clazz);
- }
- else if (path.endsWith(".jar")) {
- Jar pool = new Jar(this, path, in);
- resources.put(path, pool);
- }
- else if (path.endsWith("/packageinfo")
- && !path.startsWith("OSGI-OPT")) {
- String version = parsePackageInfo(in, exports);
- resources.put(path, version);
- }
- else if (path.endsWith("META-INF/MANIFEST.MF")) {
- manifest = new Manifest(in);
- }
- else
- resources.put(path, null);
- }
- }
- }
-
- private static String parsePackageInfo(InputStream jar, Map exports)
- throws IOException {
- try {
- byte[] buf = collect(jar, 0);
- String line = new String(buf);
- StringTokenizer qt = new StringTokenizer(line, " \r\n\t");
- if (qt.hasMoreElements()) {
- qt.nextToken();
- if (qt.hasMoreElements()) {
- String version = qt.nextToken();
- return version;
- }
- }
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- return null;
- }
-
- /**
- * Convenience method to turn an inputstream into a byte array. The method
- * uses a recursive algorithm to minimize memory usage.
- *
- * @param in stream with data
- * @param offset where we are in the stream
- * @returns byte array filled with data
- */
- private static byte[] collect(InputStream in, int offset)
- throws IOException {
- byte[] result;
- byte[] buffer = new byte[10000];
- int size = in.read(buffer);
- if (size <= 0)
- return new byte[offset];
- else
- result = collect(in, offset + size);
- System.arraycopy(buffer, 0, result, offset, size);
- return result;
- }
-
- public Manifest getManifest() {
- return manifest;
- }
-
- public Object getEntry(String resource) {
- return resources.get(resource);
- }
-
- public boolean exists(String jarOrDir) {
- return resources.keySet().contains(jarOrDir);
- }
-
- public Set getEntryPaths(String prefix) {
- Set result = new TreeSet();
- for (Iterator i = resources.keySet().iterator(); i.hasNext();) {
- String path = (String) i.next();
- if (path.startsWith(prefix))
- result.add(path);
- }
- return result;
- }
-
- String getName() {
- return name;
- }
-
- public String toString() {
- return getName();
- }
-
- public void addActivator(String path) {
- if (parent != null)
- parent.addActivator(path);
- else {
- activators.add(path);
- }
-
- }
-
- public boolean containsActivator(String path) {
- if (parent != null)
- return parent.containsActivator(path);
- return activators.contains(path);
- }
-}
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
deleted file mode 100644
index 5f43b89..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiJarMojo.java
+++ /dev/null
@@ -1,866 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.tools.maven.plugin;
-
-import java.io.*;
-import java.util.*;
-import java.util.zip.ZipFile;
-import java.util.zip.ZipEntry;
-
-import org.apache.maven.archiver.*;
-import org.apache.maven.artifact.*;
-import org.apache.maven.plugin.*;
-import org.apache.maven.project.MavenProject;
-import org.codehaus.plexus.archiver.ArchiverException;
-import org.codehaus.plexus.archiver.jar.*;
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Package an OSGi jar "bundle."
- *
- * @author <a href="mailto:dev@felix.apache.org">Apache Felix Project</a>
- * @version $Rev$, $Date$
- * @goal osgi-bundle
- * @phase package
- * @requiresDependencyResolution runtime
- * @description build an OSGi bundle jar
- */
-public class OsgiJarMojo extends AbstractMojo {
- private static final java.util.regex.Pattern versionPattern =
- java.util.regex.Pattern.compile("^(\\d+(\\.\\d+(\\.\\d+)?)?)-");
- private static final String[] versionCompleters =
- new String[] { ".0.0", ".0" };
-
- public static final String OSGI_REFERENCES = "osgi.references";
- public static final String AUTO_DETECT = "auto-detect";
-
- private static final String[] EMPTY_STRING_ARRAY = {};
-
- int bundleManifestVersion = 1;
-
- /**
- * Jars to Inline
- *
- * @parameter
- */
- private List inlinedArtifacts = new ArrayList();
-
- /**
- * Packages to ignore when generating import-package header.
- *
- * @parameter
- */
- private String ignorePackage;
-
- /**
- * The Maven project.
- *
- * @parameter expression="${project}"
- * @required
- * @readonly
- */
- private MavenProject project;
-
- /**
- * The directory for the generated JAR.
- *
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private String buildDirectory;
-
- /**
- * The directory containing generated classes.
- *
- * @parameter expression="${project.build.outputDirectory}"
- * @required
- * @readonly
- */
- private File outputDirectory;
-
- /**
- * The name of the generated JAR file.
- *
- * @parameter alias="jarName" expression="${project.build.finalName}"
- * @required
- */
- private String jarName;
-
- /**
- * The Jar archiver.
- *
- * @parameter expression="${component.org.codehaus.plexus.archiver.Archiver#jar}"
- * @required
- */
- private JarArchiver jarArchiver;
-
- /**
- * The maven archive configuration to use.
- * @parameter
- */
- private MavenArchiveConfiguration archive = new MavenArchiveConfiguration();
-
- /**
- * The comma separated list of tokens to include in the JAR. Default is
- * '**'.
- *
- * @parameter alias="includes"
- */
- private String jarSourceIncludes = "**";
-
- /**
- * The comma separated list of tokens to exclude from the JAR.
- *
- * @parameter alias="excludes"
- */
- private String jarSourceExcludes;
-
- /**
- * @parameter
- */
- private String manifestFile;
-
- /**
- * @parameter expression="${org.apache.felix.tools.maven.plugin.OsgiManifest}"
- */
- private OsgiManifest osgiManifest;
-
- /**
- * Execute this Mojo
- *
- * @throws MojoExecutionException
- */
- public void execute() throws MojoExecutionException {
- File jarFile = new File(buildDirectory, jarName + ".jar");
-
- try {
- performPackaging(jarFile);
- }
- catch (Exception e) {
- throw new MojoExecutionException("Error assembling JAR bundle", e);
- }
- }
-
- /**
- * Generates the JAR bundle file.
- *
- * @param jarFile the target JAR file
- * @throws IOException
- * @throws ArchiverException
- * @throws ManifestException
- * @throws DependencyResolutionRequiredException
- */
- private void performPackaging(File jarFile) throws IOException,
- ArchiverException, ManifestException,
- DependencyResolutionRequiredException, MojoExecutionException {
-
- outputDirectory.mkdirs();
-
- verifyDeclaredBundleManifestVersion();
-
- getLog().info("Generating JAR bundle " + jarFile.getAbsolutePath());
-
- MavenArchiver archiver = new MavenArchiver();
-
- archiver.setArchiver(jarArchiver);
- archiver.setOutputFile(jarFile);
-
- addManifestFile();
- addManifestEntries();
-
- // Inline the contents of the indicated jar artifacts
- inlineArtifacts();
-
- // Add the JARs that were specified in the POM
- // as "not" provided and which are not inlined
- addEmbeddedJars();
-
- jarArchiver.addDirectory(outputDirectory, getIncludes(), getExcludes());
-
- // Parse the output directory as if it was a JAR file.
- // This creates special entries for classes, packageinfo
- // and embedded JAR files (which are parsed as well).
- Jar mainJar = new Jar(null, jarName, outputDirectory);
-
- // Calculate the Bundle Classpath from the embedded
- // JAR files. We hardcode the bcp as ., <embedded jars>
- // TODO we add all the found JARs to the Bcp, maybe we
- // should look if they are needed by traversing the imports.
- List bundleClassPath = getBundleClassPath(mainJar);
- bundleClassPath.add(0, ".");
- createBundleClasspathHeader(bundleClassPath);
-
- // Calculate the exports (contained) and imports (referred)
- // The bundleClassPath contains the JARs in the right order
- Set contained = new HashSet(); // package name
- Set referred = new HashSet(); // package name
- Map uses = new HashMap(); // package name => Set of package name
-
- // Iterate over the bundle class path and calculate the contained
- // and referred packages as well as the uses.
- for (Iterator i = bundleClassPath.iterator(); i.hasNext();) {
- String path = (String) i.next();
- Jar jar = path.equals(".") ? mainJar : (Jar) mainJar.resources
- .get(path);
- analyzeJar(jar, contained, referred, uses);
- }
-
- referred.removeAll(contained);
-
- // Check if the osgi.references property is set and display result
- // if necessary.
- checkReferencesProperty(uses);
-
- // Dump referenced package information if debug logging is enabled.
- if (getLog().isDebugEnabled()) {
- printReferencedPackages(uses);
- }
-
- Map exports = parseHeader(osgiManifest.getExportPackage());
- Map imports = parseHeader(osgiManifest.getImportPackage());
- Map explicitImports = parseHeader(osgiManifest.getExplicitImportPackage());
- Map dynamicImports = parseHeader(osgiManifest.getDynamicImportPackage());
-
- if (dynamicImports != null) {
- // Remove any dynamic imports from the referred set.
- referred = new HashSet(referred);
- referred.removeAll(dynamicImports.keySet());
- }
-
- if (exports != null) {
- verifyDeclaredExports(exports, contained);
- createExportHeader(exports, uses);
- }
-
- // Remove any ignored packages from the referred set.
- Set ignorePackageSet = parseIgnorePackage();
- referred.removeAll(ignorePackageSet);
-
- if (explicitImports != null) {
- referred.addAll(explicitImports.keySet());
- }
-
- // If the POM file contains an import declaration,
- // we verify its validity. Otherwise, we generate the
- // import package header from the referred. Exports
- // are added to automatically imports for R4 bundles.
- if (imports == null) {
- createImportHeader(referred, exports == null ? new HashSet()
- : exports.keySet());
- }
- else {
- verifyDeclaredImports(referred, imports);
- }
-
- verifyBundleActivator(mainJar);
-
- archiver.createArchive(project, archive);
- project.getArtifact().setFile(jarFile);
- }
-
- private void verifyBundleActivator(Jar mainJar) {
- String ba = osgiManifest.getBundleActivator();
- if ((ba != null) && ba.equals(AUTO_DETECT)) {
- switch ( mainJar.activators.size() ) {
- case 0:
- break;
- case 1:
- archive.addManifestEntry("Bundle-Activator", mainJar.activators.get(0));
- break;
- default:
- getLog().info("[OSGi] Multiple activators found, unable to auto-detect." );
- break;
- }
- }
- else if (ba != null) {
- if (!mainJar.activators.contains(ba))
- getLog().warn("[OSGi] UNABLE TO VERIFY BUNDLE ACTIVATOR: " + ba);
- }
- }
-
- private void createBundleClasspathHeader(List bundleClassPath) {
- StringBuffer sb = new StringBuffer();
- for (Iterator i = bundleClassPath.iterator(); i.hasNext(); ) {
- sb.append(i.next());
- if (i.hasNext()) {
- sb.append(",");
- }
- }
- if (sb.length() > 0)
- archive.addManifestEntry("Bundle-Classpath", sb.toString());
- }
-
- /**
- * Iterate over the declared exports from the POM, verify that they are
- * present, add the uses clause if necessary and finally add the manifest
- * entry.
- *
- * @param contained Set of contained packages
- * @param exports Map with the export clauses from the POM
- * @throws MojoExecutionException
- */
- void verifyDeclaredExports(Map exports, Set contained)
- throws MojoExecutionException {
- Set declaredExports = exports.keySet();
- for (Iterator i = declaredExports.iterator(); i.hasNext();) {
- String pack = (String) i.next();
- if (!contained.contains(pack)) {
- getLog()
- .error("[OSGi] EXPORTED PACKAGE NOT IN BUNDLE: " + pack);
- throw new MojoExecutionException(
- "Exported Package not found in bundle or JARs on bundle class path "
- + pack);
- }
-
- }
- }
-
- /**
- * Print out the export headers after adding the uses clause.
- *
- * @param exports
- * @param uses
- * @throws MojoExecutionException
- */
- void createExportHeader(Map exports, Map uses)
- throws MojoExecutionException {
- if (exports.size() > 0) {
- Set declaredExports = exports.keySet();
- for (Iterator i = declaredExports.iterator(); i.hasNext();) {
- String pack = (String) i.next();
- Map clause = (Map) exports.get(pack);
-
- if (bundleManifestVersion >= 2) {
- Set t = (Set) uses.get(pack);
- if (t != null && !t.isEmpty()) {
- StringBuffer sb = new StringBuffer();
- String del = "\"";
- for (Iterator u = t.iterator(); u.hasNext();) {
- String usedPackage = (String) u.next();
- if (!usedPackage.equals(pack)) {
- sb.append(del);
- sb.append(usedPackage);
- del = ",";
- }
- }
- sb.append("\"");
- clause.put("uses:", sb.toString());
- }
- }
- }
- archive.addManifestEntry(
- "Export-Package",
- printClauses(exports));
- }
- }
-
- /**
- * Verify that the declared imports match the referred packages.
- *
- * @param referred referred package
- * @param imports imported packages from POM
- * @throws MojoExecutionException
- */
- void verifyDeclaredImports(Set referred, Map imports)
- throws MojoExecutionException {
- Set declaredImports = imports.keySet();
- Set test = new HashSet(referred);
- test.removeAll(declaredImports);
- for (Iterator m = test.iterator(); m.hasNext();) {
- Object o = m.next();
- // For backwards compatibility with existing builds, only
- // issue a warning for missing imports. On the other hand,
- // if packages are being ignored, then this is a new project
- // so be more strict and throw an error.
- if (osgiManifest.getIgnorePackage() == null) {
- getLog().warn("[OSGi] MISSING IMPORT: " + o);
- }
- else {
- getLog().error("[OSGi] MISSING IMPORT: " + o);
- throw new MojoExecutionException("Missing Import " + o);
- }
- }
-
- test = new HashSet(declaredImports);
- test.removeAll(referred);
- for (Iterator m = test.iterator(); m.hasNext();) {
- getLog().warn("[OSGi] SUPERFLUOUS IMPORT: " + m.next());
- getLog()
- .warn(
- "[OSGi] Removing the POM Import-Package element will automatically generate the import clauses");
- }
- }
-
- /**
- * Standard OSGi header parser. This parser can handle the format clauses
- * ::= clause ( ',' clause ) + clause ::= name ( ';' name ) (';' key '='
- * value )
- *
- * This is mapped to a Map { name => Map { attr|directive => value } }
- *
- * @param value
- * @return
- * @throws MojoExecutionException
- */
- static Map parseHeader(String value) throws MojoExecutionException {
- if (value == null || value.trim().length() == 0)
- return null;
-
- Map result = new HashMap();
- QuotedTokenizer qt = new QuotedTokenizer(value, ";=,");
- char del;
- do {
- boolean hadAttribute = false;
- Map clause = new HashMap();
- List aliases = new ArrayList();
- aliases.add(qt.nextToken());
- del = qt.getSeparator();
- while (del == ';') {
- String adname = qt.nextToken();
- if ((del = qt.getSeparator()) != '=') {
- if (hadAttribute)
- throw new MojoExecutionException(
- "Header contains name field after attribute or directive: "
- + adname + " from " + value);
- aliases.add(adname);
- }
- else {
- String advalue = qt.nextToken();
- clause.put(adname, advalue);
- del = qt.getSeparator();
- hadAttribute = true;
- }
- }
- for (Iterator i = aliases.iterator(); i.hasNext();) {
- result.put(i.next(), clause);
- }
- } while (del == ',');
- return result;
- }
-
- /**
- * Create the import header, taking into account R4 automatic import clauses
- * for the exports.
- *
- * @param referred
- * @param contained
- */
- void createImportHeader(Set referred, Set contained) {
- if (referred.isEmpty())
- return;
-
- referred = new TreeSet(referred);
-
- if (bundleManifestVersion > 1) {
- referred.addAll(contained);
- }
-
- StringBuffer sb = new StringBuffer();
- String del = "";
-
- for (Iterator i = referred.iterator(); i.hasNext();) {
- sb.append(del);
- sb.append(i.next());
- del = ", ";
- }
- archive.addManifestEntry("Import-Package", sb.toString());
- }
-
- /**
- * Calculate the bundle class path based on the list of JARs in our bundle.
- * This list includes outselves. We also calculate the Bundle-Classpath
- * header (a bit clumsy) This is a bit cheap, so maybe this needs to be
- * changed TODO
- *
- * @param mainJar
- * @return
- */
- List getBundleClassPath(Jar mainJar) {
- List result = new ArrayList();
- for (Iterator i = mainJar.resources.keySet().iterator(); i.hasNext();) {
- String path = (String) i.next();
- Object resource = mainJar.resources.get(path);
- if (resource instanceof Jar) {
- result.add(path);
- }
- }
- return result;
- }
-
- /**
- * We traverse through al the classes that we can find and calculate the
- * contained and referred set and uses.
- *
- * @param jar
- * @param contained
- * @param referred
- * @param uses
- */
- void analyzeJar(Jar jar, Set contained, Set referred, Map uses) {
- String prefix = "";
- Set set = jar.getEntryPaths(prefix);
- for (Iterator r = set.iterator(); r.hasNext();) {
- String path = (String) r.next();
- Object resource = jar.getEntry(path);
- if (resource instanceof Clazz) {
- Clazz clazz = (Clazz) resource;
- String pathOfClass = path.substring(prefix.length());
- String pack = Clazz.getPackage(pathOfClass);
- contained.add(pack);
- referred.addAll(clazz.getReferred());
-
- // Add all the used packages
- // to this package
- Set t = (Set) uses.get(pack);
- if (t == null)
- uses.put(pack, t = new HashSet());
- t.addAll(clazz.getReferred());
- t.remove(pack);
- }
- }
- }
-
- /**
- * Print a standard Map based OSGi header.
- *
- * @param exports map { name => Map { attribute|directive => value } }
- * @return the clauses
- */
- String printClauses(Map exports) {
- StringBuffer sb = new StringBuffer();
- String del = "";
- for (Iterator i = exports.keySet().iterator(); i.hasNext();) {
- String name = (String) i.next();
- Map map = (Map) exports.get(name);
- sb.append(del);
- sb.append(name);
-
- for (Iterator j = map.keySet().iterator(); j.hasNext();) {
- String key = (String) j.next();
- String value = (String) map.get(key);
- sb.append(";");
- sb.append(key);
- sb.append("=");
- sb.append(value);
- }
- del = ", ";
- }
- return sb.toString();
- }
-
- /**
- * Check if the BundleManifest version is set correctly, base the manifest
- * version on it.
- *
- * @throws MojoExecutionException
- */
- void verifyDeclaredBundleManifestVersion() throws MojoExecutionException {
- String mfv = osgiManifest.getBundleManifestVersion();
- if (mfv != null && mfv.trim().length() != 0) {
- try {
- bundleManifestVersion = Integer.parseInt(mfv);
- if (bundleManifestVersion != 2)
- throw new MojoExecutionException(
- "Bundle-ManifestVersion must be 2, it is " + mfv);
- }
- catch (Exception e) {
- throw new MojoExecutionException(
- "Bundle-ManifestVersion must be an integer: " + mfv);
- }
- }
- }
-
- /**
- * TODO: Decide if we accept merging of entire manifest.mf files Here's a
- * big question to make a final decision at some point: Do accept merging of
- * manifest entries located in some file somewhere in the project directory?
- * If so, do we allow both file and configuration based entries to be
- * specified simultaneously and how do we merge these?
- */
- private void addManifestFile() {
- if (manifestFile != null) {
- File file = new File(project.getBasedir().getAbsolutePath(),
- manifestFile);
- getLog().info(
- "Manifest file: " + file.getAbsolutePath()
- + " will be used");
- archive.setManifestFile(file);
- }
- else {
- getLog().info("No manifest file specified. Default will be used.");
- }
- }
-
- /**
- * Look for any OSGi specified manifest entries in the maven-osgi-plugin
- * configuration section of the POM. If we find some, then add them to the
- * target artifact's manifest.
- */
- private void addManifestEntries() {
- if (osgiManifest.getBundleVersion() == null) {
- addBundleVersion();
- }
- if (osgiManifest != null && osgiManifest.getEntries().size() > 0) {
- Map entries = osgiManifest.getEntries();
-
- getLog().debug(
- "Bundle manifest will be modified with the following entries: "
- + entries.toString());
- archive.addManifestEntries(entries);
- }
- else {
- getLog()
- .info(
- "No OSGi bundle manifest entries have been specified in the POM.");
- }
- }
-
- /**
- * We are going to iterate through the POM's specified JAR dependencies. If
- * a dependency has a scope of either RUNTIME or COMPILE, then we'll JAR
- * them up inside the OSGi bundle artifact. We will then add the
- * Bundle-Classpath manifest entry.
- *
- * Artifacts which are inlined will not be included.
- */
- private void addEmbeddedJars() throws MojoExecutionException {
- Set artifacts = project.getArtifacts();
- Map artifactMap = ArtifactUtils.artifactMapByArtifactId( artifacts );
-
- for (Iterator it = artifacts.iterator(); it.hasNext();) {
- Artifact artifact = (Artifact) it.next();
- if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())
- && !Artifact.SCOPE_TEST.equals(artifact.getScope())) {
- String type = artifact.getType();
-
- if ("jar".equals(type)) {
- // Do not include artifacts which are inlined
- if (!(inlinedArtifacts.contains(artifact.getArtifactId()))) {
-
- // Do not include artifacts provided by another bundle
- boolean isProvidedByBundle = false;
- Iterator iter = artifact.getDependencyTrail().iterator();
- iter.next(); // skip this project
- while ( iter.hasNext() )
- {
- String id = (String) iter.next();
- Artifact element = (Artifact) artifactMap.get( id );
- if ( element != null
- && "osgi-bundle".equals( element.getType() ) )
- {
- isProvidedByBundle = true;
- break;
- }
- }
- if ( isProvidedByBundle )
- continue;
-
- File depFile = artifact.getFile();
-
- try {
- FileUtils.copyFileToDirectory(depFile, outputDirectory);
-
- }
- catch (Exception e) {
- String errmsg = "Error copying "
- + depFile.getAbsolutePath() + " to "
- + outputDirectory.getAbsolutePath();
- throw new MojoExecutionException(errmsg, e);
- }
- }
- }
- }
- }
- }
-
- private static String fixBundleVersion(String version) {
- // Maven uses a '-' to separate the version qualifier, while
- // OSGi uses a '.', so we need to convert the first '-' to a
- // '.' and fill in any missing minor or micro version
- // components if necessary.
- final java.util.regex.Matcher matcher = versionPattern.matcher(version);
- if (!matcher.lookingAt())
- return version;
-
- // Leave extra space for worst-case additional insertion:
- final StringBuffer sb = new StringBuffer(version.length() + 4);
- sb.append(matcher.group(1));
-
- if (null == matcher.group(3)) {
- final int count = null != matcher.group(2) ? 2 : 1;
- sb.append(versionCompleters[count - 1]);
- }
-
- sb.append('.');
- sb.append(version.substring(matcher.end(), version.length()));
- return sb.toString();
- }
-
- /**
- * Auto-set the bundle version.
- */
- private void addBundleVersion() {
- osgiManifest.setBundleVersion(fixBundleVersion(project.getVersion()));
- }
-
- /**
- * Returns a string array of the includes to be used when assembling/copying
- * the war.
- *
- * @return an array of tokens to include
- */
- private String[] getIncludes() {
- return new String[] {jarSourceIncludes};
- }
-
- /**
- * Returns a string array of the excludes to be used when assembling/copying
- * the jar.
- *
- * @return an array of tokens to exclude
- */
- private String[] getExcludes() {
- List excludeList = new ArrayList(FileUtils.getDefaultExcludesAsList());
-
- if (jarSourceExcludes != null && !"".equals(jarSourceExcludes)) {
- excludeList.add(jarSourceExcludes);
- }
-
- return (String[]) excludeList.toArray(EMPTY_STRING_ARRAY);
- }
-
- private Set parseIgnorePackage() {
- HashSet result = new HashSet();
- if ((ignorePackage == null) && (osgiManifest.getIgnorePackage() != null)) {
- ignorePackage = osgiManifest.getIgnorePackage();
- getLog().warn("DEPRECATED METADATA! "
- + "The <ignorePackage> tag should be set inside the <configuration> "
- + "tag, not in the <osgiManifest> tag.");
- }
- if (ignorePackage != null) {
- StringTokenizer st = new StringTokenizer(ignorePackage, ",", false);
- while (st.hasMoreTokens()) {
- result.add(st.nextToken().trim());
- }
- }
- return result;
- }
-
- private void checkReferencesProperty(Map uses) {
- String interestedIn = System.getProperty(OSGI_REFERENCES);
- if (interestedIn == null) {
- return;
- }
- StringBuffer buf = new StringBuffer();
- Iterator it1 = uses.entrySet().iterator();
- while (it1.hasNext()) {
- Map.Entry entry = (Map.Entry) it1.next();
- String pack = (String) entry.getKey();
- Set references = (Set) entry.getValue();
- Iterator it2 = references.iterator();
- while (it2.hasNext()) {
- String packReferred = (String) it2.next();
- if (interestedIn.equals(packReferred)) {
- buf.append(" |-- ");
- buf.append(pack);
- buf.append('\n');
- break;
- }
- }
- }
- if (buf.length() == 0) {
- getLog().info("Noone uses " + interestedIn);
- }
- else {
- int changePos = buf.lastIndexOf("|");
- buf.setCharAt(changePos, '+');
- getLog().info(interestedIn + " used by;\n" + buf);
- }
- }
-
- private void printReferencedPackages(Map uses) {
- StringBuffer buf = new StringBuffer();
- Iterator it1 = uses.entrySet().iterator();
- while (it1.hasNext()) {
- Map.Entry entry = (Map.Entry) it1.next();
- String pack = (String) entry.getKey();
- buf.append(pack);
- buf.append('\n');
- Set references = (Set) entry.getValue();
- Iterator it2 = references.iterator();
- while (it2.hasNext()) {
- String packReferred = (String) it2.next();
- buf.append(" |-- ");
- buf.append(packReferred);
- buf.append('\n');
- }
- int changePos = buf.lastIndexOf("|");
- if (changePos >= 0) {
- buf.setCharAt(changePos, '+');
- }
- buf.append('\n');
- }
- getLog().debug("Referenced package list: \n" + buf.toString());
- }
-
- private void inlineArtifacts() throws MojoExecutionException {
- Set artifacts = project.getArtifacts();
-
- for (Iterator it = artifacts.iterator(); it.hasNext();) {
- Artifact artifact = (Artifact) it.next();
- if (!Artifact.SCOPE_PROVIDED.equals(artifact.getScope())
- && !Artifact.SCOPE_TEST.equals(artifact.getScope())) {
- String type = artifact.getType();
-
- if ("jar".equals(type)) {
- if ((inlinedArtifacts.contains(artifact.getArtifactId()))) {
- File depFile = artifact.getFile();
-
- try {
- ZipFile inlinedJar = new ZipFile(depFile);
- Enumeration entries = inlinedJar.entries();
- byte[] buffer = new byte[4096];
- while (entries.hasMoreElements()) {
- ZipEntry entry = (ZipEntry) entries.nextElement();
- if (entry.isDirectory()) {
- new File(outputDirectory, entry.getName()).mkdirs();
- } else {
- // Have to do this because some JARs ship without directories, i.e., just files.
- new File(outputDirectory, entry.getName()).getParentFile().mkdirs();
- FileOutputStream out = new FileOutputStream(new File(outputDirectory, entry.getName()));
- InputStream in = inlinedJar.getInputStream(entry);
- for (int read = in.read(buffer); read != -1; read = in.read(buffer)) {
- out.write(buffer, 0, read);
- }
- in.close();
- out.close();
- }
- }
- } catch (Exception e) {
- String errmsg = "Error inlining "
- + depFile.getAbsolutePath() + " to "
- + outputDirectory.getAbsolutePath();
- throw new MojoExecutionException(errmsg, e);
- }
- }
- }
- }
- }
- }
-}
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java
deleted file mode 100644
index e1ee668..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/OsgiManifest.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.tools.maven.plugin;
-
-import java.util.Properties;
-
-/**
- * Hold values for an OSGi jar "bundle" manifest.
- *
- * @author <a href="mailto:dev@felix.apache.org">Apache Felix Project</a>
- * @version $Rev$, $Date$
- */
-public class OsgiManifest
-{
- /**
- * Bundle manifest header constants from the OSGi R4 framework constants.
- */
- private static final String BUNDLE_CATEGORY = "Bundle-Category";
- // private static final String BUNDLE_CLASSPATH = "Bundle-ClassPath";
- private static final String BUNDLE_COPYRIGHT = "Bundle-Copyright";
- private static final String BUNDLE_DESCRIPTION = "Bundle-Description";
- private static final String BUNDLE_NAME = "Bundle-Name";
- private static final String BUNDLE_NATIVECODE = "Bundle-NativeCode";
- private static final String EXPORT_PACKAGE = "Export-Package";
- private static final String EXPORT_SERVICE = "Export-Service";
- private static final String IMPORT_PACKAGE = "Import-Package";
- private static final String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package";
- private static final String IMPORT_SERVICE = "Import-Service";
- private static final String BUNDLE_VENDOR = "Bundle-Vendor";
- private static final String BUNDLE_VERSION = "Bundle-Version";
- private static final String BUNDLE_DOCURL = "Bundle-DocURL";
- private static final String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress";
- private static final String BUNDLE_ACTIVATOR = "Bundle-Activator";
- private static final String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation";
- private static final String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
- private static final String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName";
- private static final String BUNDLE_LOCALIZATION = "Bundle-Localization";
- private static final String REQUIRE_BUNDLE = "Require-Bundle";
- private static final String FRAGMENT_HOST = "Fragment-Host";
- private static final String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion";
- private static final String BUNDLE_URL = "Bundle-URL";
- private static final String BUNDLE_SOURCE = "Bundle-Source";
- private static final String BUNDLE_DATE = "Bundle-Date";
- private static final String METADATA_LOCATION = "Metadata-Location";
- private static final String SERVICE_COMPONENT = "Service-Component";
-
- /**
- * Instance variables corresponding to the R4 framework manifest headers
- */
- private String bundleCategory;
- // private String bundleClassPath;
- private String bundleCopyright;
- private String bundleDescription;
- private String bundleName;
- private String bundleNativeCode;
- private String exportPackage;
- private String exportService;
- private String importPackage;
- private String dynamicImportPackage;
- private String importService;
- private String bundleVendor;
- private String bundleVersion;
- private String bundleDocUrl;
- private String bundleContactAddress;
- private String bundleActivator;
- private String bundleUpdateLocation;
- private String bundleRequiredExecutionEnvironment;
- private String bundleSymbolicName;
- private String bundleLocalization;
- private String requireBundle;
- private String fragmentHost;
- private String bundleManifestVersion;
- private String explicitImportPackage;
-
- /**
- * Instance variables supporting non-framework manifest headers
- */
- private String bundleUrl;
- private String bundleSource;
- private String bundleDate;
- private String metadataLocation;
- private String serviceComponent;
- private String ignorePackage;
-
- private Properties entries = new Properties();
-
- public Properties getEntries()
- {
- /*
- * setEntryValue( BUNDLE_CLASSPATH, getBundleClassPath(), null);
- */
- setEntryValue(BUNDLE_CATEGORY, getBundleCategory(), null);
- setEntryValue(BUNDLE_COPYRIGHT, getBundleCopyright(), null);
- setEntryValue(BUNDLE_DESCRIPTION, getBundleDescription(), null);
- setEntryValue(BUNDLE_NAME, getBundleName(), null);
- setEntryValue(BUNDLE_NATIVECODE, getBundleNativeCode(), null);
- setEntryValue(EXPORT_PACKAGE, getExportPackage(), null);
- setEntryValue(EXPORT_SERVICE, getExportService(), null);
- setEntryValue(IMPORT_PACKAGE, getImportPackage(), null);
- setEntryValue(DYNAMICIMPORT_PACKAGE, getDynamicImportPackage(), null);
- setEntryValue(IMPORT_SERVICE, getImportService(), null);
- setEntryValue(BUNDLE_VENDOR, getBundleVendor(), null);
- setEntryValue(BUNDLE_VERSION, getBundleVersion(), null);
- setEntryValue(BUNDLE_DOCURL, getBundleDocUrl(), null);
- setEntryValue(BUNDLE_CONTACTADDRESS, getBundleContactAddress(), null);
- setEntryValue(BUNDLE_ACTIVATOR, getBundleActivator(), null);
- setEntryValue(BUNDLE_UPDATELOCATION, getBundleUpdateLocation(), null);
- setEntryValue(BUNDLE_REQUIREDEXECUTIONENVIRONMENT,
- getBundleRequiredExecutionEnvironment(), null);
- setEntryValue(BUNDLE_SYMBOLICNAME, getBundleSymbolicName(), null);
- setEntryValue(BUNDLE_LOCALIZATION, getBundleLocalization(), null);
- setEntryValue(REQUIRE_BUNDLE, getRequireBundle(), null);
- setEntryValue(FRAGMENT_HOST, getFragmentHost(), null);
- setEntryValue(BUNDLE_MANIFESTVERSION, getBundleManifestVersion(), null);
- setEntryValue(BUNDLE_URL, getBundleUrl(), null);
- setEntryValue(BUNDLE_SOURCE, getBundleSource(), null);
- setEntryValue(BUNDLE_DATE, getBundleDate(), null);
- setEntryValue(METADATA_LOCATION, getMetadataLocation(), null);
- setEntryValue(SERVICE_COMPONENT, getServiceComponent(), null);
- return entries;
- }
-
- public String getBundleCategory()
- {
- return bundleCategory;
- }
-
- public void setBundleCategory(String bundleCategory)
- {
- this.bundleCategory = bundleCategory;
- }
-
- /*
- * public String getBundleClasspath() { return bundleClasspath; }
- *
- * public void setBundleClasspath(String bundleClasspath) {
- * this.bundleClasspath = bundleClasspath; }
- */
-
- public String getBundleCopyright()
- {
- return bundleCopyright;
- }
-
- public void setBundleCopyright(String bundleCopyright)
- {
- this.bundleCopyright = bundleCopyright;
- }
-
- public String getBundleDescription()
- {
- return bundleDescription;
- }
-
- public void setBundleDescription(String bundleDescription)
- {
- this.bundleDescription = bundleDescription;
- }
-
- public String getBundleName()
- {
- return bundleName;
- }
-
- public void setBundleName(String bundleName)
- {
- this.bundleName = bundleName;
- }
-
- public String getBundleNativeCode()
- {
- return bundleNativeCode;
- }
-
- public void setBundleNativeCode(String bundleNativeCode)
- {
- this.bundleNativeCode = bundleNativeCode;
- }
-
- public String getExportPackage()
- {
- return exportPackage;
- }
-
- public void setExportPackage(String exportPackage)
- {
- this.exportPackage = trim(exportPackage);
- }
-
- public String getExportService()
- {
- return exportService;
- }
-
- public void setExportService(String exportService)
- {
- this.exportService = trim(exportService);
- }
-
- public String getImportPackage()
- {
- return importPackage;
- }
-
- public void setImportPackage(String importPackage)
- {
- this.importPackage = trim(importPackage);
- }
-
- public String getExplicitImportPackage()
- {
- return explicitImportPackage;
- }
-
- public void setExplicitImportPackage(String explicitImportPackage)
- {
- this.explicitImportPackage = trim(explicitImportPackage);
- }
-
- public String getDynamicImportPackage()
- {
- return dynamicImportPackage;
- }
-
- public void setDynamicImportPackage(String dynamicImportPackage)
- {
- this.dynamicImportPackage = trim(dynamicImportPackage);
- }
-
- public String getImportService()
- {
- return importService;
- }
-
- public void setImportService(String importService)
- {
- this.importService = importService;
- }
-
- public String getBundleVendor()
- {
- return bundleVendor;
- }
-
- public void setBundleVendor(String bundleVendor)
- {
- this.bundleVendor = bundleVendor;
- }
-
- public String getBundleVersion()
- {
- return bundleVersion;
- }
-
- public void setBundleVersion(String bundleVersion)
- {
- this.bundleVersion = bundleVersion;
- }
-
- public String getBundleDocUrl()
- {
- return bundleDocUrl;
- }
-
- public void setBundleDocUrl(String bundleDocUrl)
- {
- this.bundleDocUrl = bundleDocUrl;
- }
-
- public String getBundleContactAddress()
- {
- return bundleContactAddress;
- }
-
- public void setBundleContactAddress(String bundleContactAddress)
- {
- this.bundleContactAddress = bundleContactAddress;
- }
-
- public String getBundleActivator()
- {
- return bundleActivator;
- }
-
- public void setBundleActivator(String bundleActivator)
- {
- this.bundleActivator = trim(bundleActivator);
- }
-
- public String getBundleUpdateLocation()
- {
- return bundleUpdateLocation;
- }
-
- public void setBundleUpdateLocation(String bundleUpdateLocation)
- {
- this.bundleUpdateLocation = bundleUpdateLocation;
- }
-
- public String getBundleRequiredExecutionEnvironment()
- {
- return bundleRequiredExecutionEnvironment;
- }
-
- public void setBundleRequiredExecutionEnvironment(
- String bundleRequiredExecutionEnvironment)
- {
- this.bundleRequiredExecutionEnvironment = bundleRequiredExecutionEnvironment;
- }
-
- public String getBundleSymbolicName()
- {
- return bundleSymbolicName;
- }
-
- public void setBundleSymbolicName(String bundleSymbolicName)
- {
- this.bundleSymbolicName = trim(bundleSymbolicName);
- }
-
- public String getBundleLocalization()
- {
- return bundleLocalization;
- }
-
- public void setBundleLocalization(String bundleLocalization)
- {
- this.bundleLocalization = bundleLocalization;
- }
-
- public String getRequireBundle()
- {
- return requireBundle;
- }
-
- public void setRequireBundle(String requireBundle)
- {
- this.requireBundle = trim(requireBundle);
- }
-
- public String getFragmentHost()
- {
- return fragmentHost;
- }
-
- public void setFragmentHost(String fragmentHost)
- {
- this.fragmentHost = trim(fragmentHost);
- }
-
- public String getBundleManifestVersion()
- {
- return bundleManifestVersion;
- }
-
- public void setBundleManifestVersion(String bundleManifestVersion)
- {
- this.bundleManifestVersion = bundleManifestVersion;
- }
-
- public String getBundleUrl()
- {
- return bundleUrl;
- }
-
- public void setBundleUrl(String bundleUrl)
- {
- this.bundleUrl = bundleUrl;
- }
-
- public String getBundleSource()
- {
- return bundleSource;
- }
-
- public void setBundleSource(String bundleSource)
- {
- this.bundleSource = bundleSource;
- }
-
- public String getBundleDate()
- {
- return bundleDate;
- }
-
- public void setBundleDate(String bundleDate)
- {
- this.bundleDate = bundleDate;
- }
-
- public String getMetadataLocation()
- {
- return metadataLocation;
- }
-
- public void setMetadataLocation(String metadataLocation)
- {
- this.metadataLocation = metadataLocation;
- }
-
- public String getServiceComponent()
- {
- return serviceComponent;
- }
-
- public void setServiceComponent(String serviceComponent)
- {
- this.serviceComponent = serviceComponent;
- }
-
- public String getIgnorePackage()
- {
- return ignorePackage;
- }
-
- public void setIgnorePackage(String ignorePackage)
- {
- this.ignorePackage = ignorePackage;
- }
-
- /**
- * Removes all whitespace in the entry.
- *
- * @param entry
- * The entry to be cleaned up.
- * @return A copy of the entry string without any whitespace.
- */
- private String trim(String entry)
- {
- StringBuffer buf = new StringBuffer(entry.length());
- for (int i = 0; i < entry.length(); i++)
- {
- char ch = entry.charAt(i);
- if (ch > 32)
- {
- buf.append(ch);
- }
- }
- return buf.toString();
- }
-
- private void setEntryValue(String key, String value, String defaultValue)
- {
- if (value != null)
- {
- entries.put(key, value);
- }
- else if (defaultValue != null)
- {
- entries.put(key, defaultValue);
- }
- }
-}
diff --git a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/QuotedTokenizer.java b/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/QuotedTokenizer.java
deleted file mode 100644
index b8fef6f..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/java/org/apache/felix/tools/maven/plugin/QuotedTokenizer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.tools.maven.plugin;
-
-import java.util.*;
-
-public class QuotedTokenizer {
- String string;
- int index = 0;
- String separators;
- boolean returnTokens;
- boolean ignoreWhiteSpace = true;
- String peek;
- char separator;
-
- public QuotedTokenizer(String string, String separators, boolean returnTokens ) {
- if ( string == null )
- throw new IllegalArgumentException("string argument must be not null");
- this.string = string;
- this.separators = separators;
- this.returnTokens = returnTokens;
- }
- public QuotedTokenizer(String string, String separators) {
- this(string,separators,false);
- }
-
- public String nextToken(String separators) {
- separator = 0;
- if ( peek != null ) {
- String tmp = peek;
- peek = null;
- return tmp;
- }
-
- if ( index == string.length())
- return null;
-
- StringBuffer sb = new StringBuffer();
-
- while (index < string.length()) {
- char c = string.charAt(index++);
-
- if ( Character.isWhitespace(c)) {
- if ( index == string.length())
- break;
- else
- continue;
- }
-
- if (separators.indexOf(c) >= 0) {
- if (returnTokens)
- peek = Character.toString(c);
- else
- separator = c;
- break;
- }
-
- switch (c) {
- case '"' :
- case '\'' :
- quotedString(sb, c);
- break;
-
- default :
- sb.append(c);
- }
- }
- String result = sb.toString().trim();
- if ( result.length()==0 && index==string.length())
- return null;
- return result;
- }
-
- public String nextToken() {
- return nextToken(separators);
- }
-
- private void quotedString(StringBuffer sb, char c) {
- char quote = c;
- while (index < string.length()) {
- c = string.charAt(index++);
- if (c == quote)
- break;
- if (c == '\\' && index < string.length()
- && string.charAt(index + 1) == quote)
- c = string.charAt(index++);
- sb.append(c);
- }
- }
-
- public String[] getTokens() {
- return getTokens(0);
- }
-
- private String [] getTokens(int cnt){
- String token = nextToken();
- if ( token == null )
- return new String[cnt];
-
- String result[] = getTokens(cnt+1);
- result[cnt]=token;
- return result;
- }
-
- public char getSeparator() { return separator; }
-
- public List getTokenSet() {
- List list = new ArrayList();
- String token = nextToken();
- while ( token != null ) {
- list.add(token);
- token = nextToken();
- }
- return list;
- }
-}
diff --git a/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml b/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index 4bcab94..0000000
--- a/tools/maven2/maven-osgi-plugin/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<component-set>
- <components>
- <component>
- <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
- <role-hint>osgi-bundle</role-hint>
- <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
- <configuration>
- <lifecycles>
- <lifecycle>
- <id>default</id>
- <!-- START SNIPPET: osgi-bundle-lifecycle -->
- <phases>
- <process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
- <compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
- <process-test-resources>org.apache.maven.plugins:maven-resources-plugin:testResources</process-test-resources>
- <test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</test-compile>
- <test>org.apache.maven.plugins:maven-surefire-plugin:test</test>
- <package>org.apache.felix.plugins:maven-osgi-plugin:osgi-bundle</package>
- <install>org.apache.maven.plugins:maven-install-plugin:install</install>
- <deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
- </phases>
- <!-- END SNIPPET: osgi-bundle-lifecycle -->
- </lifecycle>
- </lifecycles>
- </configuration>
- </component>
- <component>
- <role>org.apache.maven.artifact.handler.ArtifactHandler</role>
- <role-hint>osgi-bundle</role-hint>
- <implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
- <configuration>
- <type>osgi-bundle</type>
- <language>java</language>
- <extension>jar</extension>
- <addedToClasspath>true</addedToClasspath>
- </configuration>
- </component>
- </components>
-</component-set>
diff --git a/tools/maven2/osgi-archetype/pom.xml b/tools/maven2/osgi-archetype/pom.xml
deleted file mode 100644
index dc6765d..0000000
--- a/tools/maven2/osgi-archetype/pom.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.felix.archetypes</groupId>
- <artifactId>osgi-archetype</artifactId>
- <packaging>maven-plugin</packaging>
- <version>0.9.0-SNAPSHOT</version>
- <name>OSGi Archetype</name>
-</project>
diff --git a/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml b/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
deleted file mode 100644
index fe5c518..0000000
--- a/tools/maven2/osgi-archetype/src/main/resources/META-INF/archetype.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<archetype>
- <id>osgi-archetype</id>
- <sources>
- <source>src/main/java/Activator.java</source>
- </sources>
-</archetype>
\ No newline at end of file
diff --git a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml b/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
deleted file mode 100644
index 99d7fc1..0000000
--- a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/pom.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>${groupId}</groupId>
- <artifactId>${artifactId}</artifactId>
- <packaging>osgi-bundle</packaging>
- <version>${version}</version>
- <name>Simple Bundle Project</name>
- <url>http://felix.apache.org</url>
-
- <dependencies>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi</artifactId>
- <version>3.0</version>
- <scope>provided</scope>
- </dependency>
- </dependencies>
-
- <build>
- <!--
- ***********************************************************
- * Uncomment out to override default jar naming convention *
- ***********************************************************
- <finalName>my-bundle</finalName>
- -->
- <plugins>
- <plugin>
- <groupId>org.apache.felix.plugins</groupId>
- <artifactId>maven-osgi-plugin</artifactId>
- <extensions>true</extensions>
- <configuration>
- <!--
- *************************************************
- * Uncomment to specify a manifest file to merge *
- *************************************************
- <manifestFile>path/to/manifest.mf</manifestFile>
- -->
-
- <!--
- *******************************************************************
- * See the following link for entry specification *
- * http://docs.safehaus.org/display/OSGI/OSGi+Plugin+for+Maven+2.0 *
- *******************************************************************
- -->
- <osgiManifest>
- <bundleName>Simple Bundle</bundleName>
- <bundleActivator>${groupId}.Activator</bundleActivator>
- <bundleVendor>Apache Software Foundation</bundleVendor>
- </osgiManifest>
- </configuration>
- </plugin>
- </plugins>
- </build>
-</project>
diff --git a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java b/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
deleted file mode 100644
index dd05a0c..0000000
--- a/tools/maven2/osgi-archetype/src/main/resources/archetype-resources/src/main/java/Activator.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2005 The Apache Software Foundation
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-package ${groupId};
-
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.ServiceEvent;
-import org.osgi.framework.ServiceListener;
-
-/**
- * This class implements a simple bundle that utilizes the OSGi
- * framework's event mechanism to listen for service events.
- *
- * Upon receiving a service event, it prints out the event's details.
-**/
-public class Activator implements BundleActivator, ServiceListener {
-
- /**
- * Put your bundle initialization code here...
- *
- * Implements <code>BundleActivator.start()</code>. Prints a message
- * and adds itself to the bundle context as a service listener.
- *
- * @param bundleContext the framework context for the bundle
- * @throws Exception
- */
- public void start(BundleContext bundleContext) throws Exception {
- System.out.println("Starting to listen for service events.");
- bundleContext.addServiceListener(this);
- }
-
- /**
- * Put your bundle finalization code here...
- *
- * Implements <code>BundleActivator.stop()</code>. Prints a message
- * and removes itself from the bundle context as a service listener.
- *
- * @param bundleContext the framework context for the bundle
- * @throws Exception
- */
- public void stop(BundleContext bundleContext) throws Exception {
- bundleContext.removeServiceListener(this);
- System.out.println("Stopped listening for service events.");
-
- // Note: It is not required that we remove the listener here, since
- // the framework will do it automatically anyway.
- }
-
- /**
- * Implements <code>ServiceListener.serviceChanges()</code>. Prints the
- * details of any service event from the framework.
- *
- * @param event the fired service event
- */
- public void serviceChanged(ServiceEvent event) {
- String[] objectClass = (String[]) event.getServiceReference().getProperty("objectClass");
- if (event.getType() == ServiceEvent.REGISTERED) {
- System.out.println("SimpleBundle: Service of type " + objectClass[0] + " registered.");
- } else if (event.getType() == ServiceEvent.UNREGISTERING) {
- System.out.println("SimpleBundle: Service of type " + objectClass[0] + " unregistered.");
- } else if (event.getType() == ServiceEvent.MODIFIED) {
- System.out.println("SimpleBundle: Service of type " + objectClass[0] + " modified.");
- }
- }
-}