Extending Saké


Structure
All of the actual operations that a Saké application performs are implemented via JavaBeans modules that conform to standard interfaces. Endymion generally provides these modules in several different varieties, so that you can create a custom Saké installation that suits your site. In many cases, customers choose to create their own modules and plug them in to Saké in order to integrate specific features into an existing framework.

As an example of how the Saké extension mechanism works, take a look at Figure 1. In this illustration, we have a Saké application that has some specific task. In performing that task, the Saké application needs to perform two critical operations, it needs to store and retrieve application data in some persistent manner, and it needs to maintain a log of its output. The default configuration of this Saké application uses an "XML File" extension bean for each of these tasks, meaning that the provided modules implement their tasks by reading and writing XML files to the local file system.


Figure 1: A Saké application that uses XML file modules to implement its tasks.

In Figure 2, we see the exact same Saké application, but this installation has been configured to use extension modules that implement their tasks by connecting to SQL databases.


Figure 2: The same Saké application using SQL databases on the back end.

In Figure 3, we see the same application again, but this time using one XML file module and one SQL database module. Saké is intentionally designed to allow administrators to mix and match back-end modules, so that they can create installations with complete flexibility.


Figure 3: The same Saké application with modules that use different back-end storage systems.

Each Saké application needs to perform different tasks. For example, Saké Mail has a module for storing user messages, another module for implementing address book functionality, another module for implementing user options storage, etc. For specific details on configuring extension beans for your Saké application installation, see the "Extending" section for your specific Saké application.

If you are interested in developing custom modules to replace certain existing Saké extension beans, contact Endymion Corporation technical support at support@endymion.com for information on accessing example source code and specific assistance for your unique situation. Assistance with the extension mechanism is included in our standard licensing agreements.


Example
As an example, there is only one type of extension bean that is supported by every Saké application at the Saké framework level. The "LogBean" interface specifies the behavior that is necessary for a Saké application to produce logs at runtime. The specification for a "LogBean" is very simple, a "LogBean" only needs to support two methods, "prepareLog()" and "logEvent()".

Endymion provides one implementation of the "LogBean" interface, a bean called "TextFileLogBean". You can invoke this bean from your "general.ini" initialization file by adding the following:


<extension-bean kind="Log" class="com.endymion.sake.servlet.beans.TextFileLogBean">

<!-- The file name of your log output. -->
<parameter type="String" name="FileName" value="/var/log/sake.log" />

<!-- The level of detail of your output. -->
<parameter type="Int" name="LogDetailLevel" value="3" />

<!-- Whether the log should append when the server is
restarted, or be overwritten. -->
<parameter type="Boolean" name="Append" value="true" />

</extension-bean>


The above example will create a log of the application's output in the file "/var/log/sake.log". As in the above example, extension beans are invoked by specifying their Java class name in the configuration file for the Saké application that they will operate under. The initialization file tag "extension-bean" specifies the beginning of an extension bean invocation. The parameter "kind" specifies exactly what kind of bean you are specifying. Some varieties of bean must be configured in order for the Saké application to run. For example, Saké Mail cannot operate without a bean configured to implement the "MessageStore" functionality. Other types of beans are optional. For example, the above bean is optional, without it the Saké application will simply write log output to standard output, and no log file will be created. Some extension beans can even be chained. An example of this is also the above logging bean. You can create several log beans in a single Saké application. For example, adding the following to your "general.ini" initialization file will result in your Saké application creating two different logs at runtime, at two different levels of detail:


<extension-bean kind="Log" class="com.endymion.sake.servlet.beans.TextFileLogBean">

<!-- The file name of your log output. -->
<parameter type="String" name="Filename" value="/var/log/sake.1.log" />

<!-- The level of detail of your output. -->
<parameter type="Int" name="LogDetailLevel" value="3" />

<!-- Whether the log should append when the server is
restarted, or be overwritten. -->
<parameter type="Boolean" name="Append" value="true" />

</extension-bean>

<extension-bean kind="Log" class="com.endymion.sake.servlet.beans.TextFileLogBean">

<!-- The file name of your log output. -->
<parameter type="String" name="Filename" value="/var/log/sake.3.log" />

<!-- The level of detail of your output. -->
<parameter type="Int" name="LogDetailLevel" value="3" />

<!-- Whether the log should append when the server is
restarted, or be overwritten. -->
<parameter type="Boolean" name="Append" value="false" />

</extension-bean>


The above example will create two different logs at runtime, "/var/log/sake.1.log", which has a level of detail of 1, and "/var/log/sake.3.log", which has a level of detail of 3. Since the second log will be much more detailed and therefore much larger, it is configured to be overwritten each time the application restarts.


TemplateSelectorBean
TemplateSelector beans can be used to determine a default template set for a given browser. You can build your own TemplateSelector bean, which will be invoked any time that a Saké application needs to decide what "skin" to use for a new browser. You can use this mechanism to provide a customized interface to Palm VII users, WAP users, and different interfaces to different web browsers and versions, for instance. You could also use the bean to automatically provide different language translations to users based on what URL they use to access the installation.

Copyright © 1999 - 2002 Endymion Corporation
All rights reserved.
Carpe Noctem