| java.lang.Object edu.indiana.lib.osid.base.loader.OsidLoader
OsidLoader | public class OsidLoader implements java.io.Serializable(Code) | | OsidLoader loads a specific implementation of an Open Service Interface
Definition (OSID) with its getManager method. The getManager method loads
an instance of the OSID's org.osid.OsidManager, assigns the manager's OsidContext,
assigns any configuration information, and returns the instance of the OSID
implementation. This usage of the getManager method in the OsidLoader is
how applications should bind a particular implementation to an OSID. The
value of this approach is that an application can defer which specific OSID
implementation is used until runtime. The specific implementation package
name can then be part of the configuration information rather than being
hard coded. Changing implementations is simplified with this approach.
As an example, in order to create a new Hierarchy, an application does not
use the new operator. It uses the OsidLoader getManager method to get an
instance of a class that implements HierarchyManager (a subclass of
org.osid.OsidManager). The application uses the HierarchyManager instance to create
the Hierarchy. It is the createHierarchy() method in some package (e.g.
org.osid.hierarchy.impl.HierarchyManager) which uses the new operator on
org.osid.hierarchy.impl.Hierarchy, casts it as
org.osid.hierarchy.Hierarchy, and returns it to the application. This
indirection offers the significant value of being able to change
implementations in one spot with one modification, namely by using a
implementation package name argument for the OsidLoader getManager method.
Sample:
org.osid.OsidContext myContext = new org.osid.OsidContext(); String key = "myKey"; myContext.assignContext(key, "I want to save this string as context"); String whatWasMyContext = myContext.getContext(key); org.osid.hierarchy.HierarchyManager hierarchyManager =
org.osid.OsidLoader.getManager("org.osid.hierarchy.HierarchyManager","org.osid.shared.impl",myContext,null);
org.osid.hierarchy.Hierarchy myHierarchy =
hierarchyManager.createHierarchy(...);
A similar technique can be used for creating other objects. OSIDs that have
org.osid.OsidManager implementations loaded by OsidLoader, will define an
appropriate interface to create these objects.
The arguments to OsidLoader.getManager method are the OSID org.osid.OsidManager
interface name, the implementing package name, the OsidContext, and any
additional configuration information.
OSID Version: 2.0
Licensed under the
org.osid.SidImplementationLicenseMIT MITO.K.I. OSID Definition License .
|
Method Summary | |
public static java.io.InputStream | getConfigStream(String fileName, Class curClass) Get an InputStream for a particular file name - first check the sakai.home area and then
revert to the classpath. | public static org.osid.OsidManager | getManager(String osidPackageManagerName, String implPackageName, org.osid.OsidContext context, java.util.Properties additionalConfiguration) Returns an instance of the org.osid.OsidManager of the OSID specified by the OSID
package org.osid.OsidManager interface name and the implementation package name.
The implementation class name is constructed from the SID package
Manager interface name. |
getConfigStream | public static java.io.InputStream getConfigStream(String fileName, Class curClass)(Code) | | Get an InputStream for a particular file name - first check the sakai.home area and then
revert to the classpath.
This is a utility method used several places.
|
getManager | public static org.osid.OsidManager getManager(String osidPackageManagerName, String implPackageName, org.osid.OsidContext context, java.util.Properties additionalConfiguration) throws org.osid.OsidException(Code) | | Returns an instance of the org.osid.OsidManager of the OSID specified by the OSID
package org.osid.OsidManager interface name and the implementation package name.
The implementation class name is constructed from the SID package
Manager interface name. A configuration file name is constructed in a
similar manner and if the file exists it is loaded into the
implementation's org.osid.OsidManager's configuration.
Example: To load an implementation of the org.osid.Filing OSID
implemented in a package "xyz", one would use:
org.osid.filing.FilingManager fm =
(org.osid.filing.FilingManager)org.osid.OsidLoader.getManager(
"org.osid.filing.FilingManager" ,
"xyz" ,
new org.osid.OsidContext());
Parameters: osidPackageManagerName - osidPackageManagerName is a fullyqualified org.osid.OsidManager interface name Parameters: implPackageName - implPackageName is a fully qualifiedimplementation package name Parameters: context - Parameters: additionalConfiguration - org.osid.OsidManager throws: org.osid.OsidException - An exception with one of the followingmessages defined in org.osid.OsidException: org.osid.OsidException.OPERATION_FAILED OPERATION_FAILED,org.osid.OsidException.NULL_ARGUMENT NULL_ARGUMENT,org.osid.OsidException.VERSION_ERROR VERSION_ERROR,=org.osid.OsidException.INTERFACE_NOT_FOUNDINTERFACE_NOT_FOUND, =org.osid.OsidException.MANAGER_NOT_FOUND MANAGER_NOT_FOUND,=org.osid.OsidException.MANAGER_INSTANTIATION_ERRORMANAGER_INSTANTIATION_ERROR, =org.osid.OsidException.ERROR_ASSIGNING_CONTEXTERROR_ASSIGNING_CONTEXT, =org.osid.OsidException.ERROR_ASSIGNING_CONFIGURATIONERROR_ASSIGNING_CONFIGURATION |
|
|