13.07.2015 Views

Using the Caché %Installer Class - InterSystems Documentation

Using the Caché %Installer Class - InterSystems Documentation

Using the Caché %Installer Class - InterSystems Documentation

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong><strong>Class</strong>Version 2010.225 April 2011<strong>InterSystems</strong> Corporation 1 Memorial Drive Cambridge MA 02142 www.intersystems.com


<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong><strong>Caché</strong> Version 2010.2 25 April 2011Copyright © 2011 <strong>InterSystems</strong> CorporationAll rights reserved.This book was assembled and formatted in Adobe Page Description Format (PDF) using tools and information from <strong>the</strong> following sources:Sun Microsystems, RenderX, Inc., Adobe Systems, and <strong>the</strong> World Wide Web Consortium at www.w3c.org.The primary document developmenttools were special-purpose XML-processing applications built by <strong>InterSystems</strong> using <strong>Caché</strong> and Java.and<strong>Caché</strong> WEBLINK, Distributed Cache Protocol, M/SQL, M/NET, and M/PACT are registered trademarks of <strong>InterSystems</strong> Corporation., , and<strong>InterSystems</strong> Jalapeño Technology, Enterprise Cache Protocol, ECP, and <strong>InterSystems</strong> Zen are trademarks of <strong>InterSystems</strong> Corporation.All o<strong>the</strong>r brand or product names used herein are trademarks or registered trademarks of <strong>the</strong>ir respective companies or organizations.This document contains trade secret and confidential information which is <strong>the</strong> property of <strong>InterSystems</strong> Corporation, One Memorial Drive,Cambridge, MA 02142, or its affiliates, and is furnished for <strong>the</strong> sole purpose of <strong>the</strong> operation and maintenance of <strong>the</strong> products of <strong>InterSystems</strong>Corporation. No part of this publication is to be used for any o<strong>the</strong>r purpose, and this publication is not to be reproduced, copied, disclosed,transmitted, stored in a retrieval system or translated into any human or computer language, in any form, by any means, in whole or in part,without <strong>the</strong> express prior written consent of <strong>InterSystems</strong> Corporation.The copying, use and disposition of this document and <strong>the</strong> software programs described herein is prohibited except to <strong>the</strong> limited extentset forth in <strong>the</strong> standard software license agreement(s) of <strong>InterSystems</strong> Corporation covering such programs and related documentation.<strong>InterSystems</strong> Corporation makes no representations and warranties concerning such software programs o<strong>the</strong>r than those set forth in suchstandard software license agreement(s). In addition, <strong>the</strong> liability of <strong>InterSystems</strong> Corporation for any losses or damages relating to or arisingout of <strong>the</strong> use of such software programs is limited in <strong>the</strong> manner set forth in such standard software license agreement(s).THE FOREGOING IS A GENERAL SUMMARY OF THE RESTRICTIONS AND LIMITATIONS IMPOSED BY INTERSYSTEMSCORPORATION ON THE USE OF, AND LIABILITY ARISING FROM, ITS COMPUTER SOFTWARE. FOR COMPLETE INFORMATIONREFERENCE SHOULD BE MADE TO THE STANDARD SOFTWARE LICENSE AGREEMENT(S) OF INTERSYSTEMS CORPORATION,COPIES OF WHICH WILL BE MADE AVAILABLE UPON REQUEST.<strong>InterSystems</strong> Corporation disclaims responsibility for errors which may appear in this document, and it reserves <strong>the</strong> right, in its sole discretionand without notice, to make substitutions and modifications in <strong>the</strong> products and practices described in this document.For Support questions about any <strong>InterSystems</strong> products, contact:<strong>InterSystems</strong> Worldwide Customer SupportTel: +1 617 621-0700Fax: +1 617 374-9391Email: support@<strong>InterSystems</strong>.com


