src/share/jaxws_classes/com/sun/xml/internal/bind/v2/ContextFactory.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -58,14 +58,15 @@
  *
  * @since 2.0
  * @author Kohsuke Kawaguchi
  */
 public class ContextFactory {
+
     /**
      * The API will invoke this method via reflection
      */
-    public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException {
+    public static JAXBContext createContext(Class[] classes, Map<String,Object> properties ) throws JAXBException {
         // fool-proof check, and copy the map to make it easier to find unrecognized properties.
         if(properties==null)
             properties = Collections.emptyMap();
         else
             properties = new HashMap<String,Object>(properties);

@@ -74,10 +75,14 @@
 
         Boolean c14nSupport = getPropertyValue(properties,JAXBRIContext.CANONICALIZATION_SUPPORT,Boolean.class);
         if(c14nSupport==null)
             c14nSupport = false;
 
+        Boolean disablesecurityProcessing = getPropertyValue(properties, JAXBRIContext.DISABLE_XML_SECURITY, Boolean.class);
+        if (disablesecurityProcessing==null)
+            disablesecurityProcessing = false;
+
         Boolean allNillable = getPropertyValue(properties,JAXBRIContext.TREAT_EVERYTHING_NILLABLE,Boolean.class);
         if(allNillable==null)
             allNillable = false;
 
         Boolean retainPropertyInfo = getPropertyValue(properties, JAXBRIContext.RETAIN_REFERENCE_TO_INFO, Boolean.class);

@@ -87,12 +92,18 @@
         Boolean supressAccessorWarnings = getPropertyValue(properties, JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.class);
         if(supressAccessorWarnings==null)
             supressAccessorWarnings = false;
 
         Boolean improvedXsiTypeHandling = getPropertyValue(properties, JAXBRIContext.IMPROVED_XSI_TYPE_HANDLING, Boolean.class);
-        if(improvedXsiTypeHandling == null)
+        if (improvedXsiTypeHandling == null) {
+            String improvedXsiSystemProperty = Util.getSystemProperty(JAXBRIContext.IMPROVED_XSI_TYPE_HANDLING);
+            if (improvedXsiSystemProperty == null) {
             improvedXsiTypeHandling = true;
+            } else {
+                improvedXsiTypeHandling = Boolean.valueOf(improvedXsiSystemProperty);
+            }
+        }
 
         Boolean xmlAccessorFactorySupport = getPropertyValue(properties,
            JAXBRIContext.XMLACCESSORFACTORY_SUPPORT,Boolean.class);
         if(xmlAccessorFactorySupport==null){
             xmlAccessorFactorySupport = false;

@@ -101,10 +112,15 @@
                 "is not active.  Using JAXB's implementation");
         }
 
         RuntimeAnnotationReader ar = getPropertyValue(properties,JAXBRIContext.ANNOTATION_READER,RuntimeAnnotationReader.class);
 
+        Collection<TypeReference> tr = getPropertyValue(properties, JAXBRIContext.TYPE_REFERENCES, Collection.class);
+        if (tr == null) {
+            tr = Collections.<TypeReference>emptyList();
+        }
+
         Map<Class,Class> subclassReplacements;
         try {
             subclassReplacements = TypeCast.checkedCast(
                 getPropertyValue(properties, JAXBRIContext.SUBCLASS_REPLACEMENTS, Map.class), Class.class, Class.class);
         } catch (ClassCastException e) {

@@ -115,20 +131,21 @@
             throw new JAXBException(Messages.UNSUPPORTED_PROPERTY.format(properties.keySet().iterator().next()));
         }
 
         JAXBContextImpl.JAXBContextBuilder builder = new JAXBContextImpl.JAXBContextBuilder();
         builder.setClasses(classes);
-        builder.setTypeRefs(Collections.<TypeReference>emptyList());
+        builder.setTypeRefs(tr);
         builder.setSubclassReplacements(subclassReplacements);
         builder.setDefaultNsUri(defaultNsUri);
         builder.setC14NSupport(c14nSupport);
         builder.setAnnotationReader(ar);
         builder.setXmlAccessorFactorySupport(xmlAccessorFactorySupport);
         builder.setAllNillable(allNillable);
         builder.setRetainPropertyInfo(retainPropertyInfo);
         builder.setSupressAccessorWarnings(supressAccessorWarnings);
         builder.setImprovedXsiTypeHandling(improvedXsiTypeHandling);
+        builder.setDisableSecurityProcessing(disablesecurityProcessing);
         return builder.build();
     }
 
     /**
      * If a key is present in the map, remove the value and return it.

@@ -142,20 +159,53 @@
             throw new JAXBException(Messages.INVALID_PROPERTY_VALUE.format(keyName,o));
         else
             return type.cast(o);
     }
 
+    /**
+     *
+     * @param classes
+     * @param typeRefs
+     * @param subclassReplacements
+     * @param defaultNsUri
+     * @param c14nSupport
+     * @param ar
+     * @param xmlAccessorFactorySupport
+     * @param allNillable
+     * @param retainPropertyInfo
+     * @return
+     * @throws JAXBException
+     * @deprecated use createContext(Class[] classes, Map<String,Object> properties) method instead
+     */
+    @Deprecated
     public static JAXBRIContext createContext( Class[] classes,
             Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
             String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
             boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo) throws JAXBException {
 
         return createContext(classes, typeRefs, subclassReplacements,
                 defaultNsUri, c14nSupport, ar, xmlAccessorFactorySupport,
                 allNillable, retainPropertyInfo, false);
     }
 
+    /**
+     *
+     * @param classes
+     * @param typeRefs
+     * @param subclassReplacements
+     * @param defaultNsUri
+     * @param c14nSupport
+     * @param ar
+     * @param xmlAccessorFactorySupport
+     * @param allNillable
+     * @param retainPropertyInfo
+     * @param improvedXsiTypeHandling
+     * @return
+     * @throws JAXBException
+     * @deprecated use createContext( Class[] classes, Map<String,Object> properties) method instead
+     */
+    @Deprecated
     public static JAXBRIContext createContext( Class[] classes,
             Collection<TypeReference> typeRefs, Map<Class,Class> subclassReplacements,
             String defaultNsUri, boolean c14nSupport, RuntimeAnnotationReader ar,
             boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {