Another Maven success story: Acegi Security System for Spring

Another project I have just migrated to Maven is the Acegi Security System for Spring. The folder layout was changed (retaining CVS history) to use Maven suggestions, although it’s not needed. The core, subprojects, samples and docs (including docbook generation) were migrated from ant.

Maven multiproject: sharing common files between subprojects

Are you using multiproject and want to use common files in all your subprojects?

Then you can define a variable “rootdir” pointing to the dir where common files are stored, so they can be refered as ${rootdir}/filename, both in your properties (project.properties, build.properties) and project.xml files.

To do so you just need to create a maven.xml in the top level project (supposing you have a LICENSE.txt in the top level dir, you can use any other file). This var will point to the same dir from every subproject.

<project
   xmlns:j="jelly:core"
   xmlns:ant="jelly:ant"
   xmlns:util="jelly:util"
   xmlns:maven="jelly:maven">

    <!-- =========== Set root dir =========== -->

    <j:set var="rootdir">${basedir}</j:set>

    <j:while test="${true}">
        <util:available file="${rootdir}/LICENSE.txt">
            <j:break/>
        </util:available>
        <j:set var="rootdir">${rootdir}/..</j:set>
    </j:while>

    <ant:dirname property="rootdirname" file="${rootdir}/project.xml"/>
    <j:set var="rootdir">${rootdirname}</j:set>
    <echo>Using root dir: ${rootdir}</echo>

</project>

You’d like to set some properties using this new var

# License plugin settings
maven.license.licenseFile=${rootdir}/LICENSE.txt

# multiproject
maven.multiproject.basedir=${rootdir}

Understanding Portlets and Portals

A good introduction to the JSR-168 Portlet standard:
Understanding Portals and Portlets by Kenneth Ramirez

Spring Framework 1.1.2

Spring Framework 1.1.2 has just been released. As before it will be available to Maven users in the ibiblio central repository in a few hours.

Unfortunately this release has a bug and is not compatible with Java 1.3.

Check the announcement:

ANNOUNCEMENT: We are pleased to announce that Spring Framework 1.1.2 has just been released. This is a bugfix and minor enhancement release.
 
Among the new features in this release are:
 

  • added support for multi-dimensional collections to BeanWrapperImpl (e.g. “map[myKey][0]” or “map[myKey][0].name”)
  • added “getType(name)” method to BeanFactory interface, checking the type of object that “getBean” would return
  • added “getBeansOfType(type)” convenience method to ListableBeanFactory interface, without explicit filters
  • added PropertyPathFactoryBean, allowing to evaluate the property path of a target bean and expose the result
  • allow “bean*” rather than “bean+” in XML bean definitions, i.e. no bean definitions in a file (just imports)
  • AbstractApplicationContext automatically registers a context-aware ResourceArrayPropertyEditor for Resource arrays
  • added GenericApplicationContext class, allowing for arbitrary definition formats (via a single internal BeanFactory)
  • improved ResourceBundleMessageSource and ReloadableResourceBundleMessageSource implementations
  • added “setText(plainText, htmlText)” method to MimeMessageHelper, for alternative texts in the same mail
  • added “objectResult(collection,type)” and “intResult”/”longResult(collection)” convenience methods to DataAccessUtils
  • added support for pre-bound Sessions (e.g. OpenSessionInViewFilter/Interceptor) with JTA and TransactionManagerLookup
  • added “load(entity, id)” method to HibernateOperations and HibernateTemplate
  • added “initialize” and “closeIterator” methods to HibernateOperations/Template, following “Hibernate.initialize/close”
  • added “queryCacheRegion” property to HibernateTemplate, specifying the cache region used for queries
  • added ServletContextResourcePatternResolver, to find matching resources within a web app even in an unexpanded WAR
  • added “defaultStatusCode” property to SimpleMappingExceptionResolver, specifying the HTTP status code for error views
  • UrlBasedViewResolver supports a “redirect:” prefix now, for convenient redirects through special view names
  • added “springMessage”/”springMessageText” macros for Velocity and “message”/”messageText” macros for FreeMarker

As always, have a look at the changelog for details.
Downloads are available through the SourceForge project page [2004-11-14]

Note that this Spring distribution comes with an updated HSQLDB version, namely 1.7.2.7. Unfortunately, the HSQLDB 1.7.2 branch is incompatible with 1.7.1 in some areas. While all Spring sample apps have been adapted accordingly, please be aware that if you do decide to update your own applications with the new hsqldb.jar, you must also update your server instance (i.e. both need to run version 1.7.2), and any existing db data files may need to be upgraded. Furthermore, be aware that JBoss <= 3.2.5 shipped with HSQLDB 1.7.1 in the server classpath, while 3.2.6+ include HSQLDB 1.7.2.

Struts 2.0 “Shale”

Struts 2.0 “Shale” is now a proposal. There are plans to include new features: IoC (Spring), authentication and authorization (here it’s my vote for Acegi Security System), and Java Server Faces JSF for presentation.

Read more at

Tomcat in high volume sites

Looking for the convenience of using Tomcat in a high volume, mission critical site I’ve found some references that may be useful to other people:

Clustering and Load Balancing in Tomcat 5. Part 1

Clustering and Load Balancing in Tomcat 5. Part 2

The book Professional Apache Tomcat 5 (Programmer to Programmer) seems interesting too, with chapters “Server Load Testing” and “Clustering”.

The only benchmark I’d found is Jakarta Tomcat Performance Benchmark at TSS but it’s from march 2003, very outdated. When trying to convince a boss to use Tomcat it’d be interesting real world success stories and benchmarks.

White Book of the CMS Open Source solutions

The french company Smile has a document about the CMS Open Source, a small comparison but a very interesting document. You can get it form their site but take into account that it’s wrotten in french.

Showing latest comments in roller

Some time ago I found they way to show the latest weblog comments in roller. I found it a very cool feature for both writers, as jroller doesn’t email comments, and readers to check comments in all entries.

You can check the sources for the two files needed:

You can also add #showRecentCommentsListWidth(20 75) to show the titles of the recent comments

Thanks to Lance

Java open source CMS

After following some links my Java open source CMS list has grown:

Lenya seems a good option, maybe I’m too fan of Apache Foundation.

I’ll make a comparison between them, checking

  • Support of standard portlets JSR-168
  • Internationalization (content and administration)
  • Search of web and documents
  • Performance and cluster support
  • License style and price (GPL may be inappropiate)
  • Support available
  • More to come…

It’ll be a good boost for the project chosen by my company because we develop CMS for major enterprises and government institutions.

Update: Added Magnolia

Maven2

As I’m getting involved in the Maven2 core development, I’ll be writing down my experiencies, so they can be useful for other people.

Features of Maven2:

  • Transitive dependency resolution, say projectA depends on projectB and projectB depends on projectC, then you just need to declare projectB dependency in projectA and projectC will be automatically discovered
  • No more Jelly, you can use POJOs, they’re called MOJOs ;), it’s a funny name in spanish, also used in Austin Powers movie
  • Promotes a standarised directory layout
  • Allows a better repository layout, more scalable, and based on internet domain names

Resources of interest are:

To build it you need to run the bootstrapping process, typing java -jar mboot.jar in the maven-components dir, after creating a ~/.m2/override.xml file that must contain the following entries:

<local>
  <repository>/path/to/m2/repository</repository> (required)
  <online>true</online> (optional)
</local>

Alternatively, you can specify -Dmaven.repo.local=/path/to/m2/repository. Maven2 will be installed in ~/m2.