You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2008/04/22 19:09:39 UTC
svn commit: r650577 [3/3] - in /servicemix/smx4/specs: ./ branches/ tags/
trunk/ trunk/jaxb-api/ trunk/jaxb-api/src/ trunk/jaxb-api/src/main/
trunk/jaxb-api/src/main/java/ trunk/jaxb-api/src/main/java/javax/
trunk/jaxb-api/src/main/java/javax/xml/ trun...
Added: servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/Activator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/Activator.java?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/Activator.java (added)
+++ servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/Activator.java Tue Apr 22 10:09:14 2008
@@ -0,0 +1,105 @@
+/*
+ **
+ ** Licensed to the Apache Software Foundation (ASF) under one
+ ** or more contributor license agreements. See the NOTICE file
+ ** distributed with this work for additional information
+ ** regarding copyright ownership. The ASF licenses this file
+ ** to you under the Apache License, Version 2.0 (the
+ ** "License"); you may not use this file except in compliance
+ ** with the License. You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing,
+ ** software distributed under the License is distributed on an
+ ** "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ** KIND, either express or implied. See the License for the
+ ** specific language governing permissions and limitations
+ ** under the License.
+ */
+package org.apache.servicemix.specs.locator;
+
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Enumeration;
+import java.util.concurrent.Callable;
+import java.net.URL;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleEvent;
+import org.osgi.framework.SynchronousBundleListener;
+import org.osgi.framework.Bundle;
+
+public class Activator implements BundleActivator, SynchronousBundleListener {
+
+ private BundleContext bundleContext;
+ private Map<Long, Map<String, Callable<Class>>> factories = new HashMap<Long, Map<String, Callable<Class>>>();
+
+ public synchronized void start(BundleContext bundleContext) throws Exception {
+ this.bundleContext = bundleContext;
+ bundleContext.addBundleListener(this);
+ for (Bundle bundle : bundleContext.getBundles()) {
+ register(bundle);
+ }
+ }
+
+ public synchronized void stop(BundleContext bundleContext) throws Exception {
+ while (!factories.isEmpty()) {
+ unregister(bundleContext.getBundle(factories.keySet().iterator().next()));
+ }
+ this.bundleContext = null;
+ }
+
+ public synchronized void bundleChanged(BundleEvent event) {
+ if (event.getType() == BundleEvent.RESOLVED) {
+ register(event.getBundle());
+ } else if (event.getType() == BundleEvent.UNRESOLVED) {
+ unregister(event.getBundle());
+ }
+ }
+
+ protected void register(final Bundle bundle) {
+ Map<String, Callable<Class>> map = factories.get(bundle.getBundleId());
+ Enumeration e = bundle.findEntries("META-INF/services/", "*", false);
+ if (e != null) {
+ while (e.hasMoreElements()) {
+ final URL u = (URL) e.nextElement();
+ final String url = u.toString();
+ if (url.endsWith("/")) {
+ continue;
+ }
+ final String factoryId = url.substring(url.lastIndexOf("/") + 1);
+ if (map == null) {
+ map = new HashMap<String, Callable<Class>>();
+ factories.put(bundle.getBundleId(), map);
+ }
+ map.put(factoryId, new Callable<Class>() {
+ public Class call() throws Exception {
+ BufferedReader br = new BufferedReader(new InputStreamReader(u.openStream(), "UTF-8"));
+ String factoryClassName = br.readLine();
+ br.close();
+ return bundle.loadClass(factoryClassName);
+ }
+ });
+ }
+ }
+ if (map != null) {
+ for (Map.Entry<String, Callable<Class>> entry : map.entrySet()) {
+ OsgiLocator.register(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+ protected void unregister(Bundle bundle) {
+ Map<String, Callable<Class>> map = factories.remove(bundle.getBundleId());
+ if (map != null) {
+ for (Map.Entry<String, Callable<Class>> entry : map.entrySet()) {
+ OsgiLocator.unregister(entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
+}
Added: servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java (added)
+++ servicemix/smx4/specs/trunk/locator/src/main/java/org/apache/servicemix/specs/locator/OsgiLocator.java Tue Apr 22 10:09:14 2008
@@ -0,0 +1,67 @@
+/*
+ **
+ ** Licensed to the Apache Software Foundation (ASF) under one
+ ** or more contributor license agreements. See the NOTICE file
+ ** distributed with this work for additional information
+ ** regarding copyright ownership. The ASF licenses this file
+ ** to you under the Apache License, Version 2.0 (the
+ ** "License"); you may not use this file except in compliance
+ ** with the License. You may obtain a copy of the License at
+ **
+ ** http://www.apache.org/licenses/LICENSE-2.0
+ **
+ ** Unless required by applicable law or agreed to in writing,
+ ** software distributed under the License is distributed on an
+ ** "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ ** KIND, either express or implied. See the License for the
+ ** specific language governing permissions and limitations
+ ** under the License.
+ */
+package org.apache.servicemix.specs.locator;
+
+import java.util.concurrent.Callable;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.ArrayList;
+
+public class OsgiLocator {
+
+ private static Map<String, List<Callable<Class>>> factories;
+
+ public static synchronized void unregister(String id, Callable<Class> factory) {
+ if (factories != null) {
+ List<Callable<Class>> l = factories.get(id);
+ if (l != null) {
+ l.remove(factory);
+ }
+ }
+ }
+
+ public static synchronized void register(String id, Callable<Class> factory) {
+ if (factories == null) {
+ factories = new HashMap<String, List<Callable<Class>>>();
+ }
+ List<Callable<Class>> l = factories.get(id);
+ if (l == null) {
+ l = new ArrayList<Callable<Class>>();
+ factories.put(id, l);
+ }
+ l.add(factory);
+ }
+
+ public static synchronized Class locate(String factoryId) {
+ if (factories != null) {
+ List<Callable<Class>> l = factories.get(factoryId);
+ if (l != null && !l.isEmpty()) {
+ Callable<Class> c = l.get(0);
+ try {
+ return c.call();
+ } catch (Exception e) {
+ }
+ }
+ }
+ return null;
+ }
+
+}
Added: servicemix/smx4/specs/trunk/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/pom.xml?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/pom.xml (added)
+++ servicemix/smx4/specs/trunk/pom.xml Tue Apr 22 10:09:14 2008
@@ -0,0 +1,376 @@
+<?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</groupId>
+ <artifactId>apache</artifactId>
+ <version>4</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>specs</artifactId>
+ <packaging>pom</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Apache ServiceMix Specs</name>
+ <inceptionYear>2007</inceptionYear>
+
+ <modules>
+ <module>locator</module>
+ <module>saaj-api</module>
+ <module>stax-api</module>
+ <module>jaxb-api</module>
+ <module>jaxws-api</module>
+ </modules>
+
+ <scm>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/servicemix/smx4/specs/trunk</developerConnection>
+ <url>http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/</url>
+ </scm>
+
+ <issueManagement>
+ <system>jira</system>
+ <url>http://issues.apache.org/activemq/browse/SM</url>
+ </issueManagement>
+
+ <prerequisites>
+ <maven>2.0.7</maven>
+ </prerequisites>
+
+ <properties>
+ <ant.version>1.7.0</ant.version>
+ <aopalliance.version>1.0</aopalliance.version>
+ <asm.version>2.2.3</asm.version>
+ <cglib.version>2.1_3</cglib.version>
+ <commons.io.version>1.3.2</commons.io.version>
+ <commons.logging.version>1.1.1</commons.logging.version>
+ <felix.configadmin.version>1.0.0</felix.configadmin.version>
+ <felix.main.version>1.0.3</felix.main.version>
+ <felix.plugin.version>1.4.0</felix.plugin.version>
+ <felix.framework.version>1.1.0-r631613</felix.framework.version>
+ <felix.osgi.version>1.0.0</felix.osgi.version>
+ <felix.compendium.version>1.0.0</felix.compendium.version>
+ <felix.bundlerepository.version>1.0.2</felix.bundlerepository.version>
+ <felix.prefs.version>1.0.2</felix.prefs.version>
+ <geronimo.activation.version>1.0.2</geronimo.activation.version>
+ <geronimo.saaj.version>1.0.0</geronimo.saaj.version>
+ <geronimo.servlet.version>1.1.2</geronimo.servlet.version>
+ <geronimo.stax.version>1.0.1</geronimo.stax.version>
+ <gshell.version>1.0-alpha-2-SNAPSHOT</gshell.version>
+ <junit.version>4.4</junit.version>
+ <jline.version>0.9.93</jline.version>
+ <log4j.version>1.2.14</log4j.version>
+ <mina.version>1.1.6</mina.version>
+ <pax.logging.version>1.0.0</pax.logging.version>
+ <pax.url.version>0.3.0</pax.url.version>
+ <servicemix.legal.version>1.0-SNAPSHOT</servicemix.legal.version>
+ <spring.osgi.version>1.0.2</spring.osgi.version>
+ <spring.version>2.5.2</spring.version>
+ <xstream.version>1.2.2</xstream.version>
+ </properties>
+
+ <repositories>
+ <!-- Default repository -->
+ <repository>
+ <id>central</id>
+ <name>Default maven repo</name>
+ <url>http://repo1.maven.org/maven2</url>
+ </repository>
+ <!-- ServiceMix repo -->
+ <repository>
+ <id>servicemix</id>
+ <name>Apache ServiceMix Repository</name>
+ <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <!-- ServiceMix repo -->
+ <pluginRepository>
+ <id>servicemix</id>
+ <name>Apache ServiceMix Repository</name>
+ <url>http://svn.apache.org/repos/asf/servicemix/m2-repo</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.servicemix.legal</groupId>
+ <artifactId>legal</artifactId>
+ <version>${servicemix.legal.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+
+ <pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-release-plugin</artifactId>
+ <version>2.0-beta-7</version>
+ <configuration>
+ <preparationGoals>clean,verify,install</preparationGoals>
+ <autoVersionSubmodules>true</autoVersionSubmodules>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>${felix.plugin.version}</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>2.0.2</version>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ <maxmem>256M</maxmem>
+ <fork>${compiler.fork}</fork>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-idea-plugin</artifactId>
+ <version>2.1</version>
+ <configuration>
+ <downloadSources>true</downloadSources>
+ <downloadJavadocs>true</downloadJavadocs>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.3.1</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-legal</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.apache.servicemix.legal</groupId>
+ <artifactId>legal</artifactId>
+ <version>${servicemix.legal.version}</version>
+ <type>xml</type>
+ <outputDirectory>target/legal/</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ <stripVersion>true</stripVersion>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-remote-resources-plugin</artifactId>
+ <version>1.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>process</goal>
+ </goals>
+ <configuration>
+ <resourceBundles>
+ <resourceBundle>org.apache:apache-jar-resource-bundle:1.4</resourceBundle>
+ </resourceBundles>
+ <supplementalModels>
+ <supplementalModel>target/legal/legal.xml</supplementalModel>
+ </supplementalModels>
+ <properties>
+ <addLicense>true</addLicense>
+ <addArtifact>true</addArtifact>
+ <projectName>Apache ServiceMix</projectName>
+ </properties>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jxr-plugin</artifactId>
+ <version>2.0</version>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <profiles>
+ <profile>
+ <id>fastinstall</id>
+ <properties>
+ <maven.test.skip>true</maven.test.skip>
+ </properties>
+ </profile>
+ <profile>
+ <id>rat</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>rat-maven-plugin</artifactId>
+ <version>1.0-alpha-3</version>
+ <executions>
+ <execution>
+ <phase>verify</phase>
+ <goals>
+ <goal>check</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <reportFile>${project.build.directory}/${project.build.finalName}.rat</reportFile>
+ <excludes>
+ <exclude>**/target/**/*</exclude>
+ <!-- IDEA files -->
+ <exclude>**/*.iml</exclude>
+ <exclude>**/*.ipr</exclude>
+ <exclude>**/*.iws</exclude>
+ <!-- Eclipse files -->
+ <exclude>**/.*</exclude>
+ <exclude>**/eclipse-classes/**/*</exclude>
+ </excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>release</id>
+ <build>
+ <plugins>
+ <!-- We want to deploy the artifact to a staging location for perusal -->
+ <plugin>
+ <inherited>true</inherited>
+ <artifactId>maven-deploy-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <altDeploymentRepository>${deploy.altRepository}</altDeploymentRepository>
+ <updateReleaseInfo>true</updateReleaseInfo>
+ </configuration>
+ </plugin>
+ <!-- We want to sign the artifact, the POM, and all attached artifacts -->
+ <plugin>
+ <artifactId>maven-gpg-plugin</artifactId>
+ <version>1.0-alpha-4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>sign</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>setup.eclipse</id>
+ <modules>
+ <module>assembly</module>
+ </modules>
+ <properties>
+ <eclipse.workspace.dir>${basedir}/../workspace</eclipse.workspace.dir>
+ </properties>
+ <build>
+ <defaultGoal>eclipse:eclipse</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-eclipse-plugin</artifactId>
+ <inherited>false</inherited>
+ <executions>
+ <execution>
+ <id>setup.eclipse.workspace</id>
+ <phase>process-test-sources</phase>
+ <goals>
+ <goal>add-maven-repo</goal>
+ </goals>
+ <configuration>
+ <workspace>${eclipse.workspace.dir}</workspace>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ <profile>
+ <id>deploy</id>
+ <build>
+ <defaultGoal>deploy</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-source-plugin</artifactId>
+ <version>2.0.4</version>
+ <executions>
+ <execution>
+ <id>attach-sources</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-javadocs</id>
+ <goals>
+ <goal>jar</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+</project>
Propchange: servicemix/smx4/specs/trunk/saaj-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 22 10:09:14 2008
@@ -0,0 +1,9 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+
+
Added: servicemix/smx4/specs/trunk/saaj-api/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/saaj-api/pom.xml?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/saaj-api/pom.xml (added)
+++ servicemix/smx4/specs/trunk/saaj-api/pom.xml Tue Apr 22 10:09:14 2008
@@ -0,0 +1,77 @@
+<?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.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.saaj-api-1.3</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Apache ServiceMix Specs :: SAAJ API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-saaj_1.3_spec</artifactId>
+ <version>${geronimo.saaj.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.locator</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Export-Package>javax.xml.soap*;version=1.3;-split-package:=merge-first</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Private-Package>org.apache.servicemix.specs.locator</Private-Package>
+ <Bundle-Activator>org.apache.servicemix.specs.locator.Activator</Bundle-Activator>
+ </instructions>
+ <unpackBundle>true</unpackBundle>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: servicemix/smx4/specs/trunk/saaj-api/src/main/java/javax/xml/soap/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/saaj-api/src/main/java/javax/xml/soap/FactoryFinder.java?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/saaj-api/src/main/java/javax/xml/soap/FactoryFinder.java (added)
+++ servicemix/smx4/specs/trunk/saaj-api/src/main/java/javax/xml/soap/FactoryFinder.java Tue Apr 22 10:09:14 2008
@@ -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.soap;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Properties;
+
+/**
+ * This class is used to locate factory classes for javax.xml.soap. It has package scope since it is
+ * not part of JAXM and should not be accessed from other packages.
+ */
+class FactoryFinder {
+ /**
+ * instantiates an object go the given classname.
+ *
+ * @param factoryClassName
+ * @return a factory object
+ * @throws SOAPException
+ */
+ private static Object newInstance(String factoryClassName) throws SOAPException {
+ ClassLoader classloader = null;
+ try {
+ classloader = Thread.currentThread().getContextClassLoader();
+ } catch (Exception exception) {
+ throw new SOAPException(exception.toString(), exception);
+ }
+
+ try {
+ Class factory = null;
+ if (classloader == null) {
+ factory = Class.forName(factoryClassName);
+ } else {
+ try {
+ factory = classloader.loadClass(factoryClassName);
+ } catch (ClassNotFoundException cnfe) {
+ }
+ }
+ if (factory == null) {
+ classloader = FactoryFinder.class.getClassLoader();
+ factory = classloader.loadClass(factoryClassName);
+ }
+ return factory.newInstance();
+ } catch (ClassNotFoundException classnotfoundexception) {
+ throw new SOAPException(
+ "Provider " + factoryClassName + " not found",
+ classnotfoundexception);
+ } catch (Exception exception) {
+ throw new SOAPException(
+ "Provider " + factoryClassName +
+ " could not be instantiated: " +
+ exception,
+ exception);
+ }
+ }
+
+ /**
+ * Instantiates a factory object given the factory's property name and the default class name.
+ *
+ * @param factoryPropertyName
+ * @param defaultFactoryClassName
+ * @return a factory object
+ * @throws SOAPException
+ */
+ static Object find(String factoryPropertyName,
+ String defaultFactoryClassName) throws SOAPException {
+ try {
+ // If we are deployed into an OSGi environment, leverage it
+ Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryPropertyName);
+ if (spiClass != null) {
+ return spiClass.newInstance();
+ }
+ } catch (Throwable e) {
+ }
+
+ try {
+ String factoryClassName = System.getProperty(factoryPropertyName);
+ if (factoryClassName != null) {
+ return newInstance(factoryClassName);
+ }
+ } catch (SecurityException securityexception) {
+ }
+
+ try {
+ String propertiesFileName = System.getProperty("java.home")
+ + File.separator + "lib"
+ + File.separator + "jaxm.properties";
+ File file = new File(propertiesFileName);
+ if (file.exists()) {
+ FileInputStream fileInput = new FileInputStream(file);
+ Properties properties = new Properties();
+ properties.load(fileInput);
+ fileInput.close();
+ String factoryClassName = properties.getProperty(
+ factoryPropertyName);
+ return newInstance(factoryClassName);
+ }
+ } catch (Exception exception1) {
+ }
+
+ String factoryResource = "META-INF/services/" + factoryPropertyName;
+
+ try {
+ InputStream inputstream = getResource(factoryResource);
+ if (inputstream != null) {
+ BufferedReader bufferedreader = new BufferedReader(
+ new InputStreamReader(inputstream, "UTF-8"));
+ String factoryClassName = bufferedreader.readLine();
+ bufferedreader.close();
+ if ((factoryClassName != null) && !"".equals(factoryClassName)) {
+ try {
+ return newInstance(factoryClassName);
+ } catch (Exception e) {
+ throw new SOAPException(
+ "Provider for " + factoryPropertyName + " cannot be found",
+ null);
+ }
+ }
+ }
+ } catch (Exception exception2) {
+ }
+
+ if (defaultFactoryClassName == null) {
+ throw new SOAPException(
+ "Provider for " + factoryPropertyName + " cannot be found",
+ null);
+ } else {
+ return newInstance(defaultFactoryClassName);
+ }
+ }
+
+ /**
+ * Returns an input stream for the specified resource.
+ * <p/>
+ * <p>This method will firstly try <code>ClassLoader.getSystemResourceAsStream()</code> then the
+ * class loader of the current thread with <code>getResourceAsStream()</code> and finally
+ * attempt <code>getResourceAsStream()</code> on <code>FactoryFinder.class.getClassLoader()</code>.
+ *
+ * @param factoryResource the resource name
+ * @return an InputStream that can be used to read that resource, or <code>null</code> if the
+ * resource could not be resolved
+ */
+ private static InputStream getResource(String factoryResource) {
+ ClassLoader classloader = null;
+ try {
+ classloader = Thread.currentThread().getContextClassLoader();
+ } catch (SecurityException securityexception) {
+ }
+
+ InputStream inputstream;
+ if (classloader == null) {
+ inputstream =
+ ClassLoader.getSystemResourceAsStream(factoryResource);
+ } else {
+ inputstream = classloader.getResourceAsStream(factoryResource);
+ }
+
+ if (inputstream == null) {
+ inputstream =
+ FactoryFinder.class.getClassLoader().getResourceAsStream(
+ factoryResource);
+ }
+ return inputstream;
+ }
+}
Propchange: servicemix/smx4/specs/trunk/stax-api/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Apr 22 10:09:14 2008
@@ -0,0 +1,9 @@
+target
+*.iml
+*.ipr
+*.iws
+.classpath
+.project
+.settings
+
+
Added: servicemix/smx4/specs/trunk/stax-api/pom.xml
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api/pom.xml?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api/pom.xml (added)
+++ servicemix/smx4/specs/trunk/stax-api/pom.xml Tue Apr 22 10:09:14 2008
@@ -0,0 +1,77 @@
+<?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.0-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
+ <packaging>bundle</packaging>
+ <version>1.0-SNAPSHOT</version>
+ <name>Apache ServiceMix Specs :: STAX API</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-stax-api_1.0_spec</artifactId>
+ <version>${geronimo.stax.version}</version>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.specs</groupId>
+ <artifactId>org.apache.servicemix.specs.locator</artifactId>
+ <version>${project.version}</version>
+ <optional>true</optional>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <executions>
+ <execution>
+ <goals>
+ <goal>bundle</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <instructions>
+ <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
+ <Export-Package>javax.xml.stream*;version=1.0;-split-package:=merge-first</Export-Package>
+ <Import-Package>*</Import-Package>
+ <Private-Package>org.apache.servicemix.specs.locator</Private-Package>
+ <Bundle-Activator>org.apache.servicemix.specs.locator.Activator</Bundle-Activator>
+ </instructions>
+ <unpackBundle>true</unpackBundle>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: servicemix/smx4/specs/trunk/stax-api/src/main/java/javax/xml/stream/FactoryLocator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/stax-api/src/main/java/javax/xml/stream/FactoryLocator.java?rev=650577&view=auto
==============================================================================
--- servicemix/smx4/specs/trunk/stax-api/src/main/java/javax/xml/stream/FactoryLocator.java (added)
+++ servicemix/smx4/specs/trunk/stax-api/src/main/java/javax/xml/stream/FactoryLocator.java Tue Apr 22 10:09:14 2008
@@ -0,0 +1,137 @@
+/*
+ **
+ ** 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.stream;
+
+import java.io.InputStream;
+import java.io.File;
+import java.io.FileInputStream;
+
+import java.util.Properties;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
+
+/*
+ * Here is the beef on the finding the Factory Class
+ *
+ * 1. Use the javax.xml.stream.XMLInputFactory system property. 2. Use the
+ * properties file "lib/stax.properties" in the JRE directory. This
+ * configuration file is in standard java.util.Properties format and contains
+ * the fully qualified name of the implementation class with the key being the
+ * system property defined above. 3. Use the Services API (as detailed in the
+ * JAR specification), if available, to determine the classname. The Services
+ * API will look for a classname in the file
+ * META-INF/services/javax.xml.stream.XMLInputFactory in jars available to the
+ * runtime. Platform default XMLInputFactory instance.
+ *
+ * If the user provided a classloader we'll use that...if not, we'll assume the
+ * classloader of this class.
+ */
+
+class FactoryLocator {
+ static Object locate(String factoryId) throws FactoryConfigurationError {
+ return locate(factoryId, null);
+ }
+
+ static Object locate(String factoryId, String altClassName)
+ throws FactoryConfigurationError {
+ return locate(factoryId, altClassName,
+ Thread.currentThread().getContextClassLoader());
+ }
+
+ static Object locate(String factoryId, String altClassName,
+ ClassLoader classLoader) throws FactoryConfigurationError {
+ try {
+ // If we are deployed into an OSGi environment, leverage it
+ Class spiClass = org.apache.servicemix.specs.locator.OsgiLocator.locate(factoryId);
+ if (spiClass != null) {
+ return spiClass.newInstance();
+ }
+ } catch (Throwable e) {
+ }
+
+ try {
+ String prop = System.getProperty(factoryId);
+ if (prop != null) {
+ return loadFactory(prop, classLoader);
+ }
+ } catch (Exception e) {
+ }
+
+ try {
+ String configFile = System.getProperty("java.home")
+ + File.separator + "lib" + File.separator
+ + "stax.properties";
+ File f = new File(configFile);
+ if (f.exists()) {
+ Properties props = new Properties();
+ props.load(new FileInputStream(f));
+ String factoryClassName = props.getProperty(factoryId);
+ return loadFactory(factoryClassName, classLoader);
+ }
+ } catch (Exception e) {
+ }
+
+ String serviceId = "META-INF/services/" + factoryId;
+ try {
+ InputStream is = null;
+
+ if (classLoader == null) {
+ is = ClassLoader.getSystemResourceAsStream(serviceId);
+ } else {
+ is = classLoader.getResourceAsStream(serviceId);
+ }
+
+ if (is != null) {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ is, "UTF-8"));
+ String factoryClassName = br.readLine();
+ br.close();
+
+ if (factoryClassName != null && !"".equals(factoryClassName)) {
+ return loadFactory(factoryClassName, classLoader);
+ }
+ }
+ } catch (Exception ex) {
+ }
+
+ if (altClassName == null) {
+ throw new FactoryConfigurationError("Unable to locate factory for "
+ + factoryId + ".", null);
+ }
+ return loadFactory(altClassName, classLoader);
+ }
+
+ private static Object loadFactory(String className, ClassLoader classLoader)
+ throws FactoryConfigurationError {
+ try {
+ Class factoryClass = classLoader == null ? Class.forName(className)
+ : classLoader.loadClass(className);
+
+ return factoryClass.newInstance();
+ } catch (ClassNotFoundException x) {
+ throw new FactoryConfigurationError("Requested factory "
+ + className + " cannot be located. Classloader ="
+ + classLoader.toString(), x);
+ } catch (Exception x) {
+ throw new FactoryConfigurationError("Requested factory "
+ + className + " could not be instantiated: " + x, x);
+ }
+ }
+}