How to work with directory aliases in Aspire

Aspire being an application server that serves html files on request, Aspire needs a way to locate these html files. Aspire also delivers these html files based on a mapping between a url name and the real html template file. Aspire gathers this information from properties or configuration files. As a result Aspire also need to read these files from the disk.

Based on where Aspire is installed the path to these files may be different. To take this into account Aspire has a concept called directory aliases. Here is an example:

directories.mydir1=c:\some-root-dir1\subdir
directories.mydir2=c:\some-root-dir2\subdir

The above two lines will define two directory aliases to aspire: "mydir1" and "mydir2" pointing to the specified directory on the machine. The directory aliases will work for both unix and windows as well. In unix you will use the unix syntax and in windows you will use the windows syntax for specifying the directories. Once these aliases are defined here is how these aliases are used subsequently:


myweb-url=mydir1:\a\b\c.html

The above code will use the html file called "c.html" as the template for delivering content for the requested "myweb-url". But the point I want to emphasize here is that the file "c.html" will be located using the directory alias called "mydir1" which will translate into "c:\some-root-dir1\subdir". Ultimately the resulting file path will be "c:\some-root-dir1\subdir\a\b\c.hmtl".

Reserved/Predefined directory aliases

As Aspire runs under Tomcat or an equivalent J2EE server, it is considered a web application. Tomcat can host multiple web applications. Each web application will have its own root directory where files are hosted. You can define any root directory on your file system to be the root directory for tomcat. But depending on the installation this can be anywhere. Aspire when it starts running it asks the tomcat what this root directory is. The answer to that it keeps in a reserved directory alias called "aspire". For example say that you have installed your web application in "c:\myroot". With the reserved directory alias this is equivalent to


directories.aspire=c:\myroot

You don't have to add the above line but you can assume it to be there and use that alias. This is the recommended way to do it as this alias will adjust based on where you have installed things. This is also important when you start delivering things as war files.

The directory alias of "aspire:" will work with log file spec as well


Logging.logfile=aspire:\\log\\akc.log
Logging.msgLevel = 1
Logging.trace=no
Logging.selectiveFilters=Error:

See how the log file is specified interms of "aspire:" as well.

The directory alias of "aspire:" will work with included properties files as well


application.includeFiles=aspire:\\samples\\hello-world\\properties\\hello-world.properties,\
aspire:\\samples\\hello-world-japanese\\properties\\hello-world-japanese.properties,\
aspire:\\samples\\hello-world-jsp\\properties\\hello-world-jsp.properties,\
aspire:\\samples\\pop-table-tags\\properties\\pop-table.properties,\
aspire:\\samples\\pop-table-jsp\\properties\\pop-table-jsp.properties,\
aspire:\\samples\\pop-table-xsl\\properties\\pop-table-xsl.properties,\
aspire:\\samples\\xml-reader\\xml-reader.properties,\
aspire:\\properties\\database.properties,\
aspire:\\properties\\aspire_sequences.properties,\
aspire:\\properties\\user_login.properties,\
aspire:\\reports\\reports.properties,\
aspire:\\reports\\news\\news.properties,\
aspire:\\reports\\notes\\notes.properties,\
aspire:\\reports\\users\\users.properties,\
aspire:\\reports\\home\\home.properties,\
aspire:\\reports\\home\\header-footer.properties,\
aspire:\\reports\\report-filing\\report-filing.properties,\
aspire:\\reports\\blogs\\blogs.properties,\
aspire:\\sql-explorer\\sql-explorer.properties

Here is how the aspire: is used in defining display urls


###################################
# contributorsURL
###################################
contributorsURL=aspire:\\reports\\home\\users.html
contributorsURL.formHandlerName=contributorsURLFormHandler
request.contributorsURLFormHandler.form_handler.class_request.className=\
com.ai.htmlgen.DBHashTableFormHandler1

contributorsURLFormHandler.loopNames=usersLoop

#
# List of contributors
#
request.contributorsURLFormHandler.usersLoop.class_request.className=\
com.ai.htmlgen.GenericTableHandler6

request.contributorsURLFormHandler.usersLoop.query_request.className=\
com.ai.db.DBRequestExecutor2

request.contributorsURLFormHandler.usersLoop.query_request.db=reportsDB

request.contributorsURLFormHandler.usersLoop.query_request.stmt=\
	select user_id, first_name,middle_name,last_name,email \
	from users \
	where active='Y'