FileDocCategorySizeDatePackage
ResourceAbstractionLayer.javaAPI DocphoneME MR2 API (J2ME)6808Wed May 02 18:00:46 BST 2007com.sun.j2me.global

ResourceAbstractionLayer

public abstract class ResourceAbstractionLayer extends Object
The ResourceAbstractionLayer class provides a layer of abstraction for {@link javax.microedition.global.ResourceManager} implementation. Sub-classes of ResourceAbstractionLayer correspond to individual implementations of access to application and device resources.

Fields Summary
private static final String
ABSTRACTION_LAYER_PROPERTY
Constant name of resource abstraction layer class property.
private static final String
DEFAULT_ABSTRACTION_LAYER
Constant name of default resource abstraction layer class.
private static ResourceAbstractionLayer
abstractionLayer
An instance of ResourceAbstractionLayer, which is used in the {@link #getInstance() getInstance} method.
protected ResourceManagerFactory
appResourceManagerFactory
A resource manager factory for creating application resource managers.
Constructors Summary
Methods Summary
public ResourceManagerFactorygetAppResourceManagerFactory()
Returns an instance of the ResourceManagerFactory sub-class, which is used to create resource managers for accessing application resources.

return
the instance of the application resource manager factory
see
ResourceManagerFactory

        if (appResourceManagerFactory == null) {
            appResourceManagerFactory = new AppResourceManagerFactory(null);
        }
        return appResourceManagerFactory;
    
public abstract ResourceManagerFactorygetDevResourceManagerFactory()
Returns an instance of the ResourceManagerFactory sub-class, which is used to create resource managers for accessing device specific resources.

return
the instance of the device resource manager factory
see
ResourceManagerFactory

public static com.sun.j2me.global.ResourceAbstractionLayergetInstance()
Returns an instance ResourceAbstractionLayer. This instance is created only once (singleton) and then it is reused when the method is called again.

return
the instance of the AbstractionLayer sub-class, null if unable to get sub-class instance



                                                           
        
        if (abstractionLayer == null) {
            String alClsName =
                    Configuration.getProperty(ABSTRACTION_LAYER_PROPERTY);
            if (alClsName != null) {
                try {
                    abstractionLayer = (ResourceAbstractionLayer)
                            Class.forName(alClsName).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Resource handler class does not exist:"
                            + alClsName);
                    }
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Resource handler class missing constructor:"
                            + alClsName);
                    }
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Resource handler class incorrect type:"
                            + alClsName);
                    }
                }
            }
            if (abstractionLayer == null) {
                // try default abstraction layer
                try {
                    abstractionLayer = (ResourceAbstractionLayer)Class.forName(
                            DEFAULT_ABSTRACTION_LAYER).newInstance();
                } catch (ClassNotFoundException cnf_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Default Resource handler class does not exist:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                } catch (InstantiationException ie_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Resource handler class missing constructor:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                } catch (IllegalAccessException iae_ignore) {
                    /* intentionally ignored */
                    if (Logging.REPORT_LEVEL <= Logging.WARNING) {
                        Logging.report(Logging.WARNING, LogChannels.LC_JSR238,
                            "Resource handler class incorrect type:"
                            + DEFAULT_ABSTRACTION_LAYER);
                    }
                }
            }
        }

        return abstractionLayer;