You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by hu...@apache.org on 2009/10/02 13:59:31 UTC

svn commit: r820982 [1/2] - in /incubator/aries/contrib/ibm: com.ibm.osgi.web/ com.ibm.osgi.web/META-INF/ com.ibm.osgi.web/OSGI-INF/ com.ibm.osgi.web/OSGI-INF/blueprint/ com.ibm.osgi.web/src/ com.ibm.osgi.web/src/com/ com.ibm.osgi.web/src/com/ibm/ com....

Author: hughesj
Date: Fri Oct  2 11:59:28 2009
New Revision: 820982

URL: http://svn.apache.org/viewvc?rev=820982&view=rev
Log:
Added the code missing from the IBM initial contribution, as listed in the README

Added:
    incubator/aries/contrib/ibm/com.ibm.osgi.web/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/.aries   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/.project   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/UrlHandlerTest.war   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/test.jar   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/
    incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.aries   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadataFactory.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/Content.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ServiceDeclaration.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/VersionRange.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ApplicationMetadataImpl.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ContentImpl.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/ServiceDeclarationImpl.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/api/VersionRangeImpl.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/AppConstants.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/ws/eba/app/utils/manifest/ManifestProcessor.java   (with props)
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/
    incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/unittest/com/ibm/ws/eba/app/utils/test/ManifestProcessorTest.java   (with props)
