com.sun.xml.bind.v2.runtime
Class Coordinator

java.lang.Object
  extended by com.sun.xml.bind.v2.runtime.Coordinator
All Implemented Interfaces:
javax.xml.bind.ValidationEventHandler, org.xml.sax.ErrorHandler
Direct Known Subclasses:
UnmarshallingContext, XMLSerializer

public abstract class Coordinator
extends java.lang.Object
implements org.xml.sax.ErrorHandler, javax.xml.bind.ValidationEventHandler

Object that coordinates the marshalling/unmarshalling.

This class takes care of the logic that allows code to obtain UnmarshallingContext and XMLSerializer instances during the unmarshalling/marshalling.

This is done by using a ThreadLocal. Therefore one unmarshalling/marshalling episode has to be done from the beginning till end by the same thread. (Note that the same Coordinator can be then used by a different thread for an entirely different episode.) This class also maintains the user-configured instances of XmlAdapters.

This class implements ErrorHandler and propages erros to this object as the ValidationEventHandler, which will be implemented in a derived class.


Field Summary
static boolean debugTableNPE
           
 java.lang.Exception guyWhoSetTheTableToNull
          When we set table to null, record who did it.
 
Constructor Summary
Coordinator()
           
 
Method Summary
static Coordinator _getInstance()
           
<T extends javax.xml.bind.annotation.adapters.XmlAdapter>
boolean
containsAdapter(java.lang.Class<T> type)
           
 void error(org.xml.sax.SAXParseException exception)
           
 void fatalError(org.xml.sax.SAXParseException exception)
           
<T extends javax.xml.bind.annotation.adapters.XmlAdapter>
T
getAdapter(java.lang.Class<T> key)
          Gets the instance of the adapter.
protected abstract  javax.xml.bind.ValidationEventLocator getLocation()
          Gets the current location.
protected  void popCoordinator()
          Called whenever an execution flow exits the realm of this Coordinator.
protected  void pushCoordinator()
          Called whenever an execution flow enters the realm of this Coordinator.
 javax.xml.bind.annotation.adapters.XmlAdapter putAdapter(java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter> c, javax.xml.bind.annotation.adapters.XmlAdapter a)
           
protected  void resetThreadAffinity()
          Dis-associate this Coordinator with the current thread.
protected  void setThreadAffinity()
          Associates this Coordinator with the current thread.
 void warning(org.xml.sax.SAXParseException exception)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.xml.bind.ValidationEventHandler
handleEvent
 

Field Detail

guyWhoSetTheTableToNull

public java.lang.Exception guyWhoSetTheTableToNull
When we set table to null, record who did it. This is for trouble-shooting a possible concurrency issue reported at: http://forums.java.net/jive/thread.jspa?threadID=15132


debugTableNPE

public static boolean debugTableNPE
Constructor Detail

Coordinator

public Coordinator()
Method Detail

putAdapter

public final javax.xml.bind.annotation.adapters.XmlAdapter putAdapter(java.lang.Class<? extends javax.xml.bind.annotation.adapters.XmlAdapter> c,
                                                                      javax.xml.bind.annotation.adapters.XmlAdapter a)

getAdapter

public final <T extends javax.xml.bind.annotation.adapters.XmlAdapter> T getAdapter(java.lang.Class<T> key)
Gets the instance of the adapter.

Returns:
always non-null.

containsAdapter

public <T extends javax.xml.bind.annotation.adapters.XmlAdapter> boolean containsAdapter(java.lang.Class<T> type)

setThreadAffinity

protected final void setThreadAffinity()
Associates this Coordinator with the current thread. Should be called at the very beginning of the episode.


resetThreadAffinity

protected final void resetThreadAffinity()
Dis-associate this Coordinator with the current thread. Sohuld be called at the end of the episode to avoid memory leak.


pushCoordinator

protected final void pushCoordinator()
Called whenever an execution flow enters the realm of this Coordinator.


popCoordinator

protected final void popCoordinator()
Called whenever an execution flow exits the realm of this Coordinator.


_getInstance

public static Coordinator _getInstance()

getLocation

protected abstract javax.xml.bind.ValidationEventLocator getLocation()
Gets the current location. Used for reporting the error source location.


error

public final void error(org.xml.sax.SAXParseException exception)
                 throws org.xml.sax.SAXException
Specified by:
error in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

warning

public final void warning(org.xml.sax.SAXParseException exception)
                   throws org.xml.sax.SAXException
Specified by:
warning in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException

fatalError

public final void fatalError(org.xml.sax.SAXParseException exception)
                      throws org.xml.sax.SAXException
Specified by:
fatalError in interface org.xml.sax.ErrorHandler
Throws:
org.xml.sax.SAXException