<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong><strong>%Installer</strong> is a class that lets you define an installation manifest that describes a resulting configuration. Instead of defininga step-by-step process, <strong>%Installer</strong> defines <strong>the</strong> finished configuration. Use XML tags to define <strong>the</strong> installation manifest,which generates code to configure <strong>the</strong> instance; in addition, parameters can be passed to fur<strong>the</strong>r control execution. The<strong>%Installer</strong> manifest can be invoked automatically during installation, from a terminal session (in <strong>the</strong> %SYS namespace), orwithin code.This article provides information about defining namespaces, databases, and mappings (global, routine, and package).<strong>Class</strong>es, routines, and globals can be loaded into a namespace defined in <strong>the</strong> installation manifest; <strong>the</strong>n <strong>%Installer</strong> cancompile <strong>the</strong> classes and routines making <strong>the</strong>m available for execution in <strong>the</strong> namespace in which <strong>the</strong>y are loaded. It includes<strong>the</strong> following topics:• <strong>Using</strong> <strong>the</strong> <strong>%Installer</strong> <strong>Class</strong>• Adding Users and Passwords• <strong>%Installer</strong> Tags• Invoking <strong>the</strong> <strong>%Installer</strong> <strong>Class</strong> Methods• Example of User-created <strong>%Installer</strong> <strong>Class</strong>1 <strong>Using</strong> <strong>the</strong> <strong>%Installer</strong> <strong>Class</strong>The following example illustrates <strong>the</strong> structure of an <strong>%Installer</strong> class:Include %occInclude<strong>Class</strong> MyPackage.MyInstaller{XData MyInstall [ XMLNamespace = INSTALLER ]{


Adding Users and Passwords}}<strong>Class</strong>Method setup(ByRef pVars, pLogLevel As %Integer, pInstaller As<strong>%Installer</strong>.Installer) As %Status [ CodeMode = objectgenerator,Internal ]{#; Let XGL document generate code for this method.Quit ##class(<strong>%Installer</strong>.Manifest).%Generate(%compiledclass,%code, "MyInstall")}Important:The %occInclude include file, which includes methods required by <strong>the</strong> <strong>%Installer</strong> class, must be specifiedat <strong>the</strong> beginning of every <strong>%Installer</strong> class you create.The name of <strong>the</strong> XData block (MyInstall) is used by <strong>the</strong> MyPackage.MyInstaller.setup method to generate <strong>the</strong> code forthat manifest, which is passed as <strong>the</strong> third argument of <strong>the</strong> <strong>%Installer</strong>.Manifest.%Generate() method.Note:Referencing XMLNamespace = INSTALLER provides Studio Assist capability while authoring your <strong>%Installer</strong>class.The outer-most xml tag, , contains all <strong>the</strong> information for code generation. There can be as many tags as needed within <strong>the</strong> tag to define namespaces in <strong>the</strong> manifest.A tag, which is located inside a tag, is required only if databases and/or mappingsare being defined. There must be as many tags within <strong>the</strong> tag as are needed to define<strong>the</strong> namespace. In addition, following each tag, you can add , ,and tags as required. The tag activates <strong>the</strong> defined mappings.Within <strong>the</strong> context of a tag — after <strong>the</strong> databases and <strong>the</strong>ir mappings have been defined — globals can beloaded, and routines and classes can be loaded and compiled using tag. <strong>Class</strong> methods can be invoked using<strong>the</strong> tag. Invoked class methods can execute routines and access globals that have been imported.Optionally, you can define variable pairs with <strong>the</strong> tag; each variable must specify a name and value. When <strong>the</strong> valuefor <strong>the</strong> is needed, <strong>the</strong> name is referenced by <strong>the</strong> ${NameAssigned} syntax.2 Adding Users and PasswordsYou can add users (including <strong>the</strong>ir roles and passwords) with <strong>the</strong> System Management Portal, or you can use <strong>the</strong> Security.Usersclass on a staging instance of <strong>Caché</strong> or Ensemble as follows:1. Export <strong>the</strong> user information by using <strong>the</strong> Security.Users.Export() method.2. Import <strong>the</strong> user information by adding <strong>the</strong> following at <strong>the</strong> beginning of your <strong>%Installer</strong> class (in <strong>the</strong> %SYS namespace):where PathToExportedUserInformation is <strong>the</strong> location of <strong>the</strong> output file specified in <strong>the</strong> Security.Users.Export()method.3 <strong>%Installer</strong> TagsFollowing are descriptions of <strong>the</strong> tags (in alphabetical order) you can use in your <strong>%Installer</strong> class.Note:Values shown in italics are <strong>the</strong> defaults used if <strong>the</strong> setting is not specified explicitly.2 <strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong>


<strong>%Installer</strong> TagsOptional; within . Defines package mapping for <strong>the</strong> namespace. For example:Optional; within . Defines a class name to be compiled. For example:Required; within . Contains namespace configuration tags for databases and mapping. For example:The closing tag ( activates <strong>the</strong> mappings for <strong>the</strong> databases in a namespace to update <strong>the</strong> .cpffile.Optional; within . Defines a class to be copied from a source to a target. For example:Optional; within . Defines a directory to be copied from a source to a target. For example:Optional; within . Defines a file to be copied from a source to a target. For example:Optional; within . Defines one or more CSP applications; <strong>the</strong> supported au<strong>the</strong>ntication flags are 4(Kerberos), 32 (Password), and 64 (Unau<strong>the</strong>nticated). For example:<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong> 3


<strong>%Installer</strong> TagsRequired; within . Defines one or more databases used in <strong>the</strong> namespace. For example:Optional; within . Defines values for each iteration of <strong>the</strong> specified index key. For example:


<strong>%Installer</strong> TagsOptional; within . Defines class methods to execute routines and access globals that have beenimported. For example:"RetVal" can <strong>the</strong>n be used as a variable (${RetVal}).Required. Contains <strong>the</strong> installation instructions (all o<strong>the</strong>r tags). For example:Required; within . One for each namespace. For example:Optional; within . Defines a role. For example:Optional; within . Defines routine mapping for <strong>the</strong> namespace. For example:Optional; within . Sets any Config class that implements <strong>the</strong> Modify method. For example:Optional; within . Defines a user; if PasswordVar is specified, <strong>the</strong> user password must be providedin <strong>the</strong> referenced variable name. For example:<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong> 5


Invoking <strong>the</strong> <strong>%Installer</strong> <strong>Class</strong> MethodsOptional; within . Defines variables that can be used with <strong>the</strong> manifest. For example:For a comprehensive example of a user-defined installer class, see Sample.Installer in <strong>the</strong> SAMPLES namespace.For an up-to-date list of tags and attributes, see <strong>the</strong> <strong>%Installer</strong> class documentation.4 Invoking <strong>the</strong> <strong>%Installer</strong> <strong>Class</strong> MethodsYou can invoke <strong>the</strong> <strong>%Installer</strong> class as follows:• In <strong>the</strong> %SYS namespace, enter <strong>the</strong> following command in <strong>the</strong> <strong>Caché</strong> Terminal:%SYS> Do ##class(MyPackage.MyInstaller).setup()You can pass an array by reference to <strong>the</strong> setup() method where <strong>the</strong> subscript is used as a variable in <strong>the</strong> and <strong>the</strong> node value is <strong>the</strong> variable . For example:%SYS> Set vars("SourceDir")="c:\myinstaller"%SYS> Set vars("Updated")="Yes"%SYS> Do ##class(MyPackage.MyInstaller).setup(.vars,3)where <strong>the</strong> second parameter (3) is <strong>the</strong> log level.• Export <strong>the</strong> <strong>%Installer</strong> class as DefaultInstaller<strong>Class</strong>.xml to <strong>the</strong> same directory where <strong>the</strong> <strong>Caché</strong> install (ei<strong>the</strong>r.msi, setup_cache.exe, or cinstall) is run. It is imported into %SYS, compiled, and <strong>the</strong> setup() method is executed.Note:If you use <strong>the</strong> export technique, you cannot pass arguments to <strong>the</strong> setup() method.On Microsoft Windows systems, you can modify <strong>the</strong> .msi install package to pass variable pairs to <strong>the</strong> setup()method. Alternatively, you can use command-line arguments to pass <strong>the</strong> location of <strong>the</strong> exported <strong>%Installer</strong>class and variables, as shown in <strong>the</strong> following example:setup_cache.exe INSTALLERMANIFEST="c:\MyStuff\MyInstaller.xml"INSTALLERMANIFESTPARAMS="SourceDir=c:\mysourcedir,Updated=Yes"On UNIX®/Linux systems, set environment variables to define <strong>the</strong> location of <strong>the</strong> exported <strong>%Installer</strong> classand variable pairss, as shown in <strong>the</strong> following example:ISC_INSTALLER_MANIFEST=c:\MyStuff\MyInstaller.xmlISC_INSTALLER_PARAMETERS=SourceDir=c:\mysourcedir,Updated=Yescinstall6 <strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong>


Example of User-created <strong>%Installer</strong> <strong>Class</strong>5 Example of User-created <strong>%Installer</strong> <strong>Class</strong>The following class creates a namespace (MyNamespace) and three databases; two of <strong>the</strong> databases are defined as <strong>the</strong>default databases for globals (MyDataDB) and routines (MyRoutinesDB), while <strong>the</strong> third database (MyMappingDB) is aglobals database that overrides <strong>the</strong> default database mapping for t* globals in <strong>the</strong> MyNamespace namespace.Note:For a more comprehensive example of a user-defined installer class, see Sample.Installer in <strong>the</strong> SAMPLESnamespace.Include %occInclude/// Simple example of installation instructions (Manifest)<strong>Class</strong> MyInstallerPackage.SimpleManifest{XData SimpleManifest [ XMLNamespace = INSTALLER ]{}/// This is a method generator whose code is generated by XGL.<strong>Class</strong>Method setup(ByRef pVars, pLogLevel As %Integer,pInstaller As <strong>%Installer</strong>.Installer) As %Status[ CodeMode = objectgenerator, Internal ]{#; Let our XGL document generate code for this method.Quit ##class(<strong>%Installer</strong>.Manifest).%Generate(%compiledclass,%code, "SimpleManifest")}}After <strong>the</strong> class is compiled, you can invoke it in <strong>the</strong> <strong>Caché</strong> Terminal as shown below (assuming you created <strong>the</strong> class in<strong>the</strong> USER namespace):%SYS> znspace "USER"USER> do ##class(MyInstallerPackage.SimpleManifest).setup()<strong>Using</strong> <strong>the</strong> <strong>Caché</strong> <strong>%Installer</strong> <strong>Class</strong> 7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!