Howto-Advanced

A way to construct hds on the fly: an example using Lucene
DatabaseTM: log file for single select

part of the upload file effort

During the early days of servlets I have used a trick to accomplish client side redirect after an update took place. This client side redirect will erase the update url from the browsers memory making the "back" and "refresh" buttons safe to the user.

Aspire depends on two data abstractions. One is a relational abstraction representing a collection of rows and columns and the other a hierarchical abstraction which is a grouping of the relational abstraction with a context. The central class in relational abstraction is represented by a type called IDataCollection. The hierarchical abstraction is represented by a type called "ihds".

This artilce gives sample code for how to do this

Aspire has facilities to allow for paging in large result sets coming from database. Usually rows from a database are listed as a table on the html page. In Aspire parlance this table is populated using a loop tag in the html file. The rows for that loop are retrieved using a loop definition in a properties file. The java class that usually does this work is called "GenericTableHandlerX". The nature of this handler is that it will retrieve the rows using a database cursor. This class does not allow to retrieve rows using a seek/get approach to retrieve a window of the result set. Such a pattern is necessary for effective paging. This facility is provided a java class called RandomTableHandlerX. This document explains this process using the RandomTableHandler7.

Description to be entered

aspire.sessionSupport.applySessionManagement=yes
aspire.sessionSupport.mainpage=/webapp/your-page-that-says-session-doesn't exist

aspire.authentication.userAuthorization=no
aspire.sessionSupport.applySessionManagement=yes
aspire.sessionSupport.mainpage=/webapp/your-page-that-says-session-doesn't exist
request.aspire.sessionSupport.sessionSupportObject.className=\
com.ai.servlets.ExternalSessionManager

Aspire has two features that work together in scheduling requests. A "request" in Aspire's parlance is a unit of work or at times called a task. So when you schedule a request, you are actually scheduling tasks at a given interval.

The scheduler that is available in Aspire is a very basic scheduler with minimal but sufficient-for-the-purpose capabilities. Using this scheduler you can schedule a task (a piece of java code) for every n number of timer ticks. A timer tick is defined as a certain number of seconds.

For a task to be invoked by a scheduler it had to be registered. This is where the initialization support in Aspire come into play. Initializers in Aspire allow you to run code at the start up time. You can read the document on initialization to learn more about the interfaces.

Describes what secure variables are and how to set them up in the properties file.

Choose a an authentication implementation that is appropriate in the aspire properties file. Here is an example with Trivial authentication.


request.aspire.authentication.authenticationObject.className=\
com.ai.aspire.authentication.TrivialAuthentication

request.aspire.authentication.authenticationObject.publicURLs=\
LoginPageURL,WelcomePublicJSPURL

request.aspire.authentication.authenticationObject.publicRequestNames=\
LoginRequest

See how public urls are defined as a comma separated list aspire url names. Also see how aspires update requests can also be mentioned as public.

Notice that the lines are broken for clarity. You may want to put them on the sameline

1. You will be using commons file upload plugin or part

2. You will need to add a url rewrite filter that comes with aspire to convert extra path to url arguments

3. You will "singlefileuploadpart" to parse the multipart upload

4. You will use a PSExecutor2 part to save it as a blob in the database

5. You can BlobTransform to write it back to the browser

An example to use while trying to upload files. This is one possible approach with out saving blobs. You will use the file system to store the files and use a database table to hold references to them. You will also see here how one can display the files.

HttpEvents is a concept where the application programmer can monitor what is happening in the application server. The programmer can monitor and responds to such events as session start, request begin, request end etc. The implementation is somewhat inspired by the global.asax file in the asp.net platform.

Receives a username and password and if they are valid it succeeds. if not an exception with an identifier of INVALID_PASSWORD is raised. One can use this exception to reroute to the same page or a different page.

It also looks at an aspire_target_url parameter and if present, indicates a redirector target as aspir_target_url_key=LOGIN_TARGET_PRESENT.

Aspire has a rudimentary scheduler in a package called com.ai.scheduler. This scheduler called BasicScheduler allows you to schedule tasks every 'n' number of intervals. Where an "interval" is defined as a time duration in milliseconds.