Modified:
    incubator/aries/contrib/ibm/prereqs/persistence/build.xml
    incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/ExceptionListener.java
    incubator/aries/contrib/ibm/unittest.framework/src/com/ibm/aries/unittest/mocks/Skeleton.java

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/.aries
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/.aries?rev=820982&view=auto
==============================================================================
    (empty)

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/.aries
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath Fri Oct  2 11:59:28 2009
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="unittest"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
+		<accessrules>
+			<accessrule kind="accessible" pattern="org/osgi/service/url/"/>
+		</accessrules>
+	</classpathentry>
+	<classpathentry combineaccessrules="false" kind="src" path="/unittest.framework"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/prereqs"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/.classpath
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/.project
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/.project?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/.project (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/.project Fri Oct  2 11:59:28 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>com.ibm.osgi.web</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/.project
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF Fri Oct  2 11:59:28 2009
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Ant-Version: Apache Ant 1.7.0
+Created-By: 2.3 (IBM Corporation)
+Bundle-ManifestVersion: 2
+Bundle-Name: URLHandler Plug-in
+Bundle-SymbolicName: com.ibm.osgi.web
+Bundle-Activator: com.ibm.osgi.web.url.WAR_URLServiceHandler
+bundle-Version: 1.0.0
+Import-Package: org.objectweb.asm;version="[2.2.2,3.0.0)",
+ org.objectweb.asm.signature;version="[2.2.2,3.0.0)",
+ org.osgi.framework;version="1.5.0",
+ org.osgi.service.url;version="1.0.0"
+Eclipse-LazyStart: true

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml Fri Oct  2 11:59:28 2009
@@ -0,0 +1,15 @@
+<blueprint>
+
+  <bean id="WarURLSchemeHandler" class="com.ibm.osgi.web.url.WAR_URLServiceHandler" activation="lazy"/>
+
+  <service ref="WarURLSchemeHandler" interface="org.osgi.service.url.URLStreamHandlerService">
+    <service-properties>
+      <entry key="url.handler.protocol">
+        <array value-type="java.lang.String">
+          <value>war</value>
+        </array>
+      </entry>
+    </service-properties>
+  </service>
+  
+</blueprint>
\ No newline at end of file

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/OSGI-INF/blueprint/WARHandler.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/UrlHandlerTest.war
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/UrlHandlerTest.war?rev=820982&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/UrlHandlerTest.war
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/UrlHandlerTest.war
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties Fri Oct  2 11:59:28 2009
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = build/classes
+bin.includes = META-INF/,\
+               .

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/build.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml Fri Oct  2 11:59:28 2009
@@ -0,0 +1,6 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="com.ibm.osgi.web" default="build" basedir=".">
+      <property name="aries.image" value="true"/>
+      <import file="../build/imports/standard_imports.xml"/>
+</project>
\ No newline at end of file

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/build.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,440 @@
+/*
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.url;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.objectweb.asm.AnnotationVisitor;
+import org.objectweb.asm.Attribute;
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.FieldVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Type;
+import org.objectweb.asm.signature.SignatureReader;
+import org.objectweb.asm.signature.SignatureVisitor;
+
+public class PackageFinder implements AnnotationVisitor, SignatureVisitor, ClassVisitor,
+    FieldVisitor, MethodVisitor
+{
+  private Set<String> packages = new HashSet<String>();
+  private Set<String> exemptPackages = new HashSet<String>();
+
+  // stored value of the signature class name
+  private String signatureOuterClass = null;
+
+  public Set<String> getImportPackages()
+  {
+    // Remove entries that will be imported by default
+    for (Iterator<String> i = packages.iterator(); i.hasNext();) {
+      if (i.next().startsWith("java.")) i.remove();
+    }
+    
+    return packages;
+  }
+  
+  public Set<String> getExemptPackages()
+  {
+    return exemptPackages;
+  }
+
+  private String getPackageName(String name)
+  {
+    String packageName = null;
+    if (name != null) {
+      int index = name.lastIndexOf('/');
+      if (index > 0) packageName = name.substring(0, index);
+    }
+    return packageName;
+  }
+
+  private String canonizePackage(String rawPackage)
+  {
+    String result = rawPackage.replace('/', '.');
+
+    // handle arrays
+    return result.replaceFirst("^\\[+L", "");
+  }
+  
+  private void addPackage(String packageName)
+  {
+    if (packageName != null) {
+      packages.add(canonizePackage(packageName));
+    }
+  }
+  
+  private void addExemptPackage(String packageName)
+  {
+    if (packageName != null) 
+      exemptPackages.add(canonizePackage(packageName));
+  }
+
+  private void addPackages(String[] packageNames)
+  {
+    if (packageNames != null) {
+      for (String s : packageNames)
+        if (s != null) {
+          packages.add(canonizePackage(s));
+        }
+    }
+  }
+
+  private String getResolvedPackageName(String name)
+  {
+    String resolvedName = null;
+    if (name != null) resolvedName = getPackageName(name);
+    return resolvedName;
+  }
+
+  private String[] getResolvedPackageNames(String[] names)
+  {
+    String[] resolvedNames = null;
+    if (names != null) {
+      resolvedNames = new String[names.length];
+      int i = 0;
+      for (String s : names)
+        resolvedNames[i++] = getResolvedPackageName(s);
+    }
+    return resolvedNames;
+  }
+
+  private String getDescriptorInfo(String descriptor)
+  {
+    String type = null;
+    if (descriptor != null) type = getType(Type.getType(descriptor));
+    return type;
+  }
+
+  private String[] getMethodDescriptorInfo(String descriptor)
+  {
+    String[] descriptors = null;
+    if (descriptor != null) {
+      Type[] types = Type.getArgumentTypes(descriptor);
+      descriptors = new String[types.length + 1];
+      descriptors[0] = getType(Type.getReturnType(descriptor));
+      int i = 1;
+      for (Type t : types)
+        descriptors[i++] = getType(t);
+    }
+    return descriptors;
+  }
+
+  private String getType(Type t)
+  {
+    String type = null;
+    switch (t.getSort())
+    {
+      case Type.ARRAY:
+        type = getType(t.getElementType());
+        break;
+      case Type.OBJECT:
+        type = getPackageName(t.getInternalName());
+        break;
+    }
+    return type;
+  }
+
+  private void addSignaturePackages(String signature)
+  {
+    if (signature != null) new SignatureReader(signature).accept(this);
+  }
+
+  private void addResolvedSignaturePackages(String signature)
+  {
+    if (signature != null) new SignatureReader(signature).acceptType(this);
+  }
+
+  //
+  // ClassVisitor methods
+  //
+
+  public void visit(int arg0, int arg1, String name, String signature, String parent,
+      String[] interfaces)
+  {
+    // We dont want to import our own packages so we add this classes package name to the
+    // list of exempt packages.
+    addExemptPackage(getPackageName(name));
+
+    if (signature == null) {
+      addPackage(getResolvedPackageName(parent));
+      addPackages(getResolvedPackageNames(interfaces));
+    } else addSignaturePackages(signature);
+  }
+
+  public AnnotationVisitor visitAnnotation(String descriptor, boolean visible)
+  {
+    addPackage(getDescriptorInfo(descriptor));
+    return this;
+  }
+
+  public void visitAttribute(Attribute arg0)
+  {
+    // No-op
+  }
+
+  public FieldVisitor visitField(int access, String name, String descriptor, String signature,
+      Object value)
+  {
+    if (signature == null) addPackage(getDescriptorInfo(descriptor));
+    else addResolvedSignaturePackages(signature);
+
+    if (value instanceof Type) addPackage(getType((Type) value));
+    return this;
+  }
+
+  public void visitInnerClass(String arg0, String arg1, String arg2, int arg3)
+  {
+    // no-op
+  }
+
+  public MethodVisitor visitMethod(int access, String name, String descriptor, String signature,
+      String[] exceptions)
+  {
+    if (signature == null) addPackages(getMethodDescriptorInfo(descriptor));
+    else addSignaturePackages(signature);
+
+    addPackages(getResolvedPackageNames(exceptions));
+    return this;
+
+  }
+
+  public void visitOuterClass(String arg0, String arg1, String arg2)
+  {
+    // no-op
+  }
+
+  public void visitSource(String arg0, String arg1)
+  {
+    // no-op
+  }
+
+  public void visitEnd()
+  {
+    // no-op
+  }
+
+  // 
+  // MethodVisitor methods
+  //
+
+  public AnnotationVisitor visitAnnotationDefault()
+  {
+    return this;
+  }
+
+  public void visitCode()
+  {
+    // no-op
+  }
+
+  public void visitFieldInsn(int opcode, String owner, String name, String descriptor)
+  {
+    addPackage(getResolvedPackageName(owner));
+    addPackage(getDescriptorInfo(descriptor));
+  }
+
+  public void visitFrame(int arg0, int arg1, Object[] arg2, int arg3, Object[] arg4)
+  {
+    // no-op
+  }
+
+  public void visitIincInsn(int arg0, int arg1)
+  {
+    // no-op
+  }
+
+  public void visitInsn(int arg0)
+  {
+    // no-op
+  }
+
+  public void visitIntInsn(int arg0, int arg1)
+  {
+    // no-op
+  }
+
+  public void visitJumpInsn(int arg0, Label arg1)
+  {
+    // no-op
+  }
+
+  public void visitLabel(Label arg0)
+  {
+    // no-op
+  }
+
+  public void visitLdcInsn(Object type)
+  {
+    if (type instanceof Type) addPackage(getType((Type) type));
+  }
+
+  public void visitLineNumber(int arg0, Label arg1)
+  {
+    // no-op
+  }
+
+  public void visitLocalVariable(String name, String descriptor, String signature, Label start,
+      Label end, int index)
+  {
+    addResolvedSignaturePackages(signature);
+  }
+
+  public void visitLookupSwitchInsn(Label arg0, int[] arg1, Label[] arg2)
+  {
+    // no-op
+  }
+
+  public void visitMaxs(int arg0, int arg1)
+  {
+    // no-op
+  }
+
+  public void visitMethodInsn(int opcode, String owner, String name, String descriptor)
+  {
+    addPackage(getResolvedPackageName(owner));
+    addPackages(getMethodDescriptorInfo(descriptor));
+  }
+
+  public void visitMultiANewArrayInsn(String descriptor, int arg1)
+  {
+    addPackage(getDescriptorInfo(descriptor));
+  }
+
+  public AnnotationVisitor visitParameterAnnotation(int arg0, String descriptor, boolean arg2)
+  {
+    addPackage(getDescriptorInfo(descriptor));
+    return this;
+  }
+
+  public void visitTableSwitchInsn(int arg0, int arg1, Label arg2, Label[] arg3)
+  {
+    //no-op
+  }
+
+  public void visitTryCatchBlock(Label arg0, Label arg1, Label arg2, String type)
+  {
+    addPackage(getResolvedPackageName(type));
+  }
+
+  public void visitTypeInsn(int arg0, String type)
+  {
+    addPackage(getResolvedPackageName(type));
+  }
+
+  public void visitVarInsn(int arg0, int arg1)
+  {
+    // no-op
+  }
+
+  //
+  // AnnotationVisitor Methods
+  //
+
+  public void visit(String arg0, Object value)
+  {
+    if (value instanceof Type) {
+      addPackage(getType((Type) value));
+    }
+  }
+
+  public AnnotationVisitor visitAnnotation(String arg0, String descriptor)
+  {
+    addPackage(getDescriptorInfo(descriptor));
+    return this;
+  }
+
+  public AnnotationVisitor visitArray(String arg0)
+  {
+    return this;
+  }
+
+  public void visitEnum(String name, String desc, String value)
+  {
+    addPackage(getDescriptorInfo(desc));
+  }
+
+  // 
+  // SignatureVisitor methods
+  //
+
+  public SignatureVisitor visitArrayType()
+  {
+    return this;
+  }
+
+  public void visitBaseType(char arg0)
+  {
+    // no-op
+  }
+
+  public SignatureVisitor visitClassBound()
+  {
+    return this;
+  }
+
+  public void visitClassType(String name)
+  {
+    signatureOuterClass = name;
+    addPackage(getResolvedPackageName(name));
+  }
+
+  public void visitInnerClassType(String name)
+  {
+    addPackage(getResolvedPackageName(signatureOuterClass + "$" + name));
+  }
+
+  public SignatureVisitor visitExceptionType()
+  {
+    return this;
+  }
+
+  public void visitFormalTypeParameter(String arg0)
+  {
+    // no-op
+  }
+
+  public SignatureVisitor visitInterface()
+  {
+    return this;
+  }
+
+  public SignatureVisitor visitParameterType()
+  {
+    return this;
+  }
+
+  public SignatureVisitor visitReturnType()
+  {
+    return this;
+  }
+
+  public SignatureVisitor visitSuperclass()
+  {
+    return this;
+  }
+
+  public void visitTypeArgument()
+  {
+    // no-op
+  }
+
+  public SignatureVisitor visitTypeArgument(char arg0)
+  {
+    return this;
+  }
+
+  public void visitTypeVariable(String arg0)
+  {
+    // no-op
+  }
+
+  public SignatureVisitor visitInterfaceBound()
+  {
+    return this;
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/PackageFinder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,72 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.url;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Properties;
+
+import org.osgi.framework.Constants;
+
+import com.ibm.osgi.web.util.WarToWabConverter;
+
+public class WARConnection extends URLConnection
+{
+  private WarToWabConverter converter = null;
+  private Properties properties;
+  
+  protected WARConnection(URL url, Properties properties) throws MalformedURLException
+  {
+    super(url);
+    this.properties = properties;
+    
+    // Validate properties
+    
+    String bundleManifestVersion = (String)properties.get(Constants.BUNDLE_VERSION);
+    if (bundleManifestVersion != null && !bundleManifestVersion.equals("2"))
+      throw new MalformedURLException("Incorrect bundle version supplied in URL : "+bundleManifestVersion);
+    
+  }
+
+  @Override
+  public void connect() throws IOException
+  {
+    int fileNameIndex = url.getFile().lastIndexOf("/") + 1;
+    String warName;
+    if (fileNameIndex != 0)
+      warName = url.getFile().substring(fileNameIndex);
+    else
+      warName = url.getFile();
+
+    converter = new WarToWabConverter(new WarToWabConverter.InputStreamProvider() {
+      public InputStream getInputStream() throws IOException {
+        return url.openStream();
+      }
+    }, warName, properties);
+  }
+
+  @Override
+  public InputStream getInputStream() throws IOException
+  {
+    if (converter == null)
+      connect();
+    
+    return converter.getWAB();
+  }
+
+  @Override
+  public int getContentLength()
+  {
+    try {
+      if (converter == null)
+        connect();
+      return converter.getWabLength();
+    } catch (IOException e) {
+      return -1;
+    }
+  }
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WARConnection.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,95 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.url;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.service.url.AbstractURLStreamHandlerService;
+import org.osgi.service.url.URLConstants;
+import org.osgi.service.url.URLStreamHandlerService;
+
+public class WAR_URLServiceHandler extends AbstractURLStreamHandlerService implements
+    BundleActivator
+{
+
+  private static final String urlScheme = "webbundle";
+  
+  public WAR_URLServiceHandler()
+  {
+    super();
+  }
+
+  public URLConnection openConnection(URL url) throws IOException
+  {
+    // Create properties object
+    Properties properties = new Properties();
+    if (url.getQuery() != null)
+    {
+      String propString = url.getQuery();
+      StringTokenizer tok = new StringTokenizer(propString);
+      boolean firstProperty = true;
+      
+      // We now parse the property pairs query string.
+      // This has the format name=value&name=value...(etc)
+      while (tok.hasMoreElements())
+      {
+        String name = tok.nextToken("=");
+        // "name" will now contain the name of the property we are trying to 
+        // set. Property pairs are seperated by the '&' symbol. The tokenizer
+        // will include this symbol in the token so we need to return it from
+        // all property names except the first.
+        if (!!!firstProperty)
+          name = name.substring(1);
+        String value = tok.nextToken("&").substring(1);
+        properties.put(name, value);
+        firstProperty = false;
+      }
+    }
+        
+    return new WARConnection(new URL(url.getPath()), properties);
+  }
+
+  @Override
+  public void parseURL(URL u, String spec, int start, int limit)
+  {
+    int propertyStart = spec.lastIndexOf('?') + 1;
+    String propertyString = null;
+    if (propertyStart > 0) 
+    {
+      propertyString = spec.substring(propertyStart, spec.length());
+      propertyStart--;
+    }
+    else
+      propertyStart = spec.length();
+
+    String warURL = spec.substring(start, propertyStart);
+    
+    // For our war url, we use the "path" field to specify the full url path to the WAR file,
+    // and we use the "query" field to specify the properties for the WAB manifest
+    
+    setURL(u, urlScheme, null, 0, null, null, warURL, propertyString, null);
+  }
+
+  public void start(BundleContext context) throws Exception
+  {
+    Dictionary properties = new Hashtable();
+    properties.put( URLConstants.URL_HANDLER_PROTOCOL, new String[] {urlScheme});
+    context.registerService(URLStreamHandlerService.class.getName(), this, properties);
+  }
+
+  public void stop(BundleContext arg0) throws Exception
+  {
+    // TODO Auto-generated method stub
+    
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/url/WAR_URLServiceHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,80 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.jar.Manifest;
+
+public class ClassPathBuilder
+{
+  private Map<String, Manifest> manifests;
+  
+  /**
+   * This class takes a map of <jarFileName, manifest> pairs which are contained in 
+   * a particular jar file.
+   * The updatePath method then uses this list to analyse the contents of the manifests
+   * and looks for any dependencies in the other manfiests in the jar.
+   * @param manifests
+   */
+  public ClassPathBuilder(Map<String, Manifest> manifests)
+  {
+    this.manifests = manifests;
+  }
+
+  /**
+   * We take a full qualified jar file name and search its manifest for any other classpath
+   * dependencies within the other manifest in the parent jar file.
+   * @param jarFile
+   * @param classPath
+   * @return
+   * @throws IOException
+   */
+  public ArrayList<String> updatePath(String jarFile, ArrayList<String> classPath) throws IOException
+  {
+      // Get the classpath entries from this manifest and merge them into ours
+      Manifest manifest = manifests.get(jarFile);
+      
+      if (manifest == null)
+        return classPath;
+      
+      String dependencies = manifest.getMainAttributes().getValue("Class-Path");
+      if (dependencies == null)
+        dependencies = manifest.getMainAttributes().getValue("Class-path");
+            
+      if (dependencies != null)
+      {
+        // Search through the entries in the classpath
+        StringTokenizer tok = new StringTokenizer(dependencies, ";");
+        while (tok.hasMoreTokens()) {
+          String path = jarFile.substring(0, jarFile.lastIndexOf('/'));;
+          String entry = tok.nextToken();
+          
+          // Resolve the path to its canonical form
+          path = new File("/"+path+"/"+entry).getCanonicalPath().replace('\\','/');
+          path = path.substring(path.indexOf('/')+1);
+     
+          // If we havent already located this dependency before then we add this to our
+          // list of dependencies
+          if (entry.endsWith(".jar") && 
+              manifests.keySet().contains(path) && 
+              !classPath.contains(path) && 
+              !path.startsWith("WEB-INF/lib"))
+          {
+            classPath.add(path);
+            
+            // Recursively search the new classpath entry for more dependencies
+            classPath = updatePath(path, classPath);
+            
+          }
+        }
+      }
+
+    return classPath;
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/ClassPathBuilder.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,94 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.util;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+//import com.ibm.websphere.ras.Tr;
+//import com.ibm.websphere.ras.TraceComponent;
+
+public class JSPImportParser {
+
+  //private static final TraceComponent tc = Tr.register(JSPImportParser.class,
+  //    null, null);
+ 
+  /**
+   * 
+   * @param is
+   *          An input stream of character-based text. We expect this to be JSP
+   *          source code.
+   * @return Each java package found within valid JSP import tags
+   * @throws IOException
+   */
+  public static Collection<String> getImports (InputStream is) throws IOException {
+    //if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
+    //  Tr.entry(tc, "getImports", is);
+    Collection<String> importedPackages = new LinkedList<String>();
+    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+    String line = null;
+    do { 
+      line = reader.readLine();
+      // searchMatchedGroupForImports could take (line): I've not done that because 
+      // the entry trace, once working, will print out lots of useless information.  
+      if (line != null) { 
+        Matcher hasJSPimport = lineWithJSPimport.matcher(line);
+        if (hasJSPimport.find()) {
+          Collection<String> foundImports = searchMatchedGroupForImports (hasJSPimport.group());
+          for (String found : foundImports) { 
+            if (!importedPackages.contains(found)) { 
+              importedPackages.add(found);
+            }
+          }
+        }
+      }
+    } while (line != null);
+    //if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
+    //  Tr.exit(tc, "getImports", importedPackages);
+    return importedPackages;
+  }
+  
+  private static final Pattern lineWithJSPimport = Pattern.compile("<%@\\s*page\\s*import.*%>");
+  private static final Pattern stanzaEnd = Pattern.compile("%>");
+  private static final Pattern imports = Pattern.compile("import\\s*=\\s*\"(.*?)\"");
+  
+  /**
+   * 
+   * @param groupExtent a block of text known to contain a JSP import
+   * @return Each package found within valid JSP import tags
+   */
+  private static LinkedList<String> searchMatchedGroupForImports (String groupExtent) {
+    //if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
+    //  Tr.entry(tc, "searchMatchedGroupForImports", groupExtent);
+ 
+    LinkedList<String> packagesFound = new LinkedList<String>();
+    String importStanzas[] = stanzaEnd.split(groupExtent);
+    for (String s: importStanzas){ 
+      Matcher oneImport = imports.matcher(s);
+      if (oneImport.find()) {
+        String thisStanzasImports = oneImport.group();
+        String allPackages = thisStanzasImports.substring(thisStanzasImports.indexOf("\"")+1, 
+            thisStanzasImports.lastIndexOf("\""));
+        String [] imports = allPackages.split(",");
+        for (String p : imports) { 
+          String thisPackage = p.substring(0,p.lastIndexOf('.')).trim();
+          //if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
+          //  Tr.debug(tc, "searchMatchedGroupForImports adding package", thisPackage);
+          
+          if (!!!thisPackage.startsWith("java."))
+            packagesFound.add(thisPackage);
+        }
+      }
+    }
+    //if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
+    //  Tr.entry(tc, "searchMatchedGroupForImports", packagesFound);
+    return packagesFound;
+  }
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/JSPImportParser.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,393 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.util;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.StringTokenizer;
+import java.util.jar.Attributes;
+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.objectweb.asm.ClassReader;
+import org.osgi.framework.Constants;
+
+import com.ibm.osgi.web.url.PackageFinder;
+
+public class WarToWabConverter {
+  private static final String DEFAULT_BUNDLE_VERSION = "1.0";
+  private static final String DEFAULT_BUNDLE_MANIFESTVERSION = "2";
+  private static final String INITIAL_CLASSPATH_ENTRY = "WEB-INF/classes/";
+  private static final String CLASSPATH_LIB_PREFIX = "WEB-INF/lib/";
+  private static final String DEFAULT_IMPORT_PACKAGE_LIST = "javax.servlet;version=2.5,"
+      + "javax.servlet.http;version=2.5,"
+      + "javax.el;version=2.1,"
+      + "javax.servlet.jsp;version=2.1,"
+      + "javax.servlet.jsp.el;version=2.1,"
+      + "javax.servlet.jsp.tagext;version=2.1";
+
+  private static final String DEFAULT_WEB_CONTEXT_PATH = "/";
+  private static final String DEFAULT_WEB_JSP_EXTRACT_LOCATION = "/";
+
+  // TODO: These constants should be in the framework but at the time of write
+  // they
+  // do not exist. When they do we need to point at their values instead.
+  public static final String WEB_CONTEXT_PATH = "Web-ContextPath";
+  public static final String WEB_JSP_EXTRACT_LOCATION = "Web-JSPExtractLocation";
+
+  private Properties properties;
+
+  // InputStream for the new WAB file
+  private byte[] wabFile;
+  private String warName;
+  
+  private boolean converted = false;
+  private InputStreamProvider isProvider;
+
+  // State used for updating the manifest
+  private ArrayList<String> fileNames;
+  private Set<String> importPackages;
+  private Set<String> exemptPackages;
+  private Map<String, Manifest> manifests; 
+  private ArrayList<String> classPath;
+
+  public static interface InputStreamProvider {
+    public InputStream getInputStream() throws IOException;
+  }
+
+  public WarToWabConverter(InputStreamProvider input, String warName,
+      Properties properties) throws IOException {
+    this.warName = warName;
+
+    this.properties = properties;
+    fileNames = new ArrayList<String>();
+    classPath = new ArrayList<String>();
+    importPackages = new HashSet<String>();
+    exemptPackages = new HashSet<String>();
+    isProvider = input;
+  }
+
+  private void convert() throws IOException {
+    /*
+     * Open the underlying URL and load in the WAR. We then update the manifest
+     * file and hold an in-memory version of the modified WAR.
+     */
+
+    ZipEntry entry;
+    JarInputStream jarInput = null;
+
+    Manifest manifest;
+    try {
+      jarInput = new JarInputStream(isProvider.getInputStream());
+      scanForDependencies(jarInput);
+
+      // Add the new properties to the manifest byte stream
+      manifest = jarInput.getManifest();
+      manifest = updateManifest(manifest);
+    } 
+    finally {
+      try { if (jarInput != null) jarInput.close(); } catch (IOException e) { e.printStackTrace(); }
+    }
+
+    // Create a new jar file in memory with the new manifest and the old data
+    ByteArrayOutputStream output = new ByteArrayOutputStream();
+    JarOutputStream jarOutput = null;
+    jarInput = null;
+
+    // Copy across all entries from the original jar
+    int val;
+    try {
+      jarOutput = new JarOutputStream(output, manifest);
+      jarInput = new JarInputStream(isProvider.getInputStream());
+      while ((entry = jarInput.getNextEntry()) != null) {
+        jarOutput.putNextEntry(entry);
+        while ((val = jarInput.read()) != -1)
+          jarOutput.write(val);
+      }
+    }
+    finally {
+      if (jarOutput != null)
+        jarOutput.close();
+      if (jarInput != null)
+        jarInput.close();
+    }
+
+    // Create a stream to the in-memory jar
+    wabFile = output.toByteArray();
+  }
+
+  private void scanRecursive(final JarInputStream jarInput, boolean topLevel) throws IOException 
+  {
+    ZipEntry entry;
+    
+    while ((entry = jarInput.getNextEntry()) != null) {
+      fileNames.add(entry.getName());
+      if (entry.getName().endsWith(".class")) {
+        PackageFinder pkgFinder = new PackageFinder();
+        new ClassReader(jarInput).accept(pkgFinder, false);
+
+        importPackages.addAll(pkgFinder.getImportPackages());
+        exemptPackages.addAll(pkgFinder.getExemptPackages());
+      } else if (entry.getName().endsWith(".jsp")) { 
+        Collection<String> thisJSPsImports = JSPImportParser.getImports(jarInput);
+        importPackages.addAll(thisJSPsImports);
+      } else if (entry.getName().endsWith(".jar")) {
+        
+        JarInputStream newJar = new JarInputStream(new InputStream() {
+          @Override
+          public int read() throws IOException
+          {
+            return jarInput.read();
+          }
+        });
+        
+        // discard return, we only care about the top level jars
+        scanRecursive(newJar,false);
+        
+        // do not add jar embedded in already embedded jars
+        if (topLevel)
+          manifests.put(entry.getName(), newJar.getManifest());     
+      }
+    }
+  }
+  
+  /**
+   * 
+   * Read in the filenames inside the war (used for manifest update) Also
+   * analyse the bytecode of any .class files in order to find any required
+   * imports
+   */
+  private void scanForDependencies(final JarInputStream jarInput) throws IOException 
+  {
+    manifests = new HashMap<String, Manifest>();
+    
+    scanRecursive(jarInput, true);
+
+    // Process manifests from jars in order to work out classpath dependencies
+    ClassPathBuilder classPathBuilder = new ClassPathBuilder(manifests);
+    for (String fileName : manifests.keySet())
+      if (fileName.startsWith("WEB-INF/lib"))
+      {
+        classPath.add(fileName);
+        classPath = classPathBuilder.updatePath(fileName, classPath);
+      }
+        
+    // Remove packages that are part of the classes we searched through
+    for (String s : exemptPackages)
+      if (importPackages.contains(s))
+        importPackages.remove(s);
+  }
+
+  protected Manifest updateManifest(Manifest manifest) throws IOException
+  {
+    // If for some reason no manifest was generated, we start our own so that we don't null pointer later on
+    if (manifest == null) {
+      manifest = new Manifest();
+      manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1");
+    }
+    
+    // Compare the manifest and the supplied properties
+
+    //
+    // Bundle-Version
+    //
+
+    if (manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION) == null
+        && !properties.containsKey(Constants.BUNDLE_VERSION)) {
+      properties.put(Constants.BUNDLE_VERSION, DEFAULT_BUNDLE_VERSION);
+    }
+
+    //
+    // Bundle-ManifestVersion
+    //
+
+    if (manifest.getMainAttributes().getValue(Constants.BUNDLE_MANIFESTVERSION) == null
+        && !properties.containsKey(Constants.BUNDLE_MANIFESTVERSION)) {
+      properties.put(Constants.BUNDLE_MANIFESTVERSION,
+          DEFAULT_BUNDLE_MANIFESTVERSION);
+    }
+
+    //
+    // Bundle-SymbolicName
+    //
+
+    if (manifest.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME) == null
+        && !properties.containsKey(Constants.BUNDLE_SYMBOLICNAME)) {
+      properties.put(Constants.BUNDLE_SYMBOLICNAME, warName + "_"
+          + manifest.hashCode());
+    }
+
+    // 
+    // Bundle-ClassPath
+    //
+
+    ArrayList<String> classpath = new ArrayList<String>();
+
+    // Set initial entry into classpath
+    classpath.add(0, INITIAL_CLASSPATH_ENTRY);
+
+    // Add any files from the WEB-INF/lib directory + their dependencies
+    classpath.addAll(classPath);
+    
+    for (String s : fileNames)
+      if (s.startsWith(CLASSPATH_LIB_PREFIX) && !classpath.contains(s))
+        classpath.add(s);
+
+    // Get the list from the URL and add to classpath (removing duplicates)
+    mergePathList(properties.getProperty(Constants.BUNDLE_CLASSPATH),
+        classpath, ";");
+
+    // Get the existing list from the manifest file and add to classpath
+    // (removing duplicates)
+    mergePathList(manifest.getMainAttributes().getValue(
+        Constants.BUNDLE_CLASSPATH), classpath, ";");
+
+    // Construct the classpath string and set it into the properties
+    StringBuffer classPathValue = new StringBuffer();
+    for (String entry : classpath) {
+      classPathValue.append(";");
+      classPathValue.append(entry);
+    }
+
+    if (!classpath.isEmpty())
+      properties.put(Constants.BUNDLE_CLASSPATH, classPathValue.toString()
+          .substring(1));
+
+    ArrayList<String> packages = new ArrayList<String>() {
+      @Override
+      public boolean contains(Object elem) {
+        // Check for exact match of export list
+        if (super.contains(elem))
+          return true;
+
+        if (!!!(elem instanceof String))
+          return false;
+
+        String expPackageStmt = (String) elem;
+        String expPackage = expPackageStmt.split("\\s*;\\s*")[0];
+        
+        Pattern p = Pattern.compile("^\\s*"+Pattern.quote(expPackage)+"((;|\\s).*)?\\s*$");
+        for (String s : this) {
+          Matcher m = p.matcher(s);
+          if (m.matches()) {
+            return true;
+          }
+        }
+
+        return false;
+      }
+
+    };
+    
+    //
+    // Import-Package
+    //
+    packages.clear();
+
+    // Get the list from the URL and add to classpath (removing duplicates)
+    mergePathList(properties.getProperty(Constants.IMPORT_PACKAGE), packages,
+        ",");
+
+    // Get the existing list from the manifest file and add to classpath
+    // (removing duplicates)
+    mergePathList(manifest.getMainAttributes().getValue(
+        Constants.IMPORT_PACKAGE), packages, ",");
+
+    // Add the default set of packages
+    mergePathList(DEFAULT_IMPORT_PACKAGE_LIST, packages, ",");
+
+    // Analyse the bytecode of any .class files in the jar to find any other
+    // required imports
+    mergePathList(importPackages.toString().substring(1,
+        importPackages.toString().length() - 1), packages, ",");
+
+    // Construct the string and set it into the properties
+    StringBuffer importValues = new StringBuffer();
+    for (String entry : packages) {
+      importValues.append(",");
+      importValues.append(entry);
+    }
+    if (!packages.isEmpty())
+      properties.put(Constants.IMPORT_PACKAGE, importValues.toString()
+          .substring(1));
+
+    //
+    // Web-ContextPath
+    //
+
+    String webCPath = manifest.getMainAttributes().getValue(WEB_CONTEXT_PATH);
+    if (webCPath != null)
+    {
+      if (!webCPath.startsWith(DEFAULT_WEB_CONTEXT_PATH))
+      {
+          webCPath = DEFAULT_WEB_CONTEXT_PATH + webCPath;
+          properties.put(WEB_CONTEXT_PATH, webCPath);
+      }
+    }
+    else if ( !properties.containsKey(WEB_CONTEXT_PATH)) {
+      properties.put(WEB_CONTEXT_PATH, DEFAULT_WEB_CONTEXT_PATH);
+    }
+
+    //
+    // Web-JSPExtractLocation
+    //
+
+    if (manifest.getMainAttributes().getValue(WEB_JSP_EXTRACT_LOCATION) == null
+        && !properties.containsKey(WEB_JSP_EXTRACT_LOCATION)) {
+      properties
+          .put(WEB_JSP_EXTRACT_LOCATION, DEFAULT_WEB_JSP_EXTRACT_LOCATION);
+    }
+
+    // Take the properties map and add them to the manifest file
+    for (Object s : properties.keySet())
+      manifest.getMainAttributes().put(new Attributes.Name((String) s), properties.get(s));
+    
+    return manifest;
+  }
+
+  // pathlist = A "delim" delimitted list of path entries
+  public static void mergePathList(String pathlist, ArrayList<String> classpath,
+      String delim) {
+    if (pathlist != null) {
+      StringTokenizer tok = new StringTokenizer(pathlist, delim);
+      while (tok.hasMoreTokens()) {
+        String token = tok.nextToken().trim();
+        if (!classpath.contains(token))
+          classpath.add(token);
+      }
+    }
+  }
+
+  public InputStream getWAB() throws IOException {
+    if (!!!converted) {
+      convert();
+      converted = true;
+    }
+    
+    return new ByteArrayInputStream(wabFile);
+  }
+
+  public int getWabLength() throws IOException {
+    if (!!!converted) {
+      convert();
+      converted = true;
+    }
+
+    return wabFile.length;
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/src/com/ibm/osgi/web/util/WarToWabConverter.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/test.jar
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/test.jar?rev=820982&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/test.jar
------------------------------------------------------------------------------
    svn:executable = *

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/test.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml Fri Oct  2 11:59:28 2009
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Name: myCompany/myPackage/
+NewProperty: plop

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/test.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp Fri Oct  2 11:59:28 2009
@@ -0,0 +1,29 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<HTML>
+<HEAD>
+<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
+	pageEncoding="ISO-8859-1"%>
+<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
+<META name="GENERATOR" content="IBM Software Development Platform">
+<TITLE>helloWorld.jsp</TITLE>
+</HEAD>
+<BODY>
+<P>
+Hello world - from JSP! With JMS Import!
+xxx <%@ page import="javax.jms.*, javax.mystuff.SomeClass" %> <%@ page import = "javax.transaction.package" %>xxx
+<%@ page import="a.b.AClass" %>
+<%@ page import="a.b.AnotherClassInADotB" %>
+<%@ page import="java.util.List" %>
+
+<BR/><BR/>
+Here is a random number <%= Math.random() %>
+</P>
+
+<% 
+  JMSException jmsx = new JMSException ("reason");
+%>
+Here's an exception: <%= jmsx.toString() %>
+
+</BODY>
+</HTML>

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/JSPs/helloImport.jsp
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,63 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.test;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+import org.osgi.service.url.URLStreamHandlerSetter;
+
+import com.ibm.osgi.web.url.WAR_URLServiceHandler;
+
+public class MockProxyURLHandler extends URLStreamHandler
+{
+
+  MockURLStreamHandlerSetter urlSetter;
+  WAR_URLServiceHandler realHandler;
+
+  public MockProxyURLHandler()
+  {
+    realHandler = new WAR_URLServiceHandler();
+    urlSetter = new MockURLStreamHandlerSetter(this);
+  }
+
+  @Override
+  protected URLConnection openConnection(URL u) throws IOException
+  {
+    return realHandler.openConnection(u);
+  }
+
+  @Override
+  protected void parseURL(URL u, String spec, int start, int limit)
+  {
+    realHandler.parseURL(urlSetter, u, spec, start, limit);
+  }
+
+  class MockURLStreamHandlerSetter implements URLStreamHandlerSetter
+  {
+
+    MockProxyURLHandler handler;
+
+    public MockURLStreamHandlerSetter(MockProxyURLHandler handler)
+    {
+      this.handler = handler;
+    }
+
+    public void setURL(URL arg0, String arg1, String arg2, int arg3, String arg4, String arg5)
+    {
+      // deprecated
+
+    }
+
+    public void setURL(URL arg0, String arg1, String arg2, int arg3, String arg4, String arg5,
+        String arg6, String arg7, String arg8)
+    {
+      handler.setURL(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
+    }
+
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/MockProxyURLHandler.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,339 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.test;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLStreamHandler;
+import java.net.URLStreamHandlerFactory;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import org.osgi.framework.Constants;
+
+import org.junit.Test;
+
+import com.ibm.osgi.web.util.WarToWabConverter;
+
+public class URLHandlerTest
+{
+  private static final String urlScheme = "webbundle";
+
+  private static final String BUNDLE_VERSION_TEST_VALUE = "2.5";
+  private static final String BUNDLE_MANIFESTVERSION_TEST_VALUE = "3.5";
+  private static final String WEB_CONTEXT_PATH_TEST_VALUE = "../WebFiles";
+  private static final String WEB_JSP_EXTRACT_LOCATION_TEST_VALUE = "/";
+  private static final String BUNDLE_CLASSPATH_TEST_VALUE = "WEB-INF/classes/;WEB-INF/lib/test.jar;WEB-INF/test2/test2.jar;test3/test3.jar;WEB-INF/lib/;C:/TestDir1/TestFile1;TestDir2/TestFile2;TestDir3/TestFile3";
+  private static final String IMPORT_PACKAGE_TEST_VALUE = "com.ibm.test; version=2.5,com.ibm.test.eba; version=1.0,javax.servlet;version=2.5,javax.servlet.http;version=2.5,javax.el;version=2.1,javax.servlet.jsp;version=2.1,javax.servlet.jsp.el;version=2.1,javax.servlet.jsp.tagext;version=2.1,com.ibm.ws.ffdc";
+
+
+  private static boolean factoryDefined;
+
+  @Test
+  public void testSymbolicNameProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///" + new File("UrlHandlerTest.war").getAbsolutePath());
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(Constants.BUNDLE_SYMBOLICNAME);
+
+    // IN THIS TEST :
+    // No bundle property is specifed on the URL. No bundle property is in the manifest.
+    // We check a default value has been added
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(((String) manifestAttr.get(testProperty))
+        .startsWith("UrlHandlerTest"));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testWebContextPathProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///"+ new File("UrlHandlerTest.war").getAbsolutePath()
+        +"?Web-ContextPath=../WebFiles");
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(WarToWabConverter.WEB_CONTEXT_PATH);
+
+    // IN THIS TEST :
+    // Bundle property is specifed on the URL. No bundle property is in the manifest.
+    // We check a the url value is returned.
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(((String) manifestAttr.get(testProperty)).equals(WEB_CONTEXT_PATH_TEST_VALUE));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testJSPLocationProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///" + new File("UrlHandlerTest.war").getAbsolutePath());
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(WarToWabConverter.WEB_JSP_EXTRACT_LOCATION);
+
+    // IN THIS TEST :
+    // No bundle property is specifed on the URL. No bundle property is in the manifest.
+    // We check a default value has been added
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(((String) manifestAttr.get(testProperty))
+        .equals(WEB_JSP_EXTRACT_LOCATION_TEST_VALUE));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testBundleVersionProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///" + new File("UrlHandlerTest.war").getAbsolutePath());
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(Constants.BUNDLE_VERSION);
+
+    // IN THIS TEST :
+    // No bundle property is specifed on the URL. Bundle property IS in the manifest.
+    // We check the property is unchanged
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(((String) manifestAttr.get(testProperty)).equals(BUNDLE_VERSION_TEST_VALUE));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testBundleManifestVersProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///"+ new File("UrlHandlerTest.war").getAbsolutePath()
+        +"?Bundle-ManifestVersion=3.5");
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(Constants.BUNDLE_MANIFESTVERSION);
+
+    // IN THIS TEST :
+    // Bundle property IS specifed on the URL. Bundle property IS in the manifest.
+    // We check the property has been overridden
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(((String) manifestAttr.get(testProperty)).equals(BUNDLE_MANIFESTVERSION_TEST_VALUE));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testBundleClasspathProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL("webbundle:file:///"+ new File("UrlHandlerTest.war").getAbsolutePath()
+                        +"?Bundle-ClassPath=C:/TestDir1/TestFile1;TestDir2/TestFile2");
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(Constants.BUNDLE_CLASSPATH);
+
+    // IN THIS TEST :
+    // Bundle property IS specifed on the URL. Bundle property IS in the manifest.
+    // We check the property has been overridden
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+    
+    System.out.println(BUNDLE_CLASSPATH_TEST_VALUE);
+    System.out.println(manifestAttr.get(testProperty));
+
+    assertEquals(BUNDLE_CLASSPATH_TEST_VALUE, manifestAttr.get(testProperty));
+    
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+  @Test
+  public void testImportPackageProperty() throws Exception
+  {
+    // Override the default url factory and register the war url handler
+    // (and a file handler)
+    if (!factoryDefined) {
+      URL.setURLStreamHandlerFactory(new URLStreamHandlerFactory() {
+
+        public URLStreamHandler createURLStreamHandler(String protocol)
+        {
+          if (protocol.startsWith(urlScheme)) {
+            return new MockProxyURLHandler();
+          } else if (protocol.startsWith("file")) {
+            return new sun.net.www.protocol.file.Handler();
+          } else return null;
+        }
+      });
+      factoryDefined = true;
+    }
+
+    URL url = new URL(
+        "webbundle:file:///"+ new File("UrlHandlerTest.war").getAbsolutePath() + 
+          "?Import-Package=com.ibm.test; version=2.5,com.ibm.test.eba; version=1.0");
+
+    // Read in the wabFile and check the manifest
+    // Read in an existing war file
+    JarInputStream jarFile = new JarInputStream(url.openStream());
+    Attributes manifestAttr = jarFile.getManifest().getMainAttributes();
+    Attributes.Name testProperty = new Attributes.Name(Constants.IMPORT_PACKAGE);
+
+    // IN THIS TEST :
+    // Bundle property IS specifed on the URL. Bundle property IS in the manifest.
+    // We check the property has been overridden
+
+    // Check for existence of Bundle property
+    assertNotNull(manifestAttr.get(testProperty));
+
+    assertTrue(testProperty + ": " + manifestAttr.get(testProperty),((String) manifestAttr.get(testProperty)).equals(IMPORT_PACKAGE_TEST_VALUE));
+
+    System.out.println("Manifest Bundle Property ok, " + testProperty + ": "
+        + manifestAttr.get(testProperty));
+
+  }
+
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/test/URLHandlerTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,92 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import java.util.jar.Attributes;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+import java.util.zip.ZipEntry;
+
+import org.junit.Test;
+import org.osgi.framework.Constants;
+
+/**
+ * These tests do not cover the complete functionality (as yet). Rather this gives a place for adding
+ * smaller tests for individual units of work that don't need to be tested by converting a whole WAR file.
+ */
+public class WabConverterTest
+{
+  /**
+   * Test that we can handle a null manifest (in case a jar archive was created without manifest)
+   */
+  @Test
+  public void testNullManifest() throws Exception
+  {
+    WarToWabConverter sut = new WarToWabConverter(null, "test.war", new Properties());
+    
+    Manifest res = sut.updateManifest(null);
+    Attributes attrs = res.getMainAttributes();
+    
+    assertTrue(attrs.getValue("Import-Package").contains("javax.servlet"));
+  }
+  
+  @Test
+  public void testImportPackageMerge() throws Exception
+  {
+    WarToWabConverter sut = new WarToWabConverter(null, "test.war", new Properties());
+    
+    Manifest input = new Manifest();
+    input.getMainAttributes().putValue("Import-Package", "com.ibm.test,javax.servlet.http");
+    
+    Manifest res = sut.updateManifest(input);
+    Attributes attrs = res.getMainAttributes();
+    
+    assertEquals(
+        "com.ibm.test,"+
+        "javax.servlet.http,"+
+        "javax.servlet;version=2.5,"+
+        "javax.el;version=2.1,"+
+        "javax.servlet.jsp;version=2.1,"+
+        "javax.servlet.jsp.el;version=2.1,"+
+        "javax.servlet.jsp.tagext;version=2.1",
+        attrs.getValue("Import-Package"));
+  }
+  
+  @Test
+  public void testAcceptNoManifest() throws Exception
+  {
+    final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+    JarOutputStream out = new JarOutputStream(bout);
+    out.putNextEntry(new ZipEntry("random.html"));
+    out.write("hello world".getBytes());
+    out.close();
+    
+    Properties props = new Properties();
+    props.put(Constants.BUNDLE_SYMBOLICNAME, "test.bundle");
+    WarToWabConverter sut = new WarToWabConverter(new WarToWabConverter.InputStreamProvider() {
+      public InputStream getInputStream() throws IOException
+      {
+        return new ByteArrayInputStream(bout.toByteArray());
+      }      
+    }, "test.war", props);
+    
+    Manifest m = new JarInputStream(sut.getWAB()).getManifest();
+    assertEquals("test.bundle", m.getMainAttributes().getValue(Constants.BUNDLE_SYMBOLICNAME));
+  }
+  
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/WabConverterTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,29 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.osgi.web.util.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.FileInputStream;
+import java.util.Collection;
+
+import org.junit.Test;
+
+import com.ibm.osgi.web.util.JSPImportParser;
+
+public class JSPImportParserTest {
+
+  @Test
+  public void testJSPImportParser () throws Exception { 
+    FileInputStream helloImport = new FileInputStream ("unittest/JSPs/helloImport.jsp");
+    Collection<String> imports = JSPImportParser.getImports(helloImport);
+    assertTrue("Four imports expected", imports.size() == 4);
+    assertTrue(imports.contains("javax.jms"));
+    assertTrue(imports.contains("javax.mystuff"));
+    assertTrue(imports.contains("javax.transaction"));
+    assertTrue(imports.contains("a.b"));
+    assertFalse(imports.contains("java.util"));
+  }
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.osgi.web/unittest/com/ibm/osgi/web/util/test/JSPImportParserTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.aries
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.aries?rev=820982&view=auto
==============================================================================
    (empty)

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.aries
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath Fri Oct  2 11:59:28 2009
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="src" path="unittest"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
+	<classpathentry combineaccessrules="false" kind="src" path="/unittest.framework"/>
+	<classpathentry kind="output" path="build/classes"/>
+</classpath>

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.classpath
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project Fri Oct  2 11:59:28 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>com.ibm.ws.eba.app.utils</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/.project
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF Fri Oct  2 11:59:28 2009
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Utils Plug-in
+Bundle-SymbolicName: com.ibm.ws.eba.app.utils
+Bundle-Version: 1.0.0
+Bundle-Vendor: IBM
+Import-Package: org.osgi.framework
+Export-Package: com.ibm.ws.eba.app.utils,
+ com.ibm.websphere.application.aries

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/META-INF/MANIFEST.MF
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties Fri Oct  2 11:59:28 2009
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = build/classes/
+bin.includes = META-INF/,\
+               .

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.properties
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml Fri Oct  2 11:59:28 2009
@@ -0,0 +1,7 @@
+<!-- (C) Copyright IBM Corp. 2009 -->
+
+<project name="com.ibm.ws.eba.app.utils" default="build" basedir=".">
+  <property name="aries.image" value="true"/>
+  <property name="image.dir" value="waslib"/>
+  <import file="../build/imports/standard_imports.xml"/>
+</project>
\ No newline at end of file

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/build.xml
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF Fri Oct  2 11:59:28 2009
@@ -0,0 +1,10 @@
+Manifest-Version: 1.0
+Application-ManifestVersion: 1.0
+Application-Name: Travel Reservation
+Application-SymbolicName: com.travel.reservation
+Application-Version: 1.2
+Application-Content: com.travel.reservation.web;version="[1.1.0,1.2.0)",com.travel.reservation.business
+Export-Package: com.travel.reservation.api;version=1.2
+Import-Package: com.travel.flight.api;version="[2.1.1,3.0.0)",com.travel.rail.api;version="[1.0.0,2.0.0)"
+Application-Services: services.xml
+

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/myAppFolder/META-INF/APPLICATION.MF
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java
URL: http://svn.apache.org/viewvc/incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java?rev=820982&view=auto
==============================================================================
--- incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java (added)
+++ incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java Fri Oct  2 11:59:28 2009
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright IBM Corp. 2009
+ */
+package com.ibm.websphere.application.aries;
+
+import java.util.List;
+
+import org.osgi.framework.Version;
+
+/**
+ * this interface describes the Application.mf file
+ *
+ */
+public interface ApplicationMetadata
+{
+  /**
+   * get the value of the Application-SymbolicName header
+   * @return the value of the Application-SymbolicName header
+   */
+  public String getApplicationSymbolicName();
+  
+  /**
+   * get the value of the Application-Version header
+   * @return the value of the Application-Version header
+   */
+  public Version getApplicationVersion();
+  
+  /**
+   * get the name of the application
+   * @return the name of the application
+   */
+  public String getApplicationName();
+  /**
+   * get the list of Application contents includes bundle name, 
+   * version, directives and attributes
+   * @return the list of the Application contents 
+   */
+  public List<Content> getApplicationContents();
+  
+  /**
+   * get the value of the Export-Service header
+   * @return the list of ServiceDeclaration
+   */
+  public List<ServiceDeclaration> getApplicationExportServices();
+  
+  /**
+   * get the value of the Import-Service header
+   * @return the list of ServiceDeclaration
+   */
+  public List<ServiceDeclaration> getApplicationImportServices();  
+  
+  /**
+   * get the value of the Application-Scope, which is 
+   * calculated from Application-SymbolicName and Application-Version
+   * @return    the value of the AppScope
+   */
+  public String getApplicationScope();
+}

Propchange: incubator/aries/contrib/ibm/com.ibm.ws.eba.app.utils/src/com/ibm/websphere/application/aries/ApplicationMetadata.java
------------------------------------------------------------------------------
    svn:executable = *