Seam-Perf4j
Perf4j integration for Seam Framework
 

Documentation

Available documentation:


Getting started guide

Maven configuration

For Maven projects it's required to add seam-perf4j dependency to application's pom.xml:

<dependency>
    <groupId>net.sf.seam.perf4j</groupId>
    <artifactId>seam-perf4j</artifactId>
    <version>0.4.0</version>
</dependency>

Thanks to OSS Repository Hosting provided by Sonatype Seam-Perf4j's JARs are available in Maven Central Repository. Above configuration in pom.xml should be enough to add a dependency to any application builds with Maven 2.

Note: Seam-Perf4j is designed to be used in applications that are using Seam itself. Seam's artifacts are not available in Central Maven Repository, so it is assumed everyone interested would have JBoss Maven repository configured in his/her settings.xml already. If not following repository should be added in settings.xml located in user's home directory:

<repositories>
    (... - some other repositories)
    <repository>
        <id>jboss</id>
        <url>http://repository.jboss.com/maven2</url>
        <releases>
            <enabled>true<enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

Seam configuration

It is required to register additional interceptor 'org.sf.seam.perf4j.Perf4jProfiledInterceptor' in components.xml in Seam application to profile. In there is registered some custom interceptor already it is enough to just add mentioned value into section, if not all default Seam interceptors have to registered directly. For Seam 2.2.0.GA it would be:

<core:init>
<core:interceptors>
    
    <value>org.jboss.seam.core.SynchronizationInterceptor</value>
    <value>org.jboss.seam.async.AsynchronousInterceptor</value>
    <value>org.jboss.seam.ejb.RemoveInterceptor</value>
    <value>org.jboss.seam.persistence.HibernateSessionProxyInterceptor</value>
    <value>org.jboss.seam.persistence.EntityManagerProxyInterceptor</value>
    <value>org.jboss.seam.core.MethodContextInterceptor</value>
    <value>org.jboss.seam.core.EventInterceptor</value>
    <value>org.jboss.seam.core.ConversationalInterceptor</value>
    <value>org.jboss.seam.bpm.BusinessProcessInterceptor</value>
    <value>org.jboss.seam.core.ConversationInterceptor</value>
    <value>org.jboss.seam.core.BijectionInterceptor</value>
    <value>org.jboss.seam.transaction.RollbackInterceptor</value>
    <value>org.jboss.seam.transaction.TransactionInterceptor</value>
    <value>org.jboss.seam.webservice.WSSecurityInterceptor</value>
    <value>org.jboss.seam.security.SecurityInterceptor</value>
    
    <value>org.sf.seam.perf4j.Perf4jProfiledInterceptor</value>
</core:interceptors>
</core:init>

Application configuration

The last step is to annotate profiled method:

@Perf4jProfiled
@Profiled(tag = "profiledMethodTag")
public void profiledMethod() {...}

Note: Due to Seam limitation in interceptors configuration in XML, it's required to use marker @Perf4jProfiled annotation to associate interceptor with a method in addition to original @Profiled annotation from Perf4j. Starting from version 0.4.0 @Profiled annotation can be omitted (logging with default values takes place then).

After execution of profiled method(s) you should be able to see message similar to following in the application log:

INFO  [org.perf4j.TimingLogger] start[1267557706784] time[1075] tag[profiledMethodTag]
   

Happy profiling with Seam and Perf4j!