001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package javax.xml.bind;
018
019 import java.io.IOException;
020
021 import java.util.Map;
022 import java.util.Collections;
023
024 import org.w3c.dom.Node;
025
026 public abstract class JAXBContext {
027
028 public static final String JAXB_CONTEXT_FACTORY = "javax.xml.bind.context.factory";
029
030 protected JAXBContext() {
031 }
032
033 public Binder<Node> createBinder() {
034 throw new UnsupportedOperationException();
035 }
036
037 public <T> Binder<T> createBinder(Class<T> domType) {
038 throw new UnsupportedOperationException();
039 }
040
041 public JAXBIntrospector createJAXBIntrospector() {
042 throw new UnsupportedOperationException();
043 }
044
045 public abstract Marshaller createMarshaller() throws JAXBException;
046
047 public abstract Unmarshaller createUnmarshaller() throws JAXBException;
048
049 public abstract Validator createValidator() throws JAXBException;
050
051 public void generateSchema(SchemaOutputResolver resolver) throws IOException {
052 throw new UnsupportedOperationException();
053 }
054
055 public static JAXBContext newInstance(Class... classesToBeBound) throws JAXBException {
056 return newInstance(classesToBeBound, Collections.<String, Object>emptyMap());
057 }
058
059 public static JAXBContext newInstance(Class[] classesToBeBound, Map<String, ?> properties) throws JAXBException {
060 for (Class cl : classesToBeBound) {
061 if (cl == null) {
062 throw new IllegalArgumentException();
063 }
064 }
065 return ContextFinder.find(classesToBeBound, properties);
066 }
067
068 public static JAXBContext newInstance(String contextPath) throws JAXBException {
069 return newInstance(contextPath, Thread.currentThread().getContextClassLoader());
070 }
071
072 public static JAXBContext newInstance(String contextPath, ClassLoader classLoader) throws JAXBException {
073 return newInstance(contextPath, classLoader, Collections.<String, Object>emptyMap());
074 }
075
076 public static JAXBContext newInstance(String contextPath, ClassLoader classLoader, Map<String, ?> properties) throws JAXBException {
077 return ContextFinder.find(contextPath, classLoader, properties);
078 }
079 }