servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r664660 - in /servicemix/smx4/specs/trunk: jaxb-api-2.0/src/main/java/javax/xml/bind/ jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/ jaxb-api-2.1/src/main/java/javax/xml/bind/ jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/ jax...
Date Mon, 09 Jun 2008 08:48:42 GMT
Author: gnodet
Date: Mon Jun  9 01:48:42 2008
New Revision: 664660

URL: http://svn.apache.org/viewvc?rev=664660&view=rev
Log:
Fix jaxb specs and jaxws FactoryFinder

Modified:
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/JAXBContext.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Unmarshaller.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Validator.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElement.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java
    servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlEnum.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXBContext.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Unmarshaller.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Validator.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElement.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementWrapper.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlEnum.java
    servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlTransient.java
    servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
    servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/JAXBContext.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/JAXBContext.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/JAXBContext.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/JAXBContext.java Mon Jun  9 01:48:42 2008
@@ -46,7 +46,6 @@
 
     public abstract Unmarshaller createUnmarshaller() throws JAXBException;
 
-    @Deprecated
     public abstract Validator createValidator() throws JAXBException;
 
     public void generateSchema(SchemaOutputResolver resolver) throws IOException {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Unmarshaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Unmarshaller.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Unmarshaller.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Unmarshaller.java Mon Jun  9 01:48:42 2008
@@ -55,7 +55,6 @@
 
     UnmarshallerHandler getUnmarshallerHandler();
 
-    @Deprecated
     boolean isValidating() throws JAXBException;
 
     <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter);
@@ -72,7 +71,6 @@
 
     void setSchema(Schema schema);
 
-    @Deprecated
     void setValidating(boolean validating) throws JAXBException;
 
     Object unmarshal(File f) throws JAXBException;

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Validator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Validator.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Validator.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/Validator.java Mon Jun  9 01:48:42 2008
@@ -16,24 +16,18 @@
  */
 package javax.xml.bind;
 
