// the first in the cache.
// Any other access of _classes potentially needs to be synchronized
// using the same variable _classes (e.g. updateKeyForClass).
synchronized (this._classes)
{
MappingClassElement mappingClass =
(MappingClassElement)_classes.get(className);
if (mappingClass == null)
{
// check whether the class is known to be non PC
if (_nonPCClasses.contains(className))
return null;
try
{
InputStream stream = getInputStreamForResource(className,
classLoader, getResourceNameWithExtension(className));
if (stream != null)
{
// if the file is empty, the archiver prints an
// exception, so protect against that case and
// return null without updating either cache
if (stream.available() > 0)
{
XMLInputStream xmlInput = new XMLInputStream(stream,
getClass().getClassLoader());
mappingClass =
(MappingClassElement)xmlInput.readObject();
xmlInput.close();
// postUnarchive performs version number checking
// and possible format conversions
mappingClass.postUnarchive();
// can't call updateKeyForClass here there are cases
// when the mapping class name doesn't match the
// classname (such as copy/paste, move etc.)
_classes.put(className, mappingClass);
// update the modified flags for the mapping and
// persistence classes since the xml archiver uses
// all the set methods
mappingClass.setModified(false);
getPersistenceClass(mappingClass).
setModified(false);
}
}
else