[SMX4-663|SMX4-664]add jaxws-api-2.2 and jaxb-api-2.2 bundles

git-svn-id: https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk@1030852 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/jaxb-api-2.2/pom.xml b/jaxb-api-2.2/pom.xml
new file mode 100644
index 0000000..9062675
--- /dev/null
+++ b/jaxb-api-2.2/pom.xml
@@ -0,0 +1,185 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>specs</artifactId>
+        <version>1.6-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.specs</groupId>
+    <artifactId>org.apache.servicemix.specs.jaxb-api-2.2</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.6-SNAPSHOT</version>
+    <name>Apache ServiceMix :: Specs :: JAXB API 2.2</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.locator</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-activation_1.1_spec</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>javax.xml.bind</groupId>
+            <artifactId>jaxb-api</artifactId>
+            <version>2.2.1</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Export-Package>javax.xml.bind*;version=2.2.1;-split-package:=merge-first</Export-Package>
+                        <Import-Package>!javax.xml.bind*,*</Import-Package>
+                        <Private-Package>org.apache.servicemix.specs.locator;-split-package:=merge-first</Private-Package>
+                        <Bundle-Activator>org.apache.servicemix.specs.locator.Activator</Bundle-Activator>
+                        <Implementation-Title>Apache ServiceMix</Implementation-Title>
+                        <Implementation-Version>${project.version}</Implementation-Version>
+                    </instructions>
+                    <unpackBundle>true</unpackBundle>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <artifactSet>
+                                <includes>
+                                    <include>org.apache.servicemix.specs:org.apache.servicemix.specs.locator</include>
+                                    <include>javax.xml.bind:jaxb-api</include>
+                                </includes>
+                            </artifactSet>
+                            <filters>
+                                <filter>
+                                    <artifact>javax.xml.bind:jaxb-api</artifact>
+                                    <excludes>
+                                        <exclude>javax/**</exclude>
+                                    </excludes>
+                                </filter>
+                                <filter>
+                                    <artifact>org.apache.servicemix.specs:org.apache.servicemix.specs.locator</artifact>
+                                    <excludes>
+                                        <exclude>org/**</exclude>
+                                    </excludes>
+                                </filter>
+                            </filters>
+                            <createSourcesJar>${createSourcesJar}</createSourcesJar>
+                            <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+                            <createDependencyReducedPom>true</createDependencyReducedPom>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>deploy</id>
+            <properties>
+                <createSourcesJar>true</createSourcesJar>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-source-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>attach-sources</id>
+                                <phase>process-classes</phase>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-dependency-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>unpack-sources</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>unpack</goal>
+                                </goals>
+                                <configuration>
+                                    <artifactItems>
+                                        <artifactItem>
+                                            <groupId>org.apache.servicemix.specs</groupId>
+                                            <artifactId>org.apache.servicemix.specs.locator</artifactId>
+                                            <classifier>sources</classifier>
+                                        </artifactItem>
+                                    </artifactItems>
+                                    <outputDirectory>${project.build.directory}/sources</outputDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>package</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <minmemory>128m</minmemory>
+                            <maxmemory>512m</maxmemory>
+                            <sourcepath>${project.build.directory}/sources</sourcepath>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/jaxb-api-2.2/src/main/java/javax/xml/bind/ContextFinder.java b/jaxb-api-2.2/src/main/java/javax/xml/bind/ContextFinder.java
new file mode 100644
index 0000000..938b5aa
--- /dev/null
+++ b/jaxb-api-2.2/src/main/java/javax/xml/bind/ContextFinder.java
@@ -0,0 +1,184 @@
+/**
+ * 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 javax.xml.bind;
+
+import java.lang.reflect.Method;
+import java.util.Map;
+import java.util.Properties;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+class ContextFinder {
+
+    private static final String PLATFORM_DEFAULT_FACTORY_CLASS = "com.sun.xml.bind.v2.ContextFactory";
+    private static final String JAXB_CONTEXT_PROPERTY = JAXBContext.class.getName();
+    private static final String JAXB_CONTEXT_FACTORY = JAXBContext.JAXB_CONTEXT_FACTORY;
+
+    public static JAXBContext find(String contextPath, ClassLoader classLoader, Map properties) throws JAXBException {
+        String className = null;
+        // Patch for bug https://issues.apache.org/activemq/browse/SMX4-329
+        if (contextPath == null || contextPath.length() == 0) {
+            throw new JAXBException("Invalid contextPath (empty or null)");
+  	    }
+        String[] packages = contextPath.split(":");
+        if (packages == null || packages.length == 0) {
+            throw new JAXBException("Invalid contextPath (no packages)");
+        }
+        for (String pkg : packages) {
+            String url = pkg.replace('.', '/') + "/jaxb.properties";
+            className = loadClassNameFromProperties(url, classLoader);
+            if (className != null) {
+                break;
+            }
+        }
+        if (className == null) {
+            className = System.getProperty(JAXB_CONTEXT_PROPERTY);
+        }
+        if (className == null) {
+            String url = "META-INF/services/" + JAXB_CONTEXT_PROPERTY;
+            className = loadClassName(url, classLoader);
+        }
+        if (className == null) {
+            className = PLATFORM_DEFAULT_FACTORY_CLASS;
+        }
+        Class spi = loadSpi(className, classLoader);
+        try {
+            Method m = spi.getMethod("createContext", new Class[] { String.class, ClassLoader.class, Map.class });
+            return (JAXBContext) m.invoke(null, new Object[] { contextPath, classLoader, properties });
+        } catch (NoSuchMethodException e) {
+            // ignore
+        } catch (Throwable t) {
+            t.printStackTrace();
+            throw new JAXBException("Unable to create context", t);
+        } 
+        // Fallback for JAXB 1.0 compatibility (at least JAXB TCK tests are using that feature)
+        try {
+            Method m = spi.getMethod("createContext", new Class[] { String.class, ClassLoader.class, });
+            return (JAXBContext) m.invoke(null, new Object[] { contextPath, classLoader });
+        } catch (Throwable t) {
+            throw new JAXBException("Unable to create context", t);
+        }
+    }
+
+
+    public static JAXBContext find(Class[] classes, Map properties) throws JAXBException {
+        String className = null;
+        for (Class cl : classes) {
+            Package pkg = cl.getPackage();
+            if (pkg != null) {
+                String url = pkg.getName().replace('.', '/') + "/jaxb.properties";
+                className = loadClassNameFromProperties(url, cl.getClassLoader());
+                if (className != null) {
+                    break;
+                }
+            }
+        }
+        if (className == null) {
+            className = System.getProperty(JAXB_CONTEXT_PROPERTY);
+        }
+        if (className == null) {
+            String url = "META-INF/services/" + JAXB_CONTEXT_PROPERTY;
+            className = loadClassName(url, Thread.currentThread().getContextClassLoader());
+        }
+        if (className == null) {
+            className = PLATFORM_DEFAULT_FACTORY_CLASS;
+        }
+        Class spi = loadSpi(className, Thread.currentThread().getContextClassLoader());
+        try {
+            Method m = spi.getMethod("createContext", new Class[] { Class[].class, Map.class });
+            return (JAXBContext) m.invoke(null, new Object[] { classes, properties });
+        } catch (Throwable t) {
+            throw new JAXBException("Unable to create context", t);
+        }
+    }
+
+    private static String loadClassNameFromProperties(String url, ClassLoader classLoader) throws JAXBException {
+        try {
+            InputStream is;
+            if (classLoader != null) {
+                is = classLoader.getResourceAsStream(url);
+            } else {
+                is = ClassLoader.getSystemResourceAsStream(url);
+            }
+            if (is != null) {
+                try {
+                    Properties props = new Properties();
+                    props.load(is);
+                    String className = props.getProperty(JAXB_CONTEXT_FACTORY);
+                    if (className == null) {
+                        throw new JAXBException("jaxb.properties file " + url + " should contain a " + JAXB_CONTEXT_FACTORY + " property");
+                    }
+                    return className.trim();
+                } finally {
+                    is.close();
+                }
+            } else {
+                return null;
+            }
+        } catch (IOException e) {
+            throw new JAXBException(e);
+        }
+    }
+
+    private static String loadClassName(String url, ClassLoader classLoader) throws JAXBException {
+        try {
+            InputStream is;
+            if (classLoader != null) {
+                is = classLoader.getResourceAsStream(url);
+            } else {
+                is = ClassLoader.getSystemResourceAsStream(url);
+            }
+            if (is != null) {
+                try {
+                    BufferedReader r = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                    return r.readLine().trim();
+                } finally {
+                    is.close();
+                }
+            }
+            return null;
+        } catch (IOException e) {
+            throw new JAXBException(e);
+        }
+    }
+
+    private static Class loadSpi(String className, ClassLoader classLoader) throws JAXBException {
+        Class spiClass;
+        try {
+            spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(JAXBContext.class.getName());
+            if (spiClass != null) {
+                return spiClass;
+            }
+        } catch (Throwable t) {
+        }
+        try {
+            if (classLoader != null) {
+                spiClass = classLoader.loadClass(className);
+            } else {
+                spiClass = Class.forName(className);
+            }
+        } catch (ClassNotFoundException e) {
+            throw new JAXBException("Provider " + className + " not found", e);
+        }
+        return spiClass;
+    }
+
+
+}
+
diff --git a/jaxws-api-2.2/pom.xml b/jaxws-api-2.2/pom.xml
new file mode 100644
index 0000000..941030e
--- /dev/null
+++ b/jaxws-api-2.2/pom.xml
@@ -0,0 +1,183 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+
+    <!--
+
+        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.
+    -->
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.servicemix.specs</groupId>
+        <artifactId>specs</artifactId>
+        <version>1.6-SNAPSHOT</version>
+    </parent>
+
+    <groupId>org.apache.servicemix.specs</groupId>
+    <artifactId>org.apache.servicemix.specs.jaxws-api-2.2</artifactId>
+    <packaging>bundle</packaging>
+    <version>1.6-SNAPSHOT</version>
+    <name>Apache ServiceMix :: Specs :: JAXWS API 2.2</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+            <version>1.0</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-saaj_1.3_spec</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-stax_1.0_spec</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.apache.geronimo.specs</groupId>
+                    <artifactId>geronimo-activation_1.1_spec</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>javax.xml.bind</groupId>
+                    <artifactId>jaxb-api</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.jaxb-api-2.1</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.saaj-api-1.3</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.servicemix.specs</groupId>
+            <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
+            <version>${pom.version}</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <configuration>
+                    <instructions>
+                        <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+                        <Export-Package>javax.xml.ws*;version=2.2;-split-package:=merge-first</Export-Package>
+                        <Import-Package>!javax.xml.ws*,org.apache.geronimo.osgi.registry.api;resolution:=optional,*</Import-Package>
+                        <Private-Package>org.apache.geronimo.osgi.locator</Private-Package>
+                        <Bundle-Activator>org.apache.geronimo.osgi.locator.Activator</Bundle-Activator>
+                        <Implementation-Title>Apache ServiceMix</Implementation-Title>
+                        <Implementation-Version>${project.version}</Implementation-Version>
+                    </instructions>
+                    <unpackBundle>true</unpackBundle>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <artifactSet>
+                                <includes>
+                                    <include>org.apache.geronimo.specs:geronimo-jaxws_2.2_spec</include>
+                                </includes>
+                            </artifactSet>
+                            <filters>
+                                <filter>
+                                    <artifact>org.apache.geronimo.specs:geronimo-jaxws_2.2_spec</artifact>
+                                    <excludes>
+                                        <exclude>javax/**</exclude>
+                                        <exclude>org/apache/geronimo/osgi/locator/**</exclude>
+                                    </excludes>
+                                </filter>
+                            </filters>
+                            <createSourcesJar>${createSourcesJar}</createSourcesJar>
+                            <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+                            <createDependencyReducedPom>true</createDependencyReducedPom>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+    <profiles>
+        <profile>
+            <id>deploy</id>
+            <properties>
+                <createSourcesJar>true</createSourcesJar>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-dependency-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>unpack-sources</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>unpack</goal>
+                                </goals>
+                                <configuration>
+                                    <artifactItems>
+                                        <artifactItem>
+                                            <groupId>org.apache.geronimo.specs</groupId>
+                                            <artifactId>geronimo-jaxws_2.2_spec</artifactId>
+                                            <classifier>sources</classifier>
+                                        </artifactItem>
+                                    </artifactItems>
+                                    <outputDirectory>${project.build.directory}/sources</outputDirectory>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-javadoc-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <id>package</id>
+                                <phase>package</phase>
+                                <goals>
+                                    <goal>jar</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <minmemory>128m</minmemory>
+                            <maxmemory>512m</maxmemory>
+                            <sourcepath>${project.build.directory}/sources</sourcepath>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/pom.xml b/pom.xml
index 7923c9e..f9cfc5d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,10 +42,12 @@
         <module>jain-sip-api-1.2</module>
         <module>jaxb-api-2.0</module>
         <module>jaxb-api-2.1</module>
+        <module>jaxb-api-2.2</module>
         <module>jaxp-api-1.3</module>
         <module>jaxp-api-1.4</module>
         <module>jaxws-api-2.0</module>
         <module>jaxws-api-2.1</module>
+        <module>jaxws-api-2.2</module>
         <module>jbi-api-1.0</module>
         <module>scripting-api-1.0</module>
         <module>jsr250-1.0</module>