Tips for Deploying SakaiAhren Stevens-Taylor
The benefits of knowing that frameworks exist
Sakai is built on top of numerous third-party open source libraries and frameworks. Why write code for converting from XML text files to Java objects or connecting and managing databases, when others have specialized and thought out the technical problems and found appropriate and consistent solutions? This reuse of code saves effort and decreases the complexity of creating new functionality. Using third-party frameworks has other benefits as well; you can choose the best from a series of external libraries, increasing the quality of your own product. The external frameworks have their own communities who test them actively. Outsourcing generic requirements, such as the rudiments of generating indexes for searching, allows the Sakai community to concentrate on higher-level goals, such as building new tools.
For developers, also for course instructors and system administrators, it is useful background to know, roughly, what the underlying frameworks do:
- For a developer, it makes sense to look at reuse first. Why re-invent the wheel? Why write with external framework X for manipulating XML files when other developers have already extensively tried and tested and are running framework Y? Knowing what others have done saves time. This knowledge is especially handy for the new-to-Sakai developers who could be tempted to write from scratch.
- For the system administrator, each framework has its own strengths, weaknesses, and terminology. Understanding the terminology and technologies gives you a head start in debugging glitches and communicating with the developers. For a manager, knowing that Sakai has chosen solid and well-respected open source libraries should help influence buying decisions in favor of this platform.
- For the course instructor, knowing which frameworks exist and what their potential is helps inform the debate about adding interesting new features. Knowing what Sakai uses and what is possible sharpens the instructors’ focus and the ability to define realistic requirements.
- For the software engineering student, Sakai represents a collection of best practices and frameworks that will make the students more saleable in the labor market.
Using the third-party frameworks
This section details frameworks that Sakai is heavily dependent on: Spring (http://www.springsource.org/), Hibernate ((http://www.hibernate.org/), and numerous Apache projects (http://www.apache.org/). Generally, Java application builders understand these frameworks. This makes it relatively easier to hire programmers with experience.
All projects are open source and the individual use does not clash with Sakai’s open source license (http://www.opensource.org/licenses/ecl2.php).
The benefit of using Spring
Spring is a tightly architected set of frameworks designed to support the main goals of building modern business applications. Spring has a broad set of abilities, from connecting to databases, to transaction, managing business logic, validation, security, and remote access. It fully supports the most modern architectural design patterns.
The framework takes away a lot of drudgery for a programmer and enables pieces of code to be plugged in or to be removed by editing XML configuration files rather than refactoring the raw code base itself. You can see for yourself; this is the best framework for the user provider within Sakai. When you log in, you may want to validate the user credentials using a piece of code that connects to a directory service such as LDAP , or replace the code with another piece of code that gets credentials from an external database or even reads from a text file. Thanks to Sakai’s services that rely on Spring! You can give (called injecting) the wanted code to a Service manager, which then calls the code when needed.
In Sakai terminology, within a running application a service manager manages services for a particular type of data. For example, a course service manager allows programmers to add, modify, or delete courses. A user service manager does the same for users.
Spring is responsible for deciding which pieces of code it injects into which service manager, and developers do not need to program the heavy lifting, only the configuration. The advantage is that later, as a part of adapting Sakai to a specific organization, system administrators can also reconfigure authentication or many other services to tailor to local preferences without recompilation.
Spring abstracts away underlying differences between different databases. This allows you to program once, each for MySQL , Oracle , and so on, without taking into account the databases’ differences. Spring can sit on the top of Hibernate and other limited frameworks, such as JDBC (yet another standard for connecting to databases). This adaptability gives architects more freedom to change and refactor (the process of changing the structure of the code to improve it) without affecting other parts of the code. As Sakai grows in code size, Spring and good architectural design patterns diminish the chance breaking older code.
To sum up, the Spring framework makes programming more efficient. Sakai relies on the main framework. Many tasks that programmers would have previously hard coded are now delegated to XML configuration files.
Hibernate for database coupling
Hibernate is all about coupling databases to the code. Hibernate is a powerful, high performance object/relational persistence and query service. That is to say, a designer describes Java objects in a specific structure within XML files. After reading these files, Hibernate gains the ability to save or load instances of the object from the database. Hibernate supports complex data structures, such as Java collections and arrays of objects. Again, it is a choice of an external framework that does the programmer’s dog work, mostly via XML configuration.
The many Apache frameworks
Sakai is biased rightfully towards projects associated with the Apache Software Foundation (ASF) (http://www.apache.org/). Sakai instances run within a Tomcat server and many institutes place an Apache web server in front of the Tomcat server to deal with dishing out static content (content that does not change, such as an ordinary web page), SSL/TLS, ease of configuration, and log parsing. Further, individual internal and external frameworks make use of the Apache commons frameworks, (http://commons.apache.org/) which have reusable libraries for all kinds of specific needs, such as validation, encoding, e-mailing, uploading files, and so on. Even if a developer does not use the common libraries directly, they are often called by other frameworks and have significant impact on the wellbeing; for example, security of a Sakai instance.
To ensure look and feel consistency, designers used common technologies, such as Apache Velocity, Apache Wicket , Apache MyFaces (an implementation of Java Server Faces), Reasonable Server Faces (RSF) , and plain old Java Server Pages (JSP)
Apache Velocity places much of the look and feel in text templates that non-programmers can then manipulate with text editors. The use of Velocity is mostly superseded by JSF. However, as Sakai moves forward, technologies such as RSF and Wicket (http://wicket.apache.org/) are playing a predominate role.
Sakai uses XML as the format of choice to support much of its functionality, from configuration files, to the backing up of sites and the storage of internal data representations, RSS feeds, and so on. There is a lot of runtime effort in converting to and from XML and translating XML into other formats. Here are the gory technical details: there are two main methods for parsing XML:
- You can parse (another word for process) XML into a Document Object Model (DOM) in the memory that you can later transverse and manipulate programmatically.
- XML can also be parsed via an event-driven mechanism where Java methods are called, for example, when an XML tag begins or ends, or there is a body to the tag.
Programmatically simple API for XML (SAX) libraries support the second approach in Java. Generally, it is easier to program with DOM than SAX, but as you need a model of the XML in memory, DOM, by its nature, is more memory intensive. Why would that matter? In large-scale deployments, the amount of memory tends to limit a Sakai instance’s performance rather than Sakai being limited by the computational power of the servers. Therefore, as Sakai heavily uses XML, whenever possible, a developer should consider using SAX and avoid keeping the whole model of the XML document in memory.
Looking at dependencies
As Sakai adapts and expands its feature set, expect the range of external libraries to expand.
The table mentions libraries used, their links to the relevant home page, and a very brief description of their functionality.
|Apache-Axis||http://ws.apache.org/axis/||SOAP web services|
|SOAP, REST web services. A total rewrite of Apache-axis. However, not currently used within Entity Broker, a Sakai specific component.
|Apache Commons||http://commons.apache.org||Lower-level utilities|
|Batik||http://xmlgraphics.apache.org/batik/||Batik is a Java-based toolkit for applications or applets that want to use images in the Scalable Vector Graphics (SVG) format.|
|Commons-beanutils||http://commons.apache.org/beanutils/||Methods for Java bean manipulation|
|Commons-codec||http://commons.apache.org/codec||Commons Codec provides implementations of common encoders and decoders, such as Base64, Hex, Phonetic, and URLs.|
|Commons-digester||http://commons.apache.org/digester||Common methods for initializing objects from XML configuration|
|Commons-httpclient||http://hc.apache.org/httpcomponents-client||Supports HTTP-based standards with the client side in mind|
|Commons-validator||http://commons.apache.org/validator||Support for verifying the integrity of received data|
|FOP||http://xmlgraphics.apache.org/fop||Print formatting ready for conversions to PDF and a number of other formats|
|Hibernate||http://www.hibernate.org||ORM database framework|
|Content repository. A content repository is a hierarchical content store with support for structured and unstructured content, full text search, versioning, transactions, observation, and more.|
|James||http://james.apache.org||A mail server|
|Java Server Faces||http://java.sun.com/javaee/javaserverfaces||Simplifies building user interfaces for JavaServer applications|
|MyFaces||http://myfaces.apache.org||JSF implementation with implementation-specific widgets|
|Pluto||http://portals.apache.org/pluto||The Reference Implementation of the Java Portlet Specfication|
|Reasonable Server Faces (RSF)||http://www2.caret.cam.ac.uk/rsfwiki||RSF is built on the Spring framework, and simplifies the building of views via XHTML.|
|ROME||https://rome.dev.java.net||ROME is a set of open source Java tools for parsing, generating, and publishing RSS and Atom feeds.|
|SAX||http://www.saxproject.org||Event-based XML parser|
|STRUTS||http://struts.apache.org/||Heavy-weight MVC framework, not used in the core of Sakai, but rather some components used as part of the occasional tool|
|Spring||http://www.springsource.org||Used extensively within the code base of Sakai. It is a broad framework that is designed to make building business applications simpler.|
|Wicket||http://wicket.apache.org||Web app development framework|
|Xalan||http://xml.apache.org/xalan-j||An XSLT (Extensible Stylesheet Language Transformation) processor for transforming XML documents into HTML, text, or other XML document types|
For the reader who has downloaded and built Sakai from source code, you can automatically generate a list of current external dependencies via Maven. First, you will need to build the binary version and then print out the dependency report. To achieve this from within the top-level directory of the source code, you can run the following commands:
mvn -Ppack-demo install mvn dependency:list
The table is based on an abbreviated version of the dependency list, generated from the source code from March 2009.
For those of you wishing to dive into the depths of Sakai, you can search the home pages mentioned in the table.
In summary, Spring is the most important underlying third-party framework and Sakai spends a lot of its time manipulating XML.