/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class is responsible for producing RI JAXBContext objects. In
* the RI, this is the class that the javax.xml.bind.context.factory
* property will point to.
*
* <p>
* Used to create JAXBContext objects for v1.0.1 and forward
*
* @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 {
// fool-proof check, and copy the map to make it easier to find unrecognized properties.
if(properties==null)
else
String defaultNsUri = getPropertyValue(properties,JAXBRIContext.DEFAULT_NAMESPACE_REMAP,String.class);
Boolean c14nSupport = getPropertyValue(properties,JAXBRIContext.CANONICALIZATION_SUPPORT,Boolean.class);
if(c14nSupport==null)
c14nSupport = 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);
if(retainPropertyInfo==null)
retainPropertyInfo = false;
Boolean supressAccessorWarnings = getPropertyValue(properties, JAXBRIContext.SUPRESS_ACCESSOR_WARNINGS, Boolean.class);
supressAccessorWarnings = false;
Boolean improvedXsiTypeHandling = getPropertyValue(properties, JAXBRIContext.IMPROVED_XSI_TYPE_HANDLING, Boolean.class);
if(improvedXsiTypeHandling == null)
improvedXsiTypeHandling = true;
xmlAccessorFactorySupport = false;
"is not active. Using JAXB's implementation");
}
RuntimeAnnotationReader ar = getPropertyValue(properties,JAXBRIContext.ANNOTATION_READER,RuntimeAnnotationReader.class);
try {
getPropertyValue(properties, JAXBRIContext.SUBCLASS_REPLACEMENTS, Map.class), Class.class, Class.class);
} catch (ClassCastException e) {
}
if(!properties.isEmpty()) {
throw new JAXBException(Messages.UNSUPPORTED_PROPERTY.format(properties.keySet().iterator().next()));
}
}
/**
* If a key is present in the map, remove the value and return it.
*/
private static <T> T getPropertyValue(Map<String, Object> properties, String keyName, Class<T> type ) throws JAXBException {
if(!type.isInstance(o))
else
}
boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo) throws JAXBException {
allNillable, retainPropertyInfo, false);
}
boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean improvedXsiTypeHandling) throws JAXBException {
}
/**
* The API will invoke this method via reflection.
*/
// at least on of these must be true per package
boolean foundObjectFactory;
boolean foundJaxbIndex;
while(tokens.hasMoreTokens()) {
foundObjectFactory = foundJaxbIndex = false;
// look for ObjectFactory and load it
final Class<?> o;
try {
foundObjectFactory = true;
} catch (ClassNotFoundException e) {
// not necessarily an error
}
// look for jaxb.index and load the list of classes
try {
} catch (IOException e) {
//TODO: think about this more
throw new JAXBException(e);
}
if(indexedClasses != null) {
foundJaxbIndex = true;
}
if( !(foundObjectFactory || foundJaxbIndex) ) {
}
}
}
/**
* Look for jaxb.index file in the specified package and load it's contents
*
* @param pkg package name to search in
* @param classLoader ClassLoader to search in
* @return a List of Class objects to load, null if there weren't any
* @throws IOException if there is an error reading the index file
* @throws JAXBException if there are any errors in the index file
*/
private static List<Class> loadIndexedClasses(String pkg, ClassLoader classLoader) throws IOException, JAXBException {
if (resourceAsStream == null) {
return null;
}
try {
continue;
}
}
try {
} catch (ClassNotFoundException e) {
}
}
return classes;
} finally {
}
}
}