Abstract Manager Pattern

OsidManagers made easy.

Overview

The OsidManager is the gateway into a domain. It is initialized by the OSID Runtime and then asked to open OsidSessions. With this family of classes, you override only the pieces your implementation supports to save on implementing methods your implementation does not support.

OsidManagers do not hold domain OsidObjects directly — they hold the configuration and credentials needed to open OsidSessions, and they delegate state to those sessions. Think of an OsidManager as a hub to OsidSessions.

The other method to override is initialize(OsidRuntimeManager). This is where you will put in your startup instructions such as acquiring and setting your configuration. The base AbstractOsidManager defines utility methods for making queries to the built-in Configuration OSID.

Javadoc Reference

net.okapia.osid.jamocha.spi

Class Declaration Pattern

public abstract class AbstractOsidObjectManager
extends AbstractOsidManager
implements OsidObjectManager

Constructor Pattern

AbstractOsidObjectManager(net.okapia.osid.provider.ServiceProvider provider)

This abstract class requires a ServiceProvider which contains the service provider identity. The runtime calls initialize(OsidRuntimeManager) after construction to pull in configuration.

Tools

AbstractOsidManager already implements the identity methods — getId(), getDisplayName(), getDescription(), getVersion(), getReleaseDate(), getLicense(), getProviderId(), getProvider() and getBranding() — by reading from the ServiceProvider passed through the constructor, so a subclass rarely touches them. What a subclass does reach for is the set of protected tools below: profile declarations it calls once during setup, and helpers it uses from initialize() and its session factories.

Loading dependent managers. Use these to obtain other OSID services your implementation builds on. Both throw IllegalStateException if the manager has not been initialized.

ToolDescription
getOsidManager(OSID, implClassName) Instantiates and initializes another OsidManager through the loader.
getOsidProxyManager(OSID, implClassName) Instantiates and initializes an OsidProxyManager through the loader.

Getting configuration. These query the built-in Configuration OSID and are the everyday tools inside initialize(). Each throws IllegalStateException if the manager is not yet initialized.

ToolDescription
getConfigurationValue(Id) Returns the single most-preferred Value for a parameter; throws ConfigurationErrorException if none is set.
getConfigurationValues(Id) Returns all applicable Values for a parameter as a ValueList.

Typed configuration convenience getters. Each has the form getXxxConfigurationValue(Id parameterId, Xxx defaultValue) and returns the parameter's value coerced to that type, falling back to defaultValue (which may be null) when the parameter is absent. One exists for each configuration value type:

GetterReturns
getBooleanConfigurationValueBoolean
getBytesConfigurationValuebyte[]
getCardinalConfigurationValueLong
getCoordinateConfigurationValueCoordinate
getCurrencyConfigurationValueCurrency
getDateTimeConfigurationValueDateTime
getDecimalConfigurationValueBigDecimal
getDisplayTextConfigurationValueDisplayText
getDurationConfigurationValueDuration
getHeadingConfigurationValueHeading
getIdConfigurationValueId
getIntegerConfigurationValueLong
getObjectConfigurationValueObject
getSpeedConfigurationValueSpeed
getStringConfigurationValueString
getTimeConfigurationValueTime
getTypeConfigurationValueType
getVersionConfigurationValueVersion

Runtime access. The runtime captured at initialize() is the gateway to the rest of the OSID installation. The above tools remove the need for direct access to the runtime in most cases.

ToolDescription
getRuntime() Returns the OsidRuntimeManager stored during initialize().
setRuntime(OsidRuntimeManager) Replaces the runtime environment.

Declaring what Proxy the service supports..

ToolDescription
addProxyRecordType(Type) Declares support for a proxy record type for use in OsidProxyManagers.
removeProxyRecordType(Type) Withdraws support for a previously declared proxy record type.