This document describes how you can use the scriptable administration objects to automate deployment and distribution of your MTS packages. The MTS Explorer lets you configure and deploy packages by using a graphical user interface rather than by programming code. However, you can use the scriptable administrative objects to automate administration tasks, such as program configuration and deployment. Note that the scriptable administrative objects support the same collection hierarchy as the MTS Explorer. The following figure shows the MTS Explorer collection hierarchy.
For more information about MTS Explorer functionality, see the Administrator's Guide.
Using the Scriptable Administration Objects
Microsoft Transaction Server contains Automation objects that you can use to program administrative and deployment procedures, including:
The scriptable administration objects are derived from the IDispatch interface, so you can use any Automation language to develop your package, such as Microsoft® Visual Basic® version 5.0, Microsoft Visual C++® version 5.0, Microsoft Visual Basic® Scripting Edition (VBScript), and Microsoft JScript™.
Each folder in the MTS Explorer hierarchy corresponds to a collection stored in the catalog data store. The following scriptable objects are used for administration:
The Catalog, CatalogObject, and CatalogCollection scriptable objects provide top-level functionality such as creating and modifying objects. The Catalog object enables you to connect to specific servers and access collections. Call the CatalogCollection object to enumerate, create, delete, and modify objects, as well as to access related collections. CatalogObject allows you to retrieve and set properties on an object. The Package, Component, Remote Component, and Role objects enable more specific task automation, such as installing components and exporting packages. This utility layer allows you to program very specific tasks for collection types, such as associating a role with a user or class of users.
The following diagram illustrates how the MTS scriptable administration objects interact with the MTS Explorer catalog:
Interface | Description |
---|---|
ICatalog | The Catalog object enables you to connect to specific servers and access collections. |
ICatalogCollection | The CatalogCollection object can be used to enumerate objects, create, delete, and modify objects, and access related collections. |
ICatalogObject | The CatalogObject object provides methods to get and set properties on an object. |
IPackageUtil | The IPackageUtil object enables a package to be installed and exported within the Packages collection. |
IComponentUtil | The IComponentUtil object provides methods to install a component in a specific collection and to import components registered as an in-process server. |
IRemoteComponentUtil | You can use the IRemoteComponentUtil object to program your application to pull remote components from a package on a remote server. |
IRoleAssociationUtil | Call methods on the IRoleAssociationUtil object to associate roles with a component or component interface. |
For example, you can automate creating a new package and installing components into the new package by using the scriptable objects in the utility layer (Package, Component, Remote Component, and Role objects).
The following Visual Basic sample shows how to use the scriptable administration objects to create and install components into a new package named "My Package."
Dim catalog As Object
Dim packages As Object
Dim newPack As Object
Dim componentsInNewPack As Object
Dim util As Object
On Error GoTo failed
Set catalog = CreateObject("MTSAdmin.Catalog.1")
Set packages = catalog.GetCollection("Packages")
Set newPack = packages.Add
Dim newPackID As String
newPackID = newPack.Key
newPack.Value("Name") = "My Package"
packages.savechanges
Set componentsInNewPack =
packages.GetCollection("ComponentsInPackage",
newPackID)
Set util = componentsInNewPack.GetUtilInterface
util.InstallComponent"d:\dllfilepath", "", ""
Exit Sub
failed:
MsgBox "Failure code " + Str$(Err.Number)
End Sub
For a complete description of how to program these procedures and more sample code, refer to the Administrator’s Guide.