ohair@286: /* ohair@286: * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. ohair@286: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ohair@286: * ohair@286: * This code is free software; you can redistribute it and/or modify it ohair@286: * under the terms of the GNU General Public License version 2 only, as ohair@286: * published by the Free Software Foundation. Oracle designates this ohair@286: * particular file as subject to the "Classpath" exception as provided ohair@286: * by Oracle in the LICENSE file that accompanied this code. ohair@286: * ohair@286: * This code is distributed in the hope that it will be useful, but WITHOUT ohair@286: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ohair@286: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ohair@286: * version 2 for more details (a copy is included in the LICENSE file that ohair@286: * accompanied this code). ohair@286: * ohair@286: * You should have received a copy of the GNU General Public License version ohair@286: * 2 along with this work; if not, write to the Free Software Foundation, ohair@286: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ohair@286: * ohair@286: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@286: * or visit www.oracle.com if you need additional information or have any ohair@286: * questions. ohair@286: */ ohair@286: ohair@286: /** ohair@286: *

The JAXB 2.0 runtime

. ohair@286: * ohair@286: *

Overview

ohair@286: *

ohair@286: * This module provides code that implements {@link JAXBContext}. ohair@286: * Roughly speaking the runtime works like this: ohair@286: * ohair@286: *

    ohair@286: *
  1. There's a set of classes and interfaces that model JAXB-bound types. ohair@286: * You can think of this as a reflection library for JAXB. ohair@286: *
  2. There's a set of classes that constitute the unmarshaller and marshaller. ohair@286: * Each class represents a small portion, and they are composed to perform ohair@286: * the operations. ohair@286: *
  3. {@link JAXBContextImpl} builds itself by reading the model and ohair@286: * composing unmarshallers and marshallers. ohair@286: *
ohair@286: * ohair@286: *

Interesting Pieces inside Runtime

ohair@286: *

ohair@286: * The followings are the interesting pieces inside the runtime. ohair@286: * ohair@286: *

ohair@286: *
{@link com.sun.xml.internal.bind.v2.model model} ohair@286: *
ohair@286: * This set of classes and interfaces models JAXB-bound types. ohair@286: * ohair@286: *
{@link com.sun.xml.internal.bind.v2.runtime XML I/O} ohair@286: *
ohair@286: * This set of classes implements the JAXB API and provides the XML I/O functionality. ohair@286: *
ohair@286: * ohair@286: *

ohair@286: * The classes NOT in the {@link com.sun.xml.internal.bind.v2} package (and its subpackages) ohair@286: * are also used by old JAXB 1.0 clients. ohair@286: * ohair@286: *

Models

ohair@286: *

ohair@286: * "Model" is the portion of the code that represents JAXB-bound types. ohair@286: * ohair@286: *

ohair@286: * The following picture illustrates the relationship among major ohair@286: * packages of the binding model. ohair@286: * ohair@286: *

ohair@286: * ohair@286: *
ohair@286: * ohair@286: *

ohair@286: * The core model contracts are all interfaces, and they are parameterized ohair@286: * so that they can be used ohair@286: * with different reflection libraries. This is necessary, as the model ohair@286: * is used: ohair@286: *

    ohair@286: *
  1. at runtime to process loaded classes, ohair@286: *
  2. at tool-time to process source files / class files, and ohair@286: *
  3. at schema compile time to generate source code. ohair@286: *
ohair@286: * They all use different reflection libraries. ohair@286: * ohair@286: *

ohair@286: * This portion is used by all ohair@286: * three running mode of JAXB. ohair@286: * The corresponding base-level implementaion ohair@286: * is also parameterized. ohair@286: * ohair@286: *

ohair@286: * The runtime model contract and implementation are used only at the run-time. ohair@286: * These packages fix the parameterization to the Java reflection, ohair@286: * and also exposes additional functionalities to actually do the ohair@286: * unmarshalling/marshalling. These classes have "Runtime" prefix. ohair@286: * ohair@286: *

ohair@286: * Finally XJC has its own implementation of the contract in ohair@286: * its own package. This package also fixes the parameterization ohair@286: * to its own reflection library. ohair@286: * ohair@286: *

ohair@286: * When you work on the code, it is often helpful to know the layer you are in. ohair@286: * ohair@286: * ohair@286: *

ohair@286: * The binding model design roughly looks like the following. ohair@286: * For more details, see the javadoc of each component. ohair@286: * ohair@286: *

ohair@286: * ohair@286: *
ohair@286: * ohair@286: * TODO: link to classes from above pictures ohair@286: * ohair@286: * ohair@286: *

Evolution Rules

ohair@286: * None of the class in this package or below should be directly ohair@286: * referenced by the generated code. Hence they can be changed freely ohair@286: * from versions to versions. ohair@286: * ohair@286: * ohair@286: * ohair@286: * ohair@286: *

Performance Characteristics

ohair@286: *

ohair@286: * Model construction happens inside {@link JAXBContext#newInstance(Class[])}. ohair@286: * It's desirable for this step to be fast and consume less memory, ohair@286: * but it's not too performance sensitive. ohair@286: * ohair@286: *

ohair@286: * Code that implements the unmarshaller and the marshaller OTOH ohair@286: * needs to be very carefully written to achieve maximum sustaining ohair@286: * performance. ohair@286: * ohair@286: * ohair@286: * ohair@286: * ohair@286: *

Bootstrap Sequence

ohair@286: *

ohair@286: * The following picture illustrates how the {@link JAXBContext#newInstance(Class[])} method ohair@286: * triggers activities. ohair@286: * ohair@286: * {@SequenceDiagram ohair@286: boxwid=1.2; ohair@286: ohair@286: pobject(U,"user"); ohair@286: object(A,"JAXB API"); ohair@286: object(CF,"ContextFactory"); ohair@286: pobject(JC); ohair@286: step(); ohair@286: ohair@286: message(U,A,"JAXBContext.newInstance()"); ohair@286: active(A); ohair@286: message(A,A,"locate JAXB RI 2.0"); ohair@286: active(A); ohair@286: step(); ohair@286: inactive(A); ohair@286: ohair@286: message(A,CF,"createContext"); ohair@286: active(CF); ohair@286: ohair@286: create_message(CF,JC,"c:JAXBContextImpl"); ohair@286: active(JC); ohair@286: ohair@286: message(JC,JC,"build runtime model"); ohair@286: message(JC,JC,"build JaxBeanInfos"); ohair@286: inactive(JC); ohair@286: ohair@286: rmessage(A,U,"return c"); ohair@286: inactive(CF); ohair@286: inactive(A); ohair@286: ohair@286: complete(JC); ohair@286: complete(CF); ohair@286: complete(A); ohair@286: * } ohair@286: * ohair@286: * @ArchitectureDocument ohair@286: */ ohair@286: package com.sun.xml.internal.bind.v2; ohair@286: ohair@286: import javax.xml.bind.JAXBContext; ohair@286: ohair@286: import com.sun.xml.internal.bind.v2.runtime.JAXBContextImpl;