The Structure of the Development Environment


Before learning how to extend the development environment, it's important that you understand how it works. This section explains the directory layout and some of the files involved. The environment you create for your own applications will have the same structure.

The Development Environment Directory Layout

We refer to the directory into which you copied the source files from this book's CD-ROM as the source code base directory. Throughout this book, the name of this directory is assumed to be C:\SQL-NS, although you can give it any name you choose.

The following directories exist under the source code base directory:

  • The Common directory contains files shared by the code for all the sample SQL-NS instances.

  • The Chapters directory contains supplementary files and scripts referred to in this book's various chapters.

  • The Samples directory contains the source code and build scripts for all the sample SQL-NS instances described in this book.

  • The Tools directory contains the executable files and source code for the custom tools used in the setup of the development environment and in some of the instructions in various chapters.

The Samples directory has a subdirectory called Minimal, which contains the source files for a minimal SQL-NS instance with one application. When you create a new SQL-NS instance, you begin by copying source code for this minimal instance. This gives you a working skeleton of a SQL-NS instance and application to which you can add your own code. The section "Extending the Development Environment" (p. 651) describes the exact steps in this process.

Each of the sample subdirectories within the Samples directory contains the code for a complete SQL-NS instance. Throughout the remainder of this appendix, I refer to these directories as instance directories because each one encapsulates the source code for an instance. The directories you create for new SQL-NS instances of your own will have a structure similar to these sample instance directories, so it's important to understand their subdirectory layout. The following subdirectories exist beneath all sample instance directories:

  • The Scripts subdirectory contains the batch files used to create, update, delete, register, unregister, enable, and disable the instance, as well as grant the required database and filesystem permissions.

  • A unique application subdirectory for each application in the instance contains the applications' source files. The name of each application subdirectory is the name of the application it contains. For example, in the MusicStore instance, the application name is SongAlerts, so there is a SongAlerts subdirectory.

The directories you create for your instances will also have a Scripts subdirectory containing the build scripts and an application directory for each application.

Important Files in the Development Environment

In the Common directory under the source code base directory, the setenv.cmd file sets up the environment variables used by the build scripts in all the instance directories. These environment variables provide the location of the source code base directory, the name of the SQL Server, the name of the service user, the SQL authentication mode, and other required information. When you completed the instructions given in the "Environment Variables" section (p. 36) in Chapter 2, you edited setenv.cmd to customize the environment variables for your system.

Each instance directory also contains a file called setenv.cmd in its Scripts subdirectory. All the build scripts (batch files that invoke nscontrol create, nscontrol update, and so on) in the Scripts subdirectory call this local setenv.cmd file before invoking any operations. The local setenv.cmd file in the Scripts subdirectory first calls the common setenv.cmd file (in the Common directory, one level up) and then sets up additional environment variables specific to the instance. This establishes the complete environment, including common and instance-specific parts, required by the commands in the build scripts.

Note

Most of the build scripts in the Scripts directory are explained in detail in Chapter 4, "Working with SQL-NS Instances."


As long as the environment variables in the local and common setenv.cmd files are set correctly, the build scripts will work for any instance. When you create a new instance, you usually don't have to change the common setenv.cmd file. However, you will have to create an instance-specific setenv.cmd file in the Scripts subdirectory of the instance directory to establish the instance-specific part of the environment for building the new instance. The "Creating the Directories and Files for a New Instance" section (p. 652) later in this appendix provides instructions for doing this.




Microsoft SQL Server 2005 Notification Services
Microsoft SQL Server 2005 Notification Services
ISBN: 0672327791
EAN: 2147483647
Year: 2006
Pages: 166
Authors: Shyam Pather

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net