FileDocCategorySizeDatePackage
XMLPlatformFactory.javaAPI DocGlassfish v2 API6569Tue May 22 16:54:48 BST 2007oracle.toplink.essentials.platform.xml

XMLPlatformFactory

public class XMLPlatformFactory extends Object

Fields Summary
public static final String
XML_PLATFORM_PROPERTY
public static final String
XDK_PLATFORM_CLASS_NAME
public static final String
JAXP_PLATFORM_CLASS_NAME
private static XMLPlatformFactory
instance
private Class
xmlPlatformClass
Constructors Summary
private XMLPlatformFactory()


      
        super();
    
Methods Summary
public static oracle.toplink.essentials.platform.xml.XMLPlatformFactorygetInstance()
INTERNAL: Return the singleton instance of XMLPlatformContext.

return
the the singleton instance of XMLPlatformContext.
throws
XMLPlatformException

        if (null == instance) {
            instance = new XMLPlatformFactory();
        }
        return instance;
    
public oracle.toplink.essentials.platform.xml.XMLPlatformgetXMLPlatform()
INTERNAL: Return the XMLPlatform based on the toplink.xml.platform System property.

return
an instance of XMLPlatform
throws
XMLPlatformException

        try {
             if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                try {
                    return (XMLPlatform)AccessController.doPrivileged(new PrivilegedNewInstanceFromClass(getXMLPlatformClass()));
                } catch (PrivilegedActionException exception) {
                    Exception throwableException = exception.getException();
                    if (throwableException instanceof InstantiationException) {
                        throw XMLPlatformException.xmlPlatformCouldNotInstantiate(getXMLPlatformClass().getName(), throwableException);
                    } else {
                        throw XMLPlatformException.xmlPlatformCouldNotInstantiate(getXMLPlatformClass().getName(), throwableException);
                    }
                }
            } else {
                return (XMLPlatform)PrivilegedAccessHelper.newInstanceFromClass(getXMLPlatformClass());
            }
        } catch (IllegalAccessException e) {
            throw XMLPlatformException.xmlPlatformCouldNotInstantiate(getXMLPlatformClass().getName(), e);
        } catch (InstantiationException e) {
            throw XMLPlatformException.xmlPlatformCouldNotInstantiate(getXMLPlatformClass().getName(), e);
        }
    
public java.lang.ClassgetXMLPlatformClass()
INTERNAL: Return the implementation class for the XMLPlatform.

return
the implementation class for the XMLPlatform.
throws
XMLPlatformException

        if (null != xmlPlatformClass) {
            return xmlPlatformClass;
        }

        String newXMLPlatformClassName = System.getProperty(XML_PLATFORM_PROPERTY);
        if (null == newXMLPlatformClassName) {
            newXMLPlatformClassName = JAXP_PLATFORM_CLASS_NAME;
        }

        try {
            ClassLoader classLoader = null;
            if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){
                try{
                    classLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedGetClassLoaderForClass(this.getClass()));
                } catch (PrivilegedActionException exc){
                    // will not be thrown
                }
            } else {
                classLoader = PrivilegedAccessHelper.getClassLoaderForClass(this.getClass());
            }
            // ClassLoader classLoader = ClassLoader.getSystemClassLoader();
            // ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            Class newXMLPlatformClass = classLoader.loadClass(newXMLPlatformClassName);
            setXMLPlatformClass(newXMLPlatformClass);
            return xmlPlatformClass;
        } catch (ClassNotFoundException e) {
            throw XMLPlatformException.xmlPlatformClassNotFound(newXMLPlatformClassName, e);
        }
    
public voidsetXMLPlatformClass(java.lang.Class xmlPlatformClass)
PUBLIC: Set the implementation of XMLPlatform.

        this.xmlPlatformClass = xmlPlatformClass;