-@Deprecated
 public interface Validator {
 
-    @Deprecated
     ValidationEventHandler getEventHandler() throws JAXBException;
 
-    @Deprecated
     Object getProperty(String name) throws PropertyException;
 
-    @Deprecated
     void setEventHandler(ValidationEventHandler handler) throws JAXBException;
 
-    @Deprecated
     void setProperty(String name, Object value) throws PropertyException;
 
-    @Deprecated
     boolean validate(Object subRoot) throws JAXBException;
 
-    @Deprecated
     boolean validateRoot(Object rootObj) throws JAXBException;
+
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java Mon Jun  9 01:48:42 2008
@@ -16,11 +16,13 @@
  */
 package javax.xml.bind.annotation;
 
+import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.annotation.ElementType;
 
+@Inherited
 @Retention(RetentionPolicy.RUNTIME)
 @Target(value  = {ElementType.PACKAGE, ElementType.TYPE })
 public @interface XmlAccessorType {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElement.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElement.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElement.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElement.java Mon Jun  9 01:48:42 2008
@@ -22,7 +22,7 @@
 import java.lang.annotation.ElementType;
 
 @Retention(RetentionPolicy.RUNTIME)
-@Target(value  = {ElementType.TYPE, ElementType.METHOD })
+@Target(value  = {ElementType.FIELD, ElementType.METHOD })
 public @interface XmlElement {
 
     final class DEFAULT {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java Mon Jun  9 01:48:42 2008
@@ -32,8 +32,6 @@
 
     Class scope() default GLOBAL.class;
 
-    String defautValue() default "##default";
-
     String namespace() default "##default";
 
     String substitutionHeadNamespace() default "##default";

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlEnum.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlEnum.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlEnum.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.0/src/main/java/javax/xml/bind/annotation/XmlEnum.java Mon Jun  9 01:48:42 2008
@@ -25,5 +25,5 @@
 @Target(ElementType.TYPE)
 public @interface XmlEnum {
 
-    Class value() default String.class;
+    Class<?> value() default String.class;
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXBContext.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXBContext.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXBContext.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/JAXBContext.java Mon Jun  9 01:48:42 2008
@@ -46,7 +46,6 @@
 
     public abstract Unmarshaller createUnmarshaller() throws JAXBException;
 
-    @Deprecated
     public abstract Validator createValidator() throws JAXBException;
 
     public void generateSchema(SchemaOutputResolver resolver) throws IOException {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Unmarshaller.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Unmarshaller.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Unmarshaller.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Unmarshaller.java Mon Jun  9 01:48:42 2008
@@ -55,7 +55,6 @@
 
     UnmarshallerHandler getUnmarshallerHandler();
 
-    @Deprecated
     boolean isValidating() throws JAXBException;
 
     <A extends XmlAdapter> void setAdapter(Class<A> type, A adapter);
@@ -72,7 +71,6 @@
 
     void setSchema(Schema schema);
 
-    @Deprecated
     void setValidating(boolean validating) throws JAXBException;
 
     Object unmarshal(File f) throws JAXBException;

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Validator.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Validator.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Validator.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/Validator.java Mon Jun  9 01:48:42 2008
@@ -16,24 +16,18 @@
  */
 package javax.xml.bind;
 
-@Deprecated
 public interface Validator {
 
-    @Deprecated
     ValidationEventHandler getEventHandler() throws JAXBException;
 
-    @Deprecated
     Object getProperty(String name) throws PropertyException;
 
-    @Deprecated
     void setEventHandler(ValidationEventHandler handler) throws JAXBException;
 
-    @Deprecated
     void setProperty(String name, Object value) throws PropertyException;
 
-    @Deprecated
     boolean validate(Object subRoot) throws JAXBException;
 
-    @Deprecated
     boolean validateRoot(Object rootObj) throws JAXBException;
+
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlAccessorType.java Mon Jun  9 01:48:42 2008
@@ -16,11 +16,13 @@
  */
 package javax.xml.bind.annotation;
 
+import java.lang.annotation.Inherited;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.lang.annotation.ElementType;
 
+@Inherited
 @Retention(RetentionPolicy.RUNTIME)
 @Target(value  = {ElementType.PACKAGE, ElementType.TYPE })
 public @interface XmlAccessorType {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElement.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElement.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElement.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElement.java Mon Jun  9 01:48:42 2008
@@ -22,7 +22,7 @@
 import java.lang.annotation.ElementType;
 
 @Retention(RetentionPolicy.RUNTIME)
-@Target(value  = {ElementType.TYPE, ElementType.METHOD })
+@Target(value  = {ElementType.FIELD, ElementType.METHOD })
 public @interface XmlElement {
 
     final class DEFAULT {

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementDecl.java Mon Jun  9 01:48:42 2008
@@ -32,8 +32,6 @@
 
     Class scope() default GLOBAL.class;
 
-    String defautValue() default "##default";
-
     String namespace() default "##default";
 
     String substitutionHeadNamespace() default "##default";
@@ -41,4 +39,5 @@
     String substitutionHeadName() default "";
 
     String defaultValue() default "\u0000";
+
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementWrapper.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementWrapper.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementWrapper.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlElementWrapper.java Mon Jun  9 01:48:42 2008
@@ -30,4 +30,7 @@
     String namespace() default "##default";
 
     boolean nillable() default false;
+
+    boolean required() default false;
+
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlEnum.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlEnum.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlEnum.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlEnum.java Mon Jun  9 01:48:42 2008
@@ -25,5 +25,5 @@
 @Target(ElementType.TYPE)
 public @interface XmlEnum {
 
-    Class value() default String.class;
+    Class<?> value() default String.class;
 }

Modified: servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlTransient.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlTransient.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlTransient.java (original)
+++ servicemix/smx4/specs/trunk/jaxb-api-2.1/src/main/java/javax/xml/bind/annotation/XmlTransient.java Mon Jun  9 01:48:42 2008
@@ -22,6 +22,6 @@
 import java.lang.annotation.ElementType;
 
 @Retention(RetentionPolicy.RUNTIME)
-@Target(value = {ElementType.FIELD, ElementType.METHOD})
+@Target(value = {ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
 public @interface XmlTransient {
 }

Modified: servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java (original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.0/src/main/java/javax/xml/ws/spi/FactoryFinder.java Mon Jun  9 01:48:42 2008
@@ -1,112 +1,301 @@
-/**
- * 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
+/*
+ * 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
+ * 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.
+ * 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.ws.spi;
 
-import java.io.InputStream;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
-
-import java.util.Properties;
-import java.io.BufferedReader;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+import java.util.Properties;
 
-import javax.xml.ws.WebServiceException;
-
+/**
+ * This code is designed to implement the pluggability
+ * feature and is designed to both compile and run on JDK version 1.1 and
+ * later.  The code also runs both as part of an unbundled jar file and
+ * when bundled as part of the JDK.
+ * <p/>
+ * This class is duplicated for each subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXRPC
+ * API.
+ */
 class FactoryFinder {
-	static Object locate(String factoryId) {
-		return locate(factoryId, null);
-	}
-
-	static Object locate(String factoryId, String altClassName) {
-		return locate(factoryId, altClassName, Thread.currentThread().getContextClassLoader());
-	}
-
-	static Object locate(String factoryId, String altClassName, ClassLoader classLoader) {
-        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) {
+    /**
+     * Set to true for debugging.
+     */
+    private static final boolean debug = false;
+
+    private static void debugPrintln(String msg) {
+        if (debug) {
+            System.err.println("Factory Finder:" + msg);
         }
+    }
 
-		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) {
-		}
-
-        try {
-            String configFile = System.getProperty("java.home")
-                    + File.separator + "lib" + File.separator
-                    + "jaxws.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);
+    /**
+     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
+     * the context ClassLoader.
+     *
+     * @return the <code>ClassLoader</code>
+     * @throws ConfigurationError if this class is unable to work with the
+     *                            host JDK
+     */
+    private static ClassLoader findClassLoader()
+            throws ConfigurationError {
+        // REVIEW This doPriv block may be unnecessary because this method is private and 
+        // the caller already has a doPriv.  I added the doPriv in case someone changes the 
+        // visibility of this method to non-private.
+        ClassLoader cl = (ClassLoader)
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                
+                    Method m = null;
+
+                    try {
+
+                        m = Thread.class.getMethod("getContextClassLoader", (Class []) null);
+                    } catch (NoSuchMethodException e) {
+                        // Assume that we are running JDK 1.1, use the current ClassLoader
+                        debugPrintln("assuming JDK 1.1");
+                        return FactoryFinder.class.getClassLoader();
+                    }
+
+                    try {
+                        return (ClassLoader) m.invoke(Thread.currentThread(), (Object []) null);
+                    } catch (IllegalAccessException e) {
+                        // assert(false)
+                        throw new ConfigurationError("Unexpected IllegalAccessException",
+                                e);
+                    } catch (InvocationTargetException e) {
+                        // assert(e.getTargetException() instanceof SecurityException)
+                        throw new ConfigurationError("Unexpected InvocationTargetException",
+                                e);
+                    }
+                }
             }
-        } catch (Exception e) {
+        );
+        return cl;
+        
+    }
+
+    /**
+     * Create an instance of a class using the specified
+     * <code>ClassLoader</code>, or if that fails from the
+     * <code>ClassLoader</code> that loaded this class.
+     *
+     * @param className   the name of the class to instantiate
+     * @param classLoader a <code>ClassLoader</code> to load the class from
+     * @return a new <code>Object</code> that is an instance of the class of
+     *         the given name from the given class loader
+     * @throws ConfigurationError if the class could not be found or
+     *                            instantiated
+     */
+    private static Object newInstance(String className,
+                                      ClassLoader classLoader)
+            throws ConfigurationError {
+        
+        final ClassLoader iClassLoader = classLoader;
+        final String iClassName = className;
+        
+        // REVIEW This doPriv block may be unnecessary because this method is private and 
+        // the caller already has a doPriv.  I added the doPriv in case someone changes the 
+        // visibility of this method to non-private.
+        Object obj = 
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                    try {
+                        if (iClassLoader != null) {
+                            try {
+                                return iClassLoader.loadClass(iClassName).newInstance();
+                            } catch (ClassNotFoundException x) {
+                                // try again
+                            }
+                        }
+                        return Class.forName(iClassName).newInstance();
+                    } catch (ClassNotFoundException x) {
+                        throw new ConfigurationError(
+                                "Provider " + iClassName + " not found", x);
+                    } catch (Exception x) {
+                        throw new ConfigurationError(
+                                "Provider " + iClassName + " could not be instantiated: " + x,
+                                x);
+                    }
+                }
+            });
+        return obj;
+    }
+
+    /**
+     * Finds the implementation Class object in the specified order.  Main
+     * entry point.
+     *
+     * @param factoryId         Name of the factory to find, same as
+     *                          a property name
+     * @param fallbackClassName Implementation class name, if nothing else
+     *                          is found.  Use null to mean no fallback.
+     * @return Class object of factory, never null
+     * @throws FactoryFinder.ConfigurationError
+     *          Package private so this code can be shared.
+     */
+    static Object find(String factoryId, String fallbackClassName)
+            throws ConfigurationError {
+        
+        final String iFactoryId = factoryId;
+        final String iFallbackClassName = fallbackClassName;
+        
+        Object obj = 
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                    debugPrintln("debug is on");
+                    
+                    ClassLoader classLoader = findClassLoader();
+                    
+			        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) {
+			        }
+			
+                    // Use the system property first
+                    try {
+                        String systemProp =
+                            System.getProperty(iFactoryId);
+                        if (systemProp != null) {
+                            debugPrintln("found system property " + systemProp);
+                            return newInstance(systemProp, classLoader);
+                        }
+                    } catch (SecurityException se) {
+                    }
+                    
+                    // try to read from $java.home/lib/xml.properties
+                    try {
+                        String javah = System.getProperty("java.home");
+                        String configFile = javah + File.separator +
+                        "lib" + File.separator + "jaxrpc.properties";
+                        File f = new File(configFile);
+                        if (f.exists()) {
+                            Properties props = new Properties();
+                            props.load(new FileInputStream(f));
+                            String factoryClassName = props.getProperty(iFactoryId);
+                            debugPrintln("found java.home property " + factoryClassName);
+                            return newInstance(factoryClassName, classLoader);
+                        }
+                    } catch (Exception ex) {
+                        if (debug) ex.printStackTrace();
+                    }
+                    
+                    String serviceId = "META-INF/services/" + iFactoryId;
+                    // try to find services in CLASSPATH
+                    try {
+                        InputStream is = null;
+                        if (classLoader == null) {
+                            is = ClassLoader.getSystemResourceAsStream(serviceId);
+                        } else {
+                            is = classLoader.getResourceAsStream(serviceId);
+                        }
+                        
+                        if (is != null) {
+                            debugPrintln("found " + serviceId);
+                            
+                            // Read the service provider name in UTF-8 as specified in
+                            // the jar spec.  Unfortunately this fails in Microsoft
+                            // VJ++, which does not implement the UTF-8
+                            // encoding. Theoretically, we should simply let it fail in
+                            // that case, since the JVM is obviously broken if it
+                            // doesn't support such a basic standard.  But since there
+                            // are still some users attempting to use VJ++ for
+                            // development, we have dropped in a fallback which makes a
+                            // second attempt using the platform's default encoding. In
+                            // VJ++ this is apparently ASCII, which is a subset of
+                            // UTF-8... and since the strings we'll be reading here are
+                            // also primarily limited to the 7-bit ASCII range (at
+                            // least, in English versions), this should work well
+                            // enough to keep us on the air until we're ready to
+                            // officially decommit from VJ++. [Edited comment from
+                            // jkesselm]
+                            BufferedReader rd;
+                            try {
+                                rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                            } catch (java.io.UnsupportedEncodingException e) {
+                                rd = new BufferedReader(new InputStreamReader(is));
+                            }
+                            
+                            String factoryClassName = rd.readLine();
+                            rd.close();
+                            
+                            if (factoryClassName != null &&
+                                    ! "".equals(factoryClassName)) {
+                                debugPrintln("loaded from services: " + factoryClassName);
+                                return newInstance(factoryClassName, classLoader);
+                            }
+                        }
+                    } catch (Exception ex) {
+                        if (debug) ex.printStackTrace();
+                    }
+                    
+                    if (iFallbackClassName == null) {
+                        throw new ConfigurationError(
+                                "Provider for " + iFactoryId + " cannot be found", null);
+                    }
+                    
+                    debugPrintln("loaded from fallback value: " + iFallbackClassName);
+                    return newInstance(iFallbackClassName, classLoader);
+                }
+            });
+        return obj;
+    }
+
+    private static Object doPrivileged(PrivilegedAction action) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm == null) {
+            return(action.run());
+        } else {
+            return java.security.AccessController.doPrivileged(action);
+        }
+    }
+
+    static class ConfigurationError extends Error {
+        // fixme: should this be refactored to use the jdk1.4 exception
+        // wrapping?
+
+        private Exception exception;
+
+        /**
+         * Construct a new instance with the specified detail string and
+         * exception.
+         *
+         * @param msg the Message for this error
+         * @param x   an Exception that caused this failure, or null
+         */
+        ConfigurationError(String msg, Exception x) {
+            super(msg);
+            this.exception = x;
         }
 
-        try {
-			String prop = System.getProperty(factoryId);
-			if (prop != null) {
-				return loadFactory(prop, classLoader);
-			}
-		} catch (Exception e) {
-		}
-
-		if (altClassName == null) {
-			throw new WebServiceException("Unable to locate factory for " + factoryId + ".", null);
-		}
-		return loadFactory(altClassName, classLoader);
-	}
-
-	private static Object loadFactory(String className, ClassLoader classLoader) {
-		try {
-			Class factoryClass = classLoader == null ? Class.forName(className)
-					                                 : classLoader.loadClass(className);
-			return factoryClass.newInstance();
-		} catch (ClassNotFoundException x) {
-			throw new WebServiceException("Requested factory "
-					+ className + " cannot be located.  Classloader ="
-					+ classLoader.toString(), x);
-		} catch (Exception x) {
-			throw new WebServiceException("Requested factory "
-					+ className + " could not be instantiated: " + x, x);
-		}
-	}
+        Exception getException() {
+            return exception;
+        }
+    }
 }

Modified: servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java
URL: http://svn.apache.org/viewvc/servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java?rev=664660&r1=664659&r2=664660&view=diff
==============================================================================
--- servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java (original)
+++ servicemix/smx4/specs/trunk/jaxws-api-2.1/src/main/java/javax/xml/ws/spi/FactoryFinder.java Mon Jun  9 01:48:42 2008
@@ -1,112 +1,301 @@
-/**
- * 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
+/*
+ * 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
+ * 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.
+ * 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.ws.spi;
 
-import java.io.InputStream;
+import java.io.BufferedReader;
 import java.io.File;
 import java.io.FileInputStream;
-
-import java.util.Properties;
-import java.io.BufferedReader;
+import java.io.InputStream;
 import java.io.InputStreamReader;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.security.PrivilegedAction;
+import java.util.Properties;
 
-import javax.xml.ws.WebServiceException;
-
+/**
+ * This code is designed to implement the pluggability
+ * feature and is designed to both compile and run on JDK version 1.1 and
+ * later.  The code also runs both as part of an unbundled jar file and
+ * when bundled as part of the JDK.
+ * <p/>
+ * This class is duplicated for each subpackage so keep it in sync.
+ * It is package private and therefore is not exposed as part of the JAXRPC
+ * API.
+ */
 class FactoryFinder {
-	static Object locate(String factoryId) {
-		return locate(factoryId, null);
-	}
-
-	static Object locate(String factoryId, String altClassName) {
-		return locate(factoryId, altClassName, Thread.currentThread().getContextClassLoader());
-	}
-
-	static Object locate(String factoryId, String altClassName, ClassLoader classLoader) {
-        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) {
+    /**
+     * Set to true for debugging.
+     */
+    private static final boolean debug = false;
+
+    private static void debugPrintln(String msg) {
+        if (debug) {
+            System.err.println("Factory Finder:" + msg);
         }
+    }
 
-		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) {
-		}
-
-        try {
-            String configFile = System.getProperty("java.home")
-                    + File.separator + "lib" + File.separator
-                    + "jaxws.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);
+    /**
+     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
+     * the context ClassLoader.
+     *
+     * @return the <code>ClassLoader</code>
+     * @throws ConfigurationError if this class is unable to work with the
+     *                            host JDK
+     */
+    private static ClassLoader findClassLoader()
+            throws ConfigurationError {
+        // REVIEW This doPriv block may be unnecessary because this method is private and 
+        // the caller already has a doPriv.  I added the doPriv in case someone changes the 
+        // visibility of this method to non-private.
+        ClassLoader cl = (ClassLoader)
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                
+                    Method m = null;
+
+                    try {
+
+                        m = Thread.class.getMethod("getContextClassLoader", (Class []) null);
+                    } catch (NoSuchMethodException e) {
+                        // Assume that we are running JDK 1.1, use the current ClassLoader
+                        debugPrintln("assuming JDK 1.1");
+                        return FactoryFinder.class.getClassLoader();
+                    }
+
+                    try {
+                        return (ClassLoader) m.invoke(Thread.currentThread(), (Object []) null);
+                    } catch (IllegalAccessException e) {
+                        // assert(false)
+                        throw new ConfigurationError("Unexpected IllegalAccessException",
+                                e);
+                    } catch (InvocationTargetException e) {
+                        // assert(e.getTargetException() instanceof SecurityException)
+                        throw new ConfigurationError("Unexpected InvocationTargetException",
+                                e);
+                    }
+                }
             }
-        } catch (Exception e) {
+        );
+        return cl;
+        
+    }
+
+    /**
+     * Create an instance of a class using the specified
+     * <code>ClassLoader</code>, or if that fails from the
+     * <code>ClassLoader</code> that loaded this class.
+     *
+     * @param className   the name of the class to instantiate
+     * @param classLoader a <code>ClassLoader</code> to load the class from
+     * @return a new <code>Object</code> that is an instance of the class of
+     *         the given name from the given class loader
+     * @throws ConfigurationError if the class could not be found or
+     *                            instantiated
+     */
+    private static Object newInstance(String className,
+                                      ClassLoader classLoader)
+            throws ConfigurationError {
+        
+        final ClassLoader iClassLoader = classLoader;
+        final String iClassName = className;
+        
+        // REVIEW This doPriv block may be unnecessary because this method is private and 
+        // the caller already has a doPriv.  I added the doPriv in case someone changes the 
+        // visibility of this method to non-private.
+        Object obj = 
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                    try {
+                        if (iClassLoader != null) {
+                            try {
+                                return iClassLoader.loadClass(iClassName).newInstance();
+                            } catch (ClassNotFoundException x) {
+                                // try again
+                            }
+                        }
+                        return Class.forName(iClassName).newInstance();
+                    } catch (ClassNotFoundException x) {
+                        throw new ConfigurationError(
+                                "Provider " + iClassName + " not found", x);
+                    } catch (Exception x) {
+                        throw new ConfigurationError(
+                                "Provider " + iClassName + " could not be instantiated: " + x,
+                                x);
+                    }
+                }
+            });
+        return obj;
+    }
+
+    /**
+     * Finds the implementation Class object in the specified order.  Main
+     * entry point.
+     *
+     * @param factoryId         Name of the factory to find, same as
+     *                          a property name
+     * @param fallbackClassName Implementation class name, if nothing else
+     *                          is found.  Use null to mean no fallback.
+     * @return Class object of factory, never null
+     * @throws FactoryFinder.ConfigurationError
+     *          Package private so this code can be shared.
+     */
+    static Object find(String factoryId, String fallbackClassName)
+            throws ConfigurationError {
+        
+        final String iFactoryId = factoryId;
+        final String iFallbackClassName = fallbackClassName;
+        
+        Object obj = 
+            doPrivileged( new PrivilegedAction() {
+                public Object run() {
+                    debugPrintln("debug is on");
+                    
+                    ClassLoader classLoader = findClassLoader();
+                    
+			        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) {
+			        }
+			
+                    // Use the system property first
+                    try {
+                        String systemProp =
+                            System.getProperty(iFactoryId);
+                        if (systemProp != null) {
+                            debugPrintln("found system property " + systemProp);
+                            return newInstance(systemProp, classLoader);
+                        }
+                    } catch (SecurityException se) {
+                    }
+                    
+                    // try to read from $java.home/lib/xml.properties
+                    try {
+                        String javah = System.getProperty("java.home");
+                        String configFile = javah + File.separator +
+                        "lib" + File.separator + "jaxrpc.properties";
+                        File f = new File(configFile);
+                        if (f.exists()) {
+                            Properties props = new Properties();
+                            props.load(new FileInputStream(f));
+                            String factoryClassName = props.getProperty(iFactoryId);
+                            debugPrintln("found java.home property " + factoryClassName);
+                            return newInstance(factoryClassName, classLoader);
+                        }
+                    } catch (Exception ex) {
+                        if (debug) ex.printStackTrace();
+                    }
+                    
+                    String serviceId = "META-INF/services/" + iFactoryId;
+                    // try to find services in CLASSPATH
+                    try {
+                        InputStream is = null;
+                        if (classLoader == null) {
+                            is = ClassLoader.getSystemResourceAsStream(serviceId);
+                        } else {
+                            is = classLoader.getResourceAsStream(serviceId);
+                        }
+                        
+                        if (is != null) {
+                            debugPrintln("found " + serviceId);
+                            
+                            // Read the service provider name in UTF-8 as specified in
+                            // the jar spec.  Unfortunately this fails in Microsoft
+                            // VJ++, which does not implement the UTF-8
+                            // encoding. Theoretically, we should simply let it fail in
+                            // that case, since the JVM is obviously broken if it
+                            // doesn't support such a basic standard.  But since there
+                            // are still some users attempting to use VJ++ for
+                            // development, we have dropped in a fallback which makes a
+                            // second attempt using the platform's default encoding. In
+                            // VJ++ this is apparently ASCII, which is a subset of
+                            // UTF-8... and since the strings we'll be reading here are
+                            // also primarily limited to the 7-bit ASCII range (at
+                            // least, in English versions), this should work well
+                            // enough to keep us on the air until we're ready to
+                            // officially decommit from VJ++. [Edited comment from
+                            // jkesselm]
+                            BufferedReader rd;
+                            try {
+                                rd = new BufferedReader(new InputStreamReader(is, "UTF-8"));
+                            } catch (java.io.UnsupportedEncodingException e) {
+                                rd = new BufferedReader(new InputStreamReader(is));
+                            }
+                            
+                            String factoryClassName = rd.readLine();
+                            rd.close();
+                            
+                            if (factoryClassName != null &&
+                                    ! "".equals(factoryClassName)) {
+                                debugPrintln("loaded from services: " + factoryClassName);
+                                return newInstance(factoryClassName, classLoader);
+                            }
+                        }
+                    } catch (Exception ex) {
+                        if (debug) ex.printStackTrace();
+                    }
+                    
+                    if (iFallbackClassName == null) {
+                        throw new ConfigurationError(
+                                "Provider for " + iFactoryId + " cannot be found", null);
+                    }
+                    
+                    debugPrintln("loaded from fallback value: " + iFallbackClassName);
+                    return newInstance(iFallbackClassName, classLoader);
+                }
+            });
+        return obj;
+    }
+
+    private static Object doPrivileged(PrivilegedAction action) {
+        SecurityManager sm = System.getSecurityManager();
+        if (sm == null) {
+            return(action.run());
+        } else {
+            return java.security.AccessController.doPrivileged(action);
+        }
+    }
+
+    static class ConfigurationError extends Error {
+        // fixme: should this be refactored to use the jdk1.4 exception
+        // wrapping?
+
+        private Exception exception;
+
+        /**
+         * Construct a new instance with the specified detail string and
+         * exception.
+         *
+         * @param msg the Message for this error
+         * @param x   an Exception that caused this failure, or null
+         */
+        ConfigurationError(String msg, Exception x) {
+            super(msg);
+            this.exception = x;
         }
 
-        try {
-			String prop = System.getProperty(factoryId);
-			if (prop != null) {
-				return loadFactory(prop, classLoader);
-			}
-		} catch (Exception e) {
-		}
-
-		if (altClassName == null) {
-			throw new WebServiceException("Unable to locate factory for " + factoryId + ".", null);
-		}
-		return loadFactory(altClassName, classLoader);
-	}
-
-	private static Object loadFactory(String className, ClassLoader classLoader) {
-		try {
-			Class factoryClass = classLoader == null ? Class.forName(className)
-					                                 : classLoader.loadClass(className);
-			return factoryClass.newInstance();
-		} catch (ClassNotFoundException x) {
-			throw new WebServiceException("Requested factory "
-					+ className + " cannot be located.  Classloader ="
-					+ classLoader.toString(), x);
-		} catch (Exception x) {
-			throw new WebServiceException("Requested factory "
-					+ className + " could not be instantiated: " + x, x);
-		}
-	}
+        Exception getException() {
+            return exception;
+        }
+    }
 }



Mime
View raw message