public class OsidLoader extends Object implements Serializable
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 MIT
O.K.I. OSID Definition License.
| Constructor and Description |
|---|
OsidLoader() |
| Modifier and Type | Method and Description |
|---|---|
static 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.
|
static org.osid.OsidManager |
getManager(String osidPackageManagerName,
String implPackageName,
org.osid.OsidContext context,
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.
|
public static org.osid.OsidManager getManager(String osidPackageManagerName, String implPackageName, org.osid.OsidContext context, Properties additionalConfiguration) throws org.osid.OsidException
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());
osidPackageManagerName - osidPackageManagerName is a fully
qualified org.osid.OsidManager interface nameimplPackageName - implPackageName is a fully qualified
implementation package namecontext - additionalConfiguration - org.osid.OsidException - An exception with one of the following
messages defined in org.osid.OsidException: OPERATION_FAILED,
NULL_ARGUMENT,
VERSION_ERROR,
=INTERFACE_NOT_FOUND, =MANAGER_NOT_FOUND,
=MANAGER_INSTANTIATION_ERROR, =ERROR_ASSIGNING_CONTEXT, =ERROR_ASSIGNING_CONFIGURATIONpublic static InputStream getConfigStream(String fileName, Class curClass)
Copyright © 2004–2020 Indiana University Library Information Technology. All rights reserved.