ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.


AddThis Social Bookmark Button

For Tomcat Developers, Aspire Comes in a JAR

by Satya Komatineni

Aspire.jar: Utility for Data Access, Configuration, Logging, and Factory Needs

Aspire.jar is a free, open source, .jar file that can be used for declarative data access, configuration, logging, and factory services needs. For Java developers who are continuing to adopt Tomcat as their primary development platform, this .jar file could save lot of time, while providing a highly flexible data architecture. Aspire.jar is only about 500K and unintrusive in your applications. Installation is as simple as downloading and including the .jar file in the appropriate classpath. You can start putting the .jar file to good use as soon as you finish this article.

So what can you do with Aspire?

  • Use it for a very flexible data access library: Imagine retrieving and updating data without ever thinking about connections, databases, commits, rollbacks, etc. Imagine having all of your SQL externalized into config files so that it stays out of your pure Java code. Imagine swapping your data sources between flat files, SQL, stored procedures, CICS transactions, etc. Imagine also not changing your client code a bit while you are doing this. Imagine transactional capability across multiple data access components. Aspire provides all of this in a very small package.

  • Use it to dynamically instantiate run time objects: Aspire provides a mechanism that allows you to instantiate objects from your config files. The factory service allows you to have single-instance and multi-instance support for your instantiated objects. This is a good compromise between object pools and programmer convenience.

  • Use it for business components and their declarative composition: Data access components are a special case of an Aspire component/part called a business component. You can write specialized business components that are similar to session beans, but that can be run either on the Tomcat tier or the EJB tier (via a transactional bridge). You can combine business components, including the prebuilt ones, into higher-level composite components, allowing process flow orchestration.

  • Use it for configuration and logging: All of the above are accomplished via configuration files. Aspire supports multiple config files that get included in a master config file. This allows for multiple modules and multiple developers to keep configuration where it belongs instead of pouring all of the configuration into one file. You can include config files, the format of which can be either XML or classic properties. That means you can have one config file in properties format and one file in XML format, but programmers will access them using the same simplified API. Aspire provides a logging API with swappable logging implementations. Thus, If you use Log4J, for instance, you can plug Log4J into Aspire so that all of Aspire's logging will go through Log4J, providing better debugging capabilities.

Getting Started

Source Files

Download the needed files as a single .zip file. This file contains the following:

The original text of this article
Open free license to use the .jar file

You need two files to get started: Aspire's .jar file and a master properties file that goes with it. Both of these files are included in the .zip file. Cut and paste the aspire.properties file to create the needed properties file out of it.

Aspire's .jar file is typically named aspire_r2.0_b16.3_jsdk21.jar. This indicates that Aspire is in release 2.0, build 16.3, using the Servlets 2.1 standard, and is backward compatible with all future releases of the Servlets API.

Aspire's properties file is usually named aspire.properties and is typically placed under the /properties subdirectory of webapp root. This properties file helps you to obtain configuration information, logging information, factory objects, etc., including the externalized data access such as SQL, stored procedures, and others.

Initialize Aspire in Tomcat

To use Aspire's .jar in your Java code, you first initialize Aspire with its properties file. Although this can be done programmatically, Aspire provides a startup servlet called AppInitServlet1 for initializing Aspire under Tomcat.

Here is the portion of the web.xml file that will allow you to initialize Aspire under Tomcat environment:


AppInitServlet1 takes a parameter named AppConfigFilename. The value of this parameter points to a config filename. This filename can be absolute or relative to the webapp root directory. Follow the appropriate file-naming conventions for your platform (Unix or NT). Depending on the version of Tomcat that you are running, find a way to have this initialization servlet configured.

Aspire looks for aspire.properties in the properties subdirectory. A sample aspire.properties file is attached at the end of this document. For the initialization to complete successfully, you also need a log setting at the top of this aspire.properties.

Logging.msgLevel = 0
# Logging.selectiveFilters=cp:,sc:,db:
# Logging.excludeFilters=vectorMetadata:,dbrs:,

You can point the log file anywhere in the system. Make sure the directory exists. Aspire will create the log file every time it runs. It will log an error to the console if this file is not found. Also beware of Unix/NT file-naming conventions.

You can use the selectiveFilters and the excludeFilters to choose which log messages you want to see and which you don't. SelectiveFilters is a comma-separated list of strings. If a log message starts with any one of these strings, that message will be printed; otherwise, not. Same thing with excludeFilters, except that the matching log messages will be excluded. Some sample patterns are mentioned above.

You will know that your initialization is successful when you see a series of Aspire-related messages on your Tomcat console. These messages will start with the version of Aspire, what log file it is using, and from which properties files it is loading. If you don't see these messages, check your log file path. For any issues, email me at .

Pages: 1, 2, 3, 4, 5

Next Pagearrow