com.sun.xml.bind.v2.runtime

Class Coordinator

public abstract class Coordinator extends Object implements ErrorHandler, 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 booleandebugTableNPE
ExceptionguyWhoSetTheTableToNull
When we set table to null, record who did it.
Method Summary
<T extends XmlAdapter> booleancontainsAdapter(Class<T> type)
voiderror(SAXParseException exception)
voidfatalError(SAXParseException exception)
<T extends XmlAdapter> TgetAdapter(Class<T> key)
Gets the instance of the adapter.
protected abstract ValidationEventLocatorgetLocation()
Gets the current location.
protected voidpopCoordinator()
Called whenever an execution flow exits the realm of this Coordinator.
protected voidpushCoordinator()
Called whenever an execution flow enters the realm of this Coordinator.
XmlAdapterputAdapter(Class<? extends XmlAdapter> c, XmlAdapter a)
protected voidresetThreadAffinity()
Dis-associate this Coordinator with the current thread.
protected voidsetThreadAffinity()
Associates this Coordinator with the current thread.
voidwarning(SAXParseException exception)
static Coordinator_getInstance()

Field Detail

debugTableNPE

public static boolean debugTableNPE

guyWhoSetTheTableToNull

public 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

Method Detail

containsAdapter

public <T extends XmlAdapter> boolean containsAdapter(Class<T> type)

error

public final void error(SAXParseException exception)

fatalError

public final void fatalError(SAXParseException exception)

getAdapter

public final <T extends XmlAdapter> T getAdapter(Class<T> key)
Gets the instance of the adapter.

Returns: always non-null.

getLocation

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

popCoordinator

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

pushCoordinator

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

putAdapter

public final XmlAdapter putAdapter(Class<? extends XmlAdapter> c, XmlAdapter a)

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.

setThreadAffinity

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

warning

public final void warning(SAXParseException exception)

_getInstance

public static Coordinator _getInstance()