Instancing Overview

Applies To: System Center 2012 - Service Manager

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

In Service Manager, enterprise management object (EMO) instances are created from management pack classes and are stored in the database. A management pack class object is represented by the ManagementPackClass class. This class provides the definition of a management pack class, and is used when you are creating enterprise management objects. To create a new EMO instance, use the CreatableEnterpriseManagementObject class. This class has a constructor that accepts an instance of the ManagementPackClass object you want to create the EMO from. Then set the values of all the applicable properties on that EMO and commit it to Service Manager which will store the object in the database. When the EMO instance is later retrieved from Service Manager, it is represented by the EnterpriseManagementObject class.

When an EMO is created and stored in the database, an EMO instance is created for each class throughout the inheritance chain. For example, say you have three classes, each inherits from the next: C, B, and A. If an instance of class C was created and committed to the database, an instance of B and A would also be created behind the scenes and stored in the database together with C. This is because C cannot live without an instance of B and B cannot live without an instance of A. Even though each object exists on its own, they are all kept together through the inheritance chain. The class used to create the initial object (in our example class C) represents the absolute object instance.

Getting Instances

Once an EMO instance is stored in the database, it can be retrieved directly through the EMO’s unique identifier, by its class definition, or by query criteria. The unique identifier of an EMO is a GUID.

Getting an object by its unique identifier is very straight forward. However, when you would do this is not. When you are working with a workflow or analyzing and manipulating an object you already know about, you will most likely be using the GUID to retrieve the object. The EnterpriseManagementGroup object you used to connect to the database has a property named EntityObjects which has a method named GetObject. This method takes a GUID and returns you the EMO object matching that GUID. Additionally, if you have a list of GUIDs that you want to obtain all the objects for, you can call the one of the overloads for the method GetObjectReader.

If you do not know the specific object you want, but know what type of object you want, than you can get all EMO instances of a specific ManagementPackClass. One of the overloads for the method GetObjectReader will take a management pack class and return you all the EMO objects based on that class.

Queries help you get all objects of a specific type based on some the criteria you provide. It works very similar to obtaining all EMO instances of a specific management pack class. When you call the GetObjectReader method, one of the overloads takes an instance of the EnterpriseManagementObjectCriteria class. This class contains all the criteria for your search. This lets you filter out objects you do not want. For example, if you wanted to obtain all software titles in the database, but only wanted software from a specific publisher, you could create and use a criteria object to represent that condition.

Properties of Instances

When accessing the properties of an EMO instance, you must provide the class definition that describes the properties you want. The class definition provides a map of what the EMO instance resembles. For example, if we were to describe a chair through a class named Chair, we could have the base class be Stool. If Stool defined the count of legs, and Chair inherited from Stool, Chair would also have the count of legs. However, when we have a Chair instance, and want to access the properties that Stool provided, we need the class definition for Stool, and the EMO instance of Chair.

When an EMO is created from a management pack class, all of the key properties of each class in the inheritance chain must be set. The combination of all key properties creates the unique footprint of the object and uniquely identifies the object. For more information about properties, see Model.

See Also

Reference

ManagementPackClass
CreatableEnterpriseManagementObject
EntityObjects
EnterpriseManagementObjectCriteria

Other Resources

Instancing
Scenario: Working with Instances
Modeling