# Overview of configuration services

Orion provides a number of service APIs related to service configuration. This page explains the service configuration APIs. For a basic overview of Orion's service architecture, see Architecture.

## Managed Services

A service may need configuration information before it can perform its intended functionality. Such services are called Managed Services . A Managed Service implements a method, `updated()`, which is called by the Orion configuration framework to provide configuration data to the service. As with all service methods, `updated()` is called asynchronously. The configuration data takes the form of a dictionary of key-value pairs, called properties. If no configuration data exists for the Managed Service, `null` properties are passed.

A Managed Service needs to receive its configuration information before the service is invoked to perform other work. For example, a configurable validation service would want to receive any custom validation options (or `null`, if no custom options were configured) before actually performing any validation. For this reason, the framework guarantees that a Managed Service's `updated()` method will be called prior to any other service methods the service may implement.

To contribute a Managed Service, we register a service having the name orion.cm.managedservice. Every Managed Service must provide a service property named `"pid"` which gives a PID (persistent identifier). The PID serves as primary key, uniquely identifying the configuration information of a Managed Service.

The Orion concept of a Managed Service is analogous to the OSGi Managed Service.

## Meta Typing

A Metatype describes the shape of configuration data*. In other words, it specifies what property names can appear in the properties dictionary, and what data types their values may have (string, boolean, number, etc). Metatype information is defined in terms of Object Class Definitions (OCDs), which can be reused. Metatype information is associated with a Managed Service's PID. Metatype information is optional, so not every Managed Service need have Metatype information associated with it.

Metatype information can be contributed by registering a service with the orion.cm.metatype service name.

The Orion concept of a Metatype is analogous to the OSGi Metatype.

  * In this page we discuss Metatype information solely in the context of configuration management. Strictly speaking, Metatypes are generic, and can be used for other purposes.

## Configuration management

Configuration data is managed by a ConfigurationAdmin service, which maintains a database of Configuration objects. The ConfigurationAdmin monitors the service registry and provides configuration data to Managed Services that are registered. Orion's implementation of ConfigurationAdmin persists configuration data to a Preferences Service.

In JavaScript code, configuration information is represented as `Configuration` objects, which are returned by the ConfigurationAdmin's service methods. (Refer to "orion.cm.Configuration" in the client API reference for JSDoc.) Because the ConfigurationAdmin service is currently only accessible to code running in the same window as the service registry, Configuration objects cannot be directly interacted with by external services. Therefore a plugin's Managed Services can only receive configuration information via their `updated()` method.

The Orion ConfigurationAdmin service is analogous to the OSGi ConfigurationAdmin.

## Settings

On top of the basic configuration and metatype APIs, Orion also provides a higher-level Settings API. See Plugging into the settings page for details.