Here is a basic usage of the scheduler

ReusablePart

Calls another part or business logic, by translating the input arguments to match the expected names of the receiver

Additional property file arguments

1. originalNames: comma separated list of key names that needs to be copied from

2. newNames: comma separated list of keys to which the above key values will be copied to

3. propagateParams: yes|no: yes

4. reuseRequestName: Name of the reusable target request

if Propagateparams is "yes", then the incomign map is passed down. if it is set to "no" then a freshmap is created for the receiver Use "no" with caution, as this will result in a new transaction if the called parts have any database calls.

Output

1.resultName: What ever the target request returns

While programming databases it is important sometimes to prime the connection object. This is done by setting some additional attributes or parameters on a connection object using the "select" statements. As Aspire uses connection pools, the programmers rarely have control of the connection object directly (although it is possible). This facility is an attempt at providing a way to set these parameters using an event model.

you can use this part for introducing or copying existing keys as new keys.

Generic mappers are a set of java classes used to quickly read key value pairs. For example the relationship between file extension and their content type is determined this way.

This mechanism is intended to be a general purpose mechanism for reading a dictionary of values

The current implementation is a bit inefficient but a future implementation can amend that.

IfPart extends the functionality of the multi request executor (essentially an implementation of a sequential processing pipeline) for conditional purposes.

Aspire during startup can load classes implementing the "IApplicationInitializer" interface. These classes will be loaded as per the factory specification. This means the loaded class can be a single instance or a multi-instance. Once these classes are loaded their "initialize method gets called".

Description to be entered

request.putVariable2InSession.classname=com.ai.parts.SessionVariablesPart
request.putVariable2InSession.variableName=var1
request.putVariable2InSession.newVariableName=var2

The above code when embedded in a pipeline will take "var1" from the hashtable and places it in the session as "var2". If newVariableName is not mentioned then it will just put it as variableName

How to use SimpleDBAuthentication1 for login purposes.

The following example shows how to use substitution parts in your server side pipelines.

when you are working with web forms on a web browser, what the user types in on a form is called view state. If you were to return back to the form from the server side, you don't want the user to loose that data and reenter again. The process of managing that interaction is called view state management.

The context string looks like


<Context path="/akc" docBase="w:/satya/webapps/akc" debug="0"/>

The question is what is the parent node to the "Context" node. Here is the hierarchy in that xml file


<Server><Service><Engine><Host>
		<Context path="/akc" docBase="w:/satya/webapps/akc" debug="0"/>
</Host></Engine></Service></Server>

This is based on tomcat 5. Probably the same for earlier and later tomcats as well. But just check in case


public interface IAuthentication2 extends IAuthentication1
{
   //from original
   public boolean verifyPassword(final String userid, final String passwd ) 
      throws AuthorizationException;
      
   public boolean isAccessAllowed(final String userid, final String resource )
      throws AuthorizationException;
	  
   //from 1
   public boolean isAccessAllowed(final String userid
                                 , HttpServletRequest request
                                  ,HttpServletResponse response)
      throws AuthorizationException;

   //from 2	  
   public boolean isAPublicURL(HttpServletRequest request
                                  ,HttpServletResponse response)
      throws AuthorizationException;
}

part of the upload file effort

Some important log search strings
Description to be entered
Description to be entered
Description to be entered
Description to be entered
Description to be entered
Source code of Aspires session management: DefaultSessionSupport1
Description to be entered
Description to be entered
Supports the login process
Improves on the original version
Keeps the target url when directed
Further documentation will follow

Works like an oracle decoder for field values including default values

Description to be entered

In this article I want to explain an architectural model that I use often called "parts and pipelines" using an example. This model is especially useful in declrative programming. This article will start by introducing an example where a web page will update some content on the server side. The quoted example will be analyzed to explain parts, pipelines, and declarative programming. To further understand the details of a Part the source code for a "HelloWorldPart" is presented followed by the source code of 2 real world parts.

1. Inheriting from an abstract factory part
2. Handling exceptions
3. Common mistakes
4. Closing collections