<?xml version="1.0" encoding="UTF-8"?>
<rss version='2.0' xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">
    <channel>
        <!-- This XML Feed shows details for the page Spring&#039;s corner -->
        <creativeCommons:license>http://creativecommons.org/licenses/by-sa/2.5/</creativeCommons:license>
        <title>Spring&#039;s corner</title>
        <link>http://swik.net/Spring%2FSpring%26%23039%3Bs+corner</link>
        <description>&lt;p&gt;Thoughts and articles on Spring&lt;/p&gt;
</description>
                <category>Spring</category>

        <pubDate>Tue, 18 Oct 2005 14:19:46 -0700</pubDate>
        <lastBuildDate>Tue, 18 Oct 2005 14:19:46 -0700</lastBuildDate>
            
        <item>
            <title>Integrate P6Spy with Spring</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Integrate+P6Spy+with+Spring/besz4</link>
            <description>&lt;br/&gt;&lt;br/&gt;

&lt;p&gt;P6Spy is a tool to &lt;b&gt;debug JDBC&lt;/b&gt; interaction with a database. It&#039;s a &lt;b&gt;wrapper&lt;/b&gt; of all JDBC elements ( Connection, PreparedStatement, ResultSet... ) and it has a powerful feature in order to log all informations about those interactions.&lt;/p&gt;

&lt;p&gt;JDBC wrapper is described in the &lt;a href=&quot;http://www.oreilly.com/catalog/javapt2/&quot;&gt;&quot;Java Performance Tuning&quot;&lt;/a&gt; book of Jack Shirazi ( O&#039;Reilly) in the chapter 16.&lt;/p&gt;

&lt;p&gt;All elements wrappers have a constructor with the element to wrap. We can use it but there is another mode for datasource. This last mode must be used to wrap a datasource defined in an application server for example.&lt;/p&gt;

&lt;p&gt;However since we can manage our objects ( &lt;b&gt;beans&lt;/b&gt; ) in Spring ( and datasources too ), it&#039;s possible to add a P6Spy datasource and link it with the real datasource with constructor injection.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;

&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; 
                   &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&amp;gt;

&amp;lt;beans&amp;gt;
    &amp;lt;bean id=&quot;myDataSourceTarget&quot; 
          class=&quot;org.apache.commons.dbcp.BasicDataSource&quot;
          destroy-method=&quot;close&quot;&amp;gt;
        &amp;lt;property name=&quot;driverClassName&quot;&amp;gt;
            &amp;lt;value&amp;gt;org.hsqldb.jdbcDriver&amp;lt;/value&amp;gt;
        &amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;url&quot;&amp;gt;
            &amp;lt;value&amp;gt;jdbc:hsqldb:hsql://localhost:9001&amp;lt;/value&amp;gt;
        &amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;username&quot;&amp;gt;&amp;lt;value&amp;gt;sa&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;password&quot;&amp;gt;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;
    &amp;lt;/bean&amp;gt;

    &amp;lt;bean id=&quot;myDataSource&quot; class=&quot;com.p6spy.engine.spy.P6DataSource&quot; 
                                                 destroy-method=&quot;close&quot;&amp;gt;
        &amp;lt;constructor-arg&amp;gt;
            &amp;lt;ref local=&quot;myDataSourceTarget&quot;/&amp;gt;
        &amp;lt;/constructor-arg&amp;gt;
    &amp;lt;/bean&amp;gt;

&amp;lt;/beans&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Moreover a p6spy.log file must be add to the classpath of the application to specify the location of the log file.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
module.log=com.p6spy.engine.logging.P6LogFactory

executionthreshold=
outagedetection=false
outagedetectioninterval=
filter=false
include     = 
exclude     =
sqlexpression = 
autoflush   = true
dateformat=
includecategories=
excludecategories=info,debug,result,batch

stringmatcher=
stacktraceclass=

reloadproperties=false
reloadpropertiesinterval=60

useprefix=false

appender=com.p6spy.engine.logging.appender.FileLogger
logfile     = c:/spy.log

append=true

log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=p6spy - %m%n

log4j.logger.p6spy=INFO,STDOUT

&lt;/pre&gt;

&lt;p&gt;The output can be graphically view with a tool like &lt;a href=&quot;http://www.irongrid.com/documentation/irontracksql/indexIronTrackSQL.html&quot;&gt;Iron Track SQL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The advantages of this solution are the following:&lt;/p&gt;
&lt;li&gt;It isn&#039;t necessary to modify the configuration of the application server datasource in order to integrate P6Spy.&lt;/li&gt;
&lt;li&gt;The use of P6Spy is much easier. No deep knowledge of the format
of the P6Spy configuration file is required ( only specify the location of log file ).&lt;/li&gt;&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>My blog has moved...</title>
            <link>http://swik.net/Spring/Spring%27s+corner/My+blog+has+moved.../besz3</link>
            <description>	&lt;p&gt;&lt;p&gt;I have moved my old blog on this blog with a new skin. You can have access to my old entries at the following url: &lt;a href=&quot;http://templth.blogspot.com&quot;&gt;http://templth.blogspot.com&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>JMX notifications with Spring</title>
            <link>http://swik.net/Spring/Spring%27s+corner/JMX+notifications+with+Spring/besz2</link>
            <description>&lt;p&gt;The Spring framework offers a great support of JMX. The aims of this support are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;automatically convert simple beans into MBeans&lt;/li&gt;
&lt;li&gt;automatically register simple beans and MBeans declaratively&lt;/li&gt;
&lt;li&gt;configure an embedded JMX server&lt;/li&gt;
&lt;li&gt;configure JMX connectors to access to the components of the agent layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this time, the support doesn&#039;t include JMX notifications but it&#039;s planned for the version 1.3RC2. See the issue SPR-680 in JIRA:
&lt;a href=&quot;http://opensource2.atlassian.com/projects/spring/browse/SPR-680&quot;&gt;http://opensource2.atlassian.com/projects/spring/browse/SPR-680&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have developped some code to implement this issue. Its aims are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;provide a way to add/remove JMX listeners on registred MBeans based on their object names&lt;/li&gt;
&lt;li&gt;provide a way to add/remove JMX listeners on simple beans and MBean exported on the JMX server with Spring facilities.&lt;/li&gt;
&lt;li&gt;offer an abstraction to allow bean or MBean exported with to send notifications&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Add/remove JMX listeners on registered MBeans&lt;/h3&gt;

&lt;p&gt;The aim of this part is to add/remove listeners on MBean not registered with Spring facilities. The common example is to listen events triggered by the MBean server delegate. This entity sends notifications on register/unregister MBean events. The following listing shows how to configure it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;delegateListeners&quot; class=&quot;org.springframework.jmx.export.notifier.NotifierFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;server&quot;&amp;gt;&amp;lt;ref local=&quot;mbeanServer&quot;/&amp;gt;&amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;objectName&quot;&amp;gt;
    &amp;lt;value&amp;gt;
      JMImplementation:type=MBeanServerDelegate
    &amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;listener&quot; class=&quot;TestNotificationListener&quot;/&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The class testNotificationListener is a classic JMX notification listener as shown in the following listing:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class TestNotificationListener
                 implements NotificationListener {
  public void handleNotification(
                 Notification notification, Object handback) {
    System.out.println(&quot;Notification received.&quot;);
    System.out.println(&quot; -&gt; &quot;+notification);
  }
}
&lt;/pre&gt;

&lt;p&gt;The listener receives the following notifications for example:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
Notification received.
 -&gt; javax.management.MBeanServerNotification
          [source=JMImplementation:type=MBeanServerDelegate]
                       [type=JMX.mbean.registered][message=]
Notification received.
 -&gt; javax.management.MBeanServerNotification
          [source=JMImplementation:type=MBeanServerDelegate]
          [type=JMX.mbean.unregistered][message=]
&lt;/pre&gt;

&lt;h3&gt;Add/remove JMX listeners on MBeans registered with Spring&lt;/h3&gt;

&lt;p&gt;The support distinguishes two possibilities according to the kind of instance to export.&lt;/p&gt;

&lt;p&gt;First the bean ot export is &lt;b&gt;a simple bean not tied with JMX&lt;/b&gt;. In this case, the JMX support of Spring uses model MBean to convert the bean into an MBean according to different strategies to know attributes and methods to expose. The RequiredModelMBean already implements the NotificationBroadcaster, so there is nothing to do, but the listeners must be added not on the bean but on the created model MBean.&lt;/p&gt;

&lt;p&gt;Secondly the bean is &lt;b&gt;a MBean (so tied with JMX)&lt;/b&gt;. In this case, the support looks if the MBean implements the &lt;code&gt;NotificationBroadcaster&lt;/code&gt;. This JMX interface allows MBean to register and unregister notification listeners.&lt;/p&gt;

&lt;p&gt;If not, AOP is used to add this interface to the bean with the method introduction feature. The implementation of this interface is the GenericBroadcaster class based on the &lt;code&gt;NotificationBroadcasterSupport&lt;/code&gt; of JMX.&lt;/p&gt;

&lt;p&gt;The following listing shows an example of use in this case.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    &amp;lt;map&amp;gt;
      &amp;lt;entry key=&quot;bean:name=testBean1&quot;
                value-ref=&quot;testBean&quot;/&amp;gt;
      &amp;lt;entry key=&quot;bean:name=testBean2&quot;
                value-ref=&quot;testSimpleBean&quot;/&amp;gt;
    &amp;lt;/map&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;server&quot; ref=&quot;mbeanServer&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;listener&quot; class=&quot;TestNotificationListener&quot;/&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Send notifications from simple beans and MBeans registered with Spring&lt;/h3&gt;

&lt;p&gt;To send a notification, the simple bean or the MBean needs an abstraction. This abstraction must just have a method to send a notification. I define the Notifier interface as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public interface Notifier {
  void notify(NotificationCreator creator,Object handback);
}
&lt;/pre&gt;

&lt;p&gt;One of the challenge is to give an instance of this interface. The simple bean or MBean must tell the JMX support that it can accept this by implementing the NotifierAware interface. It works like the other *Aware interfaces (ApplicationContextAware, BeanFactoryAware) in Spring. If the support detects this interface, it will call the method setNotifier on it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public interface NotifierAware {
  void setNotifier(Notifier notifier);
}
&lt;/pre&gt;

&lt;p&gt;The following listing shows an example to send a notification.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class MyBean
  public void test() {
    notifier.notify(new NotificationCreator() {
      public Notification createNotification() {
        return new Notification(&quot;test&quot;,this,0);
      }
    },null);
  }

  public void setNotifier(Notifier notifier) {
    System.out.println(&quot;TestSimpleBean.setNotifier&quot;);
    this.notifier=notifier;
  }
}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: I have a doubt about the utility of the NotificationCreator which offers a callback to create the Notification. As a matter of fact, the creation of a notification instance is just a new... I&#039;m thinking of removing it.&lt;/p&gt;

&lt;h3&gt;Improve the support&lt;/h3&gt;

&lt;p&gt;An improvement could be the support of filter for notification and the management of the handback instance...&lt;/p&gt;

&lt;p&gt;To be continued ;-)&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>JMX notifications with Spring (2)</title>
            <link>http://swik.net/Spring/Spring%27s+corner/JMX+notifications+with+Spring+%282%29/besz1</link>
            <description>&lt;p&gt;The second part of the thread describe the end of the support of JMX notifications in Spring. Like the previous one, it describes the patch I have written to address the issue SPR-680 in JIRA.&lt;/p&gt;

&lt;p&gt;See the second zip file (SpringJMX_Notification_v1.1.zip) on the issue for the implementation of this patch.&lt;/p&gt;

&lt;h3&gt;Support of filters&lt;/h3&gt;

&lt;p&gt;When a JMX notification listener is added to an MBean, you can pass a filter to select notifications the listener will accept. In our case, we use the class NotificationFilterSupport which implements NotificationFilter and allow configure the allow and deny of notifications types.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class NotificationListenerSupport {
  ...
  public synchronized boolean isNotificationEnabled(
                       Notification notification) {...}
  public synchronized void enableType(String type)
               throws IllegalArgumentException {...}
  public synchronized void disableType(String type) {...}
  public synchronized void disableAllTypes() {...}
  public synchronized Vector getEnabledTypes() {...}
  ...
}
&lt;/pre&gt;

&lt;p&gt;To associate filters with listeners on the MBeanExporter class, you need to set the notificationFilters property which tokens are delimited by the character &#039;,&#039;. If the element starts with the character &#039;+&#039;, the nofication type is allowed and if it starts with &#039;-&#039;, the type is denied. The following listing shows an example of use.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    ...
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;list&amp;gt;
      &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
    &amp;lt;/list&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationFilters&quot;&amp;gt;
    &amp;lt;value&amp;gt;DENY_ALL_TYPES,+test&amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This feature is supported on the NotifierFactoryBean class too.&lt;/p&gt;

&lt;h3&gt;Support of handback&lt;/h3&gt;

&lt;p&gt;Handback is an object specified on the call of addNotificationListener which is then given to the listener when a notification is triggered. The patch supports now this feature with the handback property of the MBeanExporter class. The following listing shows an example of use.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    ...
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;list&amp;gt;
      &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
    &amp;lt;/list&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationFilters&quot;&amp;gt;
    &amp;lt;value&amp;gt;DENY_ALL_TYPES,+test&amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;handback&quot; value=&quot;test handback&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This feature is supported on the NotifierFactoryBean class too.&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Jencks in action</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Jencks+in+action/besz0</link>
            <description>&lt;p&gt;The aim of this article is to describe the use of Jencks (&lt;a href=&quot;http://jencks.org/&quot;&gt;http://jencks.org&lt;/a&gt;). It is based on the version 1.1.1 of the project.&lt;/p&gt;

&lt;p&gt;This project allows application to use the transaction and connector modules with the JCA support of Spring in order to use JCA in a managed mode outside a J2EE application server. It allows to develop more lightweight applications and to embed XA features into every applications even if they are not deployed in an application server.&lt;/p&gt;

&lt;h3&gt;JCA support of Spring&lt;/h3&gt;

&lt;p&gt;The JCA support of Spring provides a dedicated FactoryBean implementation, &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/api/index.html&quot;&gt;LocalConnectionFactoryBean&lt;/a&gt;, to configure a JCA connector in a non managed mode. You can too use it to configure a connector in a managed mode if you specify an implementation of the JCA ConnectionManager interface in addition to the ManagedConnectionFactort as described in the following code.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot; class=&quot;org.springframework.jca.support.LocalConnectionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;managedConnectionFactory&quot;&amp;gt;&amp;lt;ref local=&quot;managedConnectionFactory&quot;/&amp;gt;&amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;connectionManager&quot;&amp;gt;&amp;lt;ref local=&quot;connectionManager&quot;/&amp;gt;&amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that the LocalConnectionFactoryBean class can be used to expose different interfaces like the JMS ConnectionFactory, the JDBC DataSource, the Hibernate SessionFactory, of course the JCA ConnectionFactory...&lt;/p&gt;

&lt;p&gt;When using this feature, you are now able to add your resources in the context of global transactions and use them with JTA.&lt;/p&gt;

&lt;h3&gt;Jencks&lt;/h3&gt;

&lt;p&gt;Jencks is very close to the Geronimo and Spring projects. As a matter of fact, it provides dedicated FactoryBean to configure resources of the connector and transaction modules of Geronimo.&lt;/p&gt;

&lt;p&gt;The first step to use Jencks is to configure the transaction module as following.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionTracker&quot;
      class=&quot;org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator&quot;/&amp;gt;

&amp;lt;bean id=&quot;transactionManagerImpl&quot; class=&quot;org.jencks.factory.TransactionManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;defaultTransactionTimeoutSeconds&quot; value=&quot;600&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionLog&quot;&amp;gt;
    &amp;lt;bean class=&quot;org.apache.geronimo.transaction.log.UnrecoverableLog&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;transactionContextManager&quot; class=&quot;org.jencks.factory.TransactionContextManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManagerImpl&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;userTransaction&quot; class=&quot;org.jencks.factory.UserTransactionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionContextManager&quot; ref=&quot;transactionContextManager&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionTrackingCoordinator&quot; ref=&quot;connectionTracker&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The connector module will use the entities in order to be able to use global transactions.&lt;/p&gt;

&lt;p&gt;The next step is to configure the ConnectionManager implementation of Geronimo. It provides a pooling mechanism and a contract with the transaction manager. So you must configure a ConnectionManager for each factories (DataSource, SessionFactory, ConnectionManager...).&lt;/p&gt;

&lt;p&gt;The configuration of the XA JMS ConnectionFactory of ActiveMQ is described in the following code. It is based on the ActiveMQ JCA connector. Firstly, you must configure the ConnectionManager and then the connector using it. Note that the configuration of ConnectionManager is similar for every connector.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;transactionSupport&quot;
      class=&quot;org.jencks.factory.XATransactionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;useTransactionCaching&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;useThreadCaching&quot; value=&quot;false&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;poolingSupport&quot; class=&quot;org.jencks.factory.SinglePoolFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;maxSize&quot; value=&quot;2&quot;/&amp;gt;
  &amp;lt;property name=&quot;minSize&quot; value=&quot;1&quot;/&amp;gt;
  &amp;lt;property name=&quot;blockingTimeoutMilliseconds&quot; value=&quot;60&quot;/&amp;gt;
  &amp;lt;property name=&quot;idleTimeoutMinutes&quot; value=&quot;60&quot;/&amp;gt;
  &amp;lt;property name=&quot;matchOne&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;matchAll&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;selectOneAssumeMatch&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsConnectionManager&quot; class=&quot;org.jencks.factory.ConnectionManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionSupport&quot; ref=&quot;transactionSupport&quot;/&amp;gt;
  &amp;lt;property name=&quot;poolingSupport&quot; ref=&quot;poolingSupport&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionContextManager&quot; ref=&quot;transactionContextManager&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionTracker&quot; ref=&quot;connectionTracker&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Then you need to configure the connector basing the ConnectionManager previously configured. Here is a sample with the connector of ActiveMQ. In this case, you can inject the JMS ConnectionFactory configured which is internally XA compliant. So it can participate in a 2PC transaction.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;jmsResourceAdapter&quot; class=&quot;org.activemq.ra.ActiveMQResourceAdapter&quot;&amp;gt;
  &amp;lt;property name=&quot;serverUrl&quot; value=&quot;tcp://localhost:61616&quot;/&amp;gt;
  &amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsManagedConnectionFactory&quot; class=&quot;org.activemq.ra.ActiveMQManagedConnectionFactory&quot;&amp;gt;
  &amp;lt;property name=&quot;resourceAdapter&quot; ref=&quot;jmsResourceAdapter&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsConnectionFactory&quot; class=&quot;org.springframework.jca.support.LocalConnectionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;managedConnectionFactory&quot; ref=&quot;jmsManagedConnectionFactory&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionManager&quot; ref=&quot;jmsConnectionManager&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Transaction demarcation with Spring&lt;/h3&gt;

&lt;p&gt;With the use of Jencks, you can manage transactions in your application normally with the classic support of Spring. In this case, the implementation of the PlatformTransactionManager interface to use is JtaTransactionManager.&lt;/p&gt;

&lt;p&gt;For more information, see the chapter &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/reference/transaction.html&quot;&gt;Transaction management&lt;/a&gt; in the reference documentation of Spring. The following code shows how to configure the JtaTransactionManager with the previous configured beans.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;transactionManager&quot; class=&quot;org.springframework.transaction.jta.JtaTransactionManager&quot;&amp;gt;
  &amp;lt;property name=&quot;userTransaction&quot; ref=&quot;userTransaction&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManagerImpl&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In this howto, we have described the way to use Jencks, ActiveMQ and Spring to make global transactions with JCA and Geronimo outside the application server. The article is focused on the outbound communication of JCA. As the ActiveMQ connector is 1.5 compliant, you can use Jencks with inbound communication. I will describe this feature in a next howto.&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Use the JMS support of Spring with Joram</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Use+the+JMS+support+of+Spring+with+Joram/beszz</link>
            <description>&lt;p&gt;The aim of this entry is to describe the way to use the JMS support of Spring in order to develop Java/J2EE applications based on the JMS provider Joram.&lt;/p&gt;

&lt;p&gt;Firstly, we will describe the way to configure the ConnectionFactory of Joram in a context of Spring. Then, we will show how to handle the destinations with both JNDI and administration API of Joram. Finally, we will see how to use the JmsTemplate class of Spring in order to send and receive JMS messages basing on Joram.&lt;/p&gt;

&lt;h3&gt;Configuration of the ConnectionFactory instance&lt;/h3&gt;

&lt;p&gt;The first thing to do is to configure the ConnectionFactory of Joram in order to inject it in the JmsTemplate class of Spring. Joram offers several implementations of the JMS interface ConnectionFactory. We will see the configurations of the one based on tcp and an other used for embedded server.&lt;/p&gt;

&lt;p&gt;Firstly, if you need to access a Joram server with tcp, you must use the TcpConnectionFactory class. This class can be configured as a Bean as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot;
     class=&quot;org.objectweb.joram.client.jms.tcp.TcpConnectionFactory&quot;&amp;gt;
    &amp;lt;constructor-arg index=&quot;0&quot; value=&quot;tcp://localhost/&quot;/&amp;gt;
    &amp;lt;constructor-arg index=&quot;1&quot; value=&quot;16010&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In the case of the class LocalConnectionFactory, you need to use a static factory method in order to instanciate a ConnectionFactory of this type.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
ConnectionFactory connectionFactory=LocalConnectionFactory.create(&quot;root&quot;,&quot;root&quot;);
&lt;/pre&gt;

&lt;p&gt;For this class, you can choose to use the support of factory method of Spring or develop a custom FactoryBean as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class LocalConnectionFactoryBean
                  implements FactoryBean,InitializingBean {
    private ConnectionFactory connectionFactory;

    public Object getObject() throws Exception {
        return connectionFactory;
    }

    public Class getObjectType() {
        return ConnectionFactory.class;
    }

    public boolean isSingleton() {
        return true;
    }

    public void afterPropertiesSet() throws Exception {
        this.connectionFactory=LocalConnectionFactory.create();
    }
}
&lt;/pre&gt;

&lt;p&gt;This class will be configured in Spring as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot;
         class=&quot;test.joram.LocalConnectionFactoryBean&quot;/&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that you can too choose to use the JndiObjectFactoryBean in order to get
an instance of a ConnectionFactory from JNDI. The following code shows how to configure this strategy:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot; class=&quot;...JndiObjectFactoryBean&quot;&amp;gt;
    &amp;lt;property name=&quot;jndiName&quot; value=&quot;cnf&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Working with destintations&lt;/h3&gt;

&lt;p&gt;After having configured your JMS ConnectionFactory for Joram, the strategy to resolve the destinations must be configured. As a matter of fact, the JmsTemplate of Spring can be used both with a parameter &#039;destination&#039; of type Destionation or a parameter &#039;destinationName&#039; of type String.&lt;/p&gt;

&lt;p&gt;In the first case, the application is entirely responsible to get the instance of the destination. You can use both JNDI or administration API of Joram. Here is an example of the latter:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
(...)
JmsTemplate template=createTemplate();

List destinations=AdminModule.getDestinations();
Destination destination=null;
for(Iterator i=destinations.iterator();i.hasNext();) {
    Destination tmpDestination=(Destination)i.next();
    if( !isQueue(destination) ) {
        continue;
    }

    if( destinationName.equals(destination.getAdminName()) ) {
        destination=tmpDestination;
    }
}

template.send(destination,new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
        (...)
        return (...);
    }
});
&lt;/pre&gt;

&lt;p&gt;In the second case, the JMS support of Spring delegates the task to get the
destination instance basing on the name of destination to an instance of the
interface DestinationResolver. There are two implementations provides by the
support: DynamicDestinationResolver (based on the method createQueue and
createTopic of JMS API) and JndiDestionationResolver (based on Jndi).&lt;p&gt;
&lt;p&gt;By defaut, the template uses the first one, but you can provide your own one
with the method setDestinationResolver of this class.&lt;/p&gt;

&lt;p&gt;Here is a custom one for Joram named JoramDestinationResolver which looks for the destination thanks to the administration API of the provider. If it doesn&#039;t exist, the class uses the same API in order to create it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class JoramDestinationResolver
                     implements DestinationResolver,InitializingBean {
    private static final Object JORAM_QUEUE_TYPE = &quot;queue&quot;;
    private static final Object JORAM_TOPIC_TYPE = &quot;topic&quot;;

    private JoramAdmin admin;
    private String hostName;
    private int port;
    private String userName;
    private String password;

    public Destination resolveDestinationName(
                 Session session,String destinationName,
                 boolean pubSubDomain) throws JMSException {
        List destinations = doGetDestinations();
        for(Iterator i=destinations.iterator();i.hasNext();) {
            Destination destination=(Destination)i.next();
            if( !isPubSubDomain(destination,pubSubDomain) ) {
                continue;
            }

            if( destinationName.equals(destination.getAdminName()) ) {
                return destination;
            }
        }

        return doCreateDestination(destinationName,pubSubDomain);
    }

    private Destination doCreateDestination(
                  String destinationName, boolean pubSubDomain) {
        try {
            Destination destination=null;
            if( !pubSubDomain ) {
                destination=(Destination)admin.createQueue(destinationName);
            } else {
                destination=(Destination)admin.createTopic(destinationName);
            }
            destination.setFreeReading();
            destination.setFreeWriting();
            return destination;
        } catch(AdminException ex) {
            throw new JoramAdminException(
                         &quot;Unable to create the destination&quot;+
                         &quot; with the name &quot;+destinationName,ex);
        } catch (ConnectException ex) {
            throw new JoramAdminException(
                         &quot;Unable to create the destination with&quot;+
                         &quot; the name &quot;+destinationName,ex);
        }
    }

    private List doGetDestinations() {
        try {
            List destinations=AdminModule.getDestinations();
            return destinations;
        } catch(Exception ex) {
            throw new JoramAdminException(&quot;Unable to get the&quot;+
                                       &quot; list of destinations&quot;,ex);
        }
    }

    private boolean isPubSubDomain(
                 Destination destination, boolean pubSubDomain) {
        if( !pubSubDomain
               &amp;&amp; JORAM_QUEUE_TYPE.equals(destination.getType()) ) {
            return true;
        }

        if( pubSubDomain
               &amp;&amp; JORAM_TOPIC_TYPE.equals(destination.getType()) ) {
            return true;
        }

        return false;
    }

    public void afterPropertiesSet() throws Exception {
        if( hostName==null || port==0 ) {
            throw new IllegalArgumentException(
                         &quot;Both hostName and port are required&quot;);
        }

        if( userName==null || password==null ) {
            throw new IllegalArgumentException(
                         &quot;Both userName and password are required&quot;);
        }

        admin=new JoramAdmin(hostName,port,userName,password,60);
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
&lt;/pre&gt;

&lt;h3&gt;Sending JMS messages using the JoramDestinationResolver class&lt;/h3&gt;

&lt;p&gt;This DestinationResolver implementation can be used as following in order to send JMS messages with the JmsTemplate class.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
(...)
JmsTemplate template=createTemplate();
JoramDestinationResolver resolver=new JoramDestinationResolver();
resolver.setHostName(&quot;localhost&quot;);
resolver.setPort(16010);
resolver.setUserName(&quot;root&quot;);
resolver.setPassword(&quot;root&quot;);
resolver.afterPropertiesSet();
template.setDestinationResolver(resolver);

template.send(destinationName,new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
        (...)
        return (...);
    }
});
&lt;/pre&gt;

&lt;h3&gt;Receiving JMS messages using the JoramDestinationResolver&lt;/h3&gt;

&lt;p&gt;Since its version 2.0, Spring offers support for JMS asynchronous communications
with the classes SimpleMessageListenerContainer and ServerSessionMessageListenerContainer which must be configured with an instance of the class MessageListener of the JMS specification.&lt;/p&gt;

&lt;p&gt;These two classes support the mechanism based on the DestinationResolver interface in order to get an instance of a destination using its name.&lt;/p&gt;

&lt;p&gt;Here is an example based on a JMS MessageListener:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;myJmsListener&quot; class=&quot;test.joram.MyJmsListener&quot;/&amp;gt;

&amp;lt;bean id=&quot;destinationResolver&quot;
      class=&quot;joram.JoramDestinationResolver&quot;&amp;gt;
    &amp;lt;property name=&quot;hostName&quot; value=&quot;localhost&quot;/&amp;gt;
    &amp;lt;property name=&quot;port&quot; value=&quot;16010&quot;/&amp;gt;
    &amp;lt;property name=&quot;userName&quot; value=&quot;root&quot;/&amp;gt;
    &amp;lt;property name=&quot;password&quot; value=&quot;root&quot;/&amp;gt;
&amp;lt;bean&amp;gt;

&amp;lt;bean id=&quot;jmsContainer&quot;
      class=&quot;org.springframework.jms.listener.DefaultMessageListenerContainer&quot;&amp;gt;
    &amp;lt;property name=&quot;connectionFactory&quot; ref=&quot;connectionFactory&quot;/&amp;gt;
    &amp;lt;property name=&quot;destinationResolver&quot; ref=&quot;destinationResolver&quot;/&amp;gt;
    &amp;lt;property name=&quot;destinationName&quot; value=&quot;test.queue&quot;/&amp;gt;
    &amp;lt;property name=&quot;messageListener&quot; ref=&quot;myJmsListener&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Book: Spring par la pratique</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Book%3A+Spring+par+la+pratique/beszy</link>
            <description>	&lt;p&gt;&lt;p&gt;I&#039;m pleased to announce the publishing of the book &quot;Spring par la pratique&quot; (Eyrolles).&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;I have co-written this book with &lt;a href=&quot;http://julien.dubois.free.fr/&quot;&gt;Julien Dubois&lt;/a&gt; and Jean-Philippe Retaillé. Rod Johnson has written a great preface.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;The book is the first book dedicated to the Spring framework written in french. It has been added in the list of books on the website of the framework. See the following urls: &lt;a href=&quot;http://www.springframework.org/books&quot;&gt;http://www.springframework.org/books&lt;/a&gt; and &lt;a href=&quot;http://www.springframework.org/bookreview&quot;&gt;http://www.springframework.org/bookreview&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can have more details on the book on the website of Eyrolles:&lt;br/&gt;
summary, contents and sample chapters. You can reach the page of the book and download the sample chapters at the following url:&lt;br/&gt;
&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212117103/&quot;&gt;http://www.eyrolles.com/Accueil/Livre/9782212117103/&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can buy online this book on the following sites:&lt;br/&gt;
&lt;ul&gt;&lt;/p&gt;
	&lt;p&gt;&lt;li&gt;&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212117103/&quot;&gt;Eyrolles&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.fr/exec/obidos/ASIN/2212117108/qid=1149756504/sr=1-1/ref=sr_1_0_1/403-6381974-1482861&quot;&gt;Amazon&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.fnac.com/Shelf/article.asp?PRID=1824114&quot;&gt;Fnac&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;/ul&gt;&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Spring at ECOOP 2006 in Nantes</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Spring+at+ECOOP+2006+in+Nantes/beszx</link>
            <description>	&lt;p&gt;&lt;p&gt;Next week, Rob Harrop and Adryan Colyer will make a presentation of Spring AOP during ECOOP 2006 in Nantes:&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;&quot;This tutorial provides an introduction to aspect-oriented programming using the Spring framework and AspectJ. Attendees will understand the principles behind AOP, and where it fits in enterprise application development. We demonstrate how to write aspects using the Spring framework, exploiting the AspectJ pointcut language. The @AspectJ (annotation based) style of aspect declaration supported by AspectJ 5 will be explained, including support for using such aspects with the Spring AOP framework. Finally we look at the AspectJ language itself, how it goes beyond the capabilities of Spring AOP, and how to get started with some quick wins on your own projects.&quot;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;For more details, see the page decribing this event: &lt;a href=&quot;http://www.emn.fr/x-info/ecoop2006/Tid7.html&quot;&gt;http://www.emn.fr/x-info/ecoop2006/Tid7.html&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Jencks namespace</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Jencks+namespace/beszw</link>
            <description>&lt;p&gt;Jencks is a project hosted on the codehaus site which allows to embed the transaction and connection managers of Geronimo in every applications.&lt;/p&gt;

&lt;p&gt;In order to simply the configuration of the two different managers, we have developped a dedicated namespace handler for Spring called Jencks. It allows applications to use two tags, transactionManager and connectionManager, which will be described in the following sections.&lt;/p&gt;

&lt;p&gt;The XML grammar of these tags is described in the spring-jencks.xsd file. The content of this file is the following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&amp;gt;

&amp;lt;xsd:schema xmlns=&quot;http://www.springframework.org/schema/jencks&quot;
	xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
	xmlns:beans=&quot;http://www.springframework.org/schema/beans&quot;
	targetNamespace=&quot;http://www.springframework.org/schema/jencks&quot;
	elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;&amp;gt;

	&amp;lt;xsd:import namespace=&quot;http://www.springframework.org/schema/beans&quot;/&amp;gt;

	&amp;lt;xsd:element name=&quot;transactionManager&quot;&amp;gt;
		&amp;lt;xsd:complexType&amp;gt;
			&amp;lt;xsd:sequence&amp;gt;
				&amp;lt;xsd:element name=&quot;transactionLog&quot;
					type=&quot;transactionLogType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
			&amp;lt;/xsd:sequence&amp;gt;
			&amp;lt;xsd:attribute name=&quot;id&quot; type=&quot;xsd:ID&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;userTransactionId&quot; type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;transactionContextManagerId&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;connectionTrackerId&quot; type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;defaultTransactionTimeoutSeconds&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
		&amp;lt;/xsd:complexType&amp;gt;
	&amp;lt;/xsd:element&amp;gt;

	&amp;lt;xsd:element name=&quot;connectionManager&quot;&amp;gt;
		&amp;lt;xsd:complexType&amp;gt;
			&amp;lt;xsd:sequence&amp;gt;
				&amp;lt;xsd:element name=&quot;transactionSupport&quot;
					type=&quot;transactionSupportType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
				&amp;lt;xsd:element name=&quot;poolingSupport&quot;
					type=&quot;poolingSupportType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
			&amp;lt;/xsd:sequence&amp;gt;
			&amp;lt;xsd:attribute name=&quot;id&quot; type=&quot;xsd:ID&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;transactionContextManager-ref&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;connectionTracker-ref&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
		&amp;lt;/xsd:complexType&amp;gt;
	&amp;lt;/xsd:element&amp;gt;

	&amp;lt;xsd:complexType name=&quot;transactionLogType&quot;&amp;gt;
		&amp;lt;xsd:sequence&amp;gt;
			&amp;lt;xsd:element ref=&quot;beans:bean&quot; /&amp;gt;
		&amp;lt;/xsd:sequence&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;

	&amp;lt;xsd:complexType name=&quot;transactionSupportType&quot;&amp;gt;
		&amp;lt;xsd:attribute name=&quot;useTransactionCaching&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;useThreadCaching&quot; type=&quot;xsd:boolean&quot;
			default=&quot;false&quot; /&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;

	&amp;lt;xsd:complexType name=&quot;poolingSupportType&quot;&amp;gt;
		&amp;lt;xsd:attribute name=&quot;maxSize&quot; type=&quot;xsd:int&quot; default=&quot;2&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;minSize&quot; type=&quot;xsd:int&quot; default=&quot;1&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;blockingTimeoutMilliseconds&quot; type=&quot;xsd:int&quot;
			default=&quot;60&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;idleTimeoutMinutes&quot; type=&quot;xsd:int&quot;
			default=&quot;60&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;matchOne&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;matchAll&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;selectOneAssumeMatch&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;
&amp;lt;/xsd:schema&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that this namespace need the version 2.0 M4 of Spring.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;In order to use this namespace handler in Spring, we need to add two files in the META-INF directory of your project.&lt;/p&gt;

&lt;p&gt;Firstly, the spring.handlers file specifies the name of implementation of NamespaceHandler. The follwing code describes the content of this file:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
http\://www.springframework.org/schema/jencks=org.springframework.jca.config.JencksNamespaceHandler
&lt;/pre&gt;

&lt;p&gt;Secondly, the spring.schemas file specifies the location of the xsd file in the classpath. The follwing code describes the content of this file:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
http\://www.springframework.org/schema/jencks=org/springframework/jca/config/spring-jencks.xsd
&lt;/pre&gt;

&lt;h3&gt;Configuration of the transaction manager&lt;/h3&gt;

&lt;p&gt;The tag transactionManager is used to configuration the JTA transaction manager of Geronimo. It internally creates four beans:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Transaction manager (identified by the value of the id attribute)&lt;/li&gt;
  &lt;li&gt;Transaction context manager (identified by the value of the transactionContextManagerId attribute)&lt;/li&gt;
  &lt;li&gt;User transaction (identified by the value of the userTransactionId attribute)&lt;/li&gt;
  &lt;li&gt;Connection tracker (identified by the value of the connectionTrackerId attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following code is an example of use of this tag in a application context of Spring:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;jencks:transactionManager id=&quot;transactionManager&quot;
               userTransactionId=&quot;userTransaction&quot;
               transactionContextManagerId=&quot;transactionContextManager&quot;
               connectionTrackerId=&quot;connectionTracker&quot;
               defaultTransactionTimeoutSeconds=&quot;600&quot;&amp;gt;

    &amp;lt;jencks:transactionLog&amp;gt;
        &amp;lt;bean class=&quot;org.apache.geronimo.transaction.log.UnrecoverableLog&quot;/&amp;gt;
    &amp;lt;/jencks:transactionLog&amp;gt;

&amp;lt;/jencks:transactionManager&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Configuration of the connection manager&lt;/h3&gt;

&lt;p&gt;The tag connectionManager is used to configuration the JCA connection manager of Geronimo. It can be used in order to configure a connector for outbound communications. It internally creates one bean:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Connection manager (identified by the value of the id attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tag is based on entites configured by the tag described in the previous section:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Transaction context manager (referenced  by the value of the transactionContextManager-ref attribute)&lt;/li&gt;
  &lt;li&gt;Connection tracker (referenced  by the value of the connectionTracker-ref attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following code is an example of use of this tag in a application context of Spring:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;jencks:connectionManager id=&quot;connectionManager&quot;
          transactionContextManager-ref=&quot;transactionContextManager&quot;
          connectionTracker-ref=&quot;connectionTracker&quot;&amp;gt;

    &amp;lt;jencks:transactionSupport useTransactionCaching=&quot;true&quot;
                               useThreadCaching=&quot;false&quot;/&amp;gt;

    &amp;lt;jencks:poolingSupport maxSize=&quot;2&quot; minSize=&quot;2&quot;
              blockingTimeoutMilliseconds=&quot;60&quot; idleTimeoutMinutes=&quot;60&quot;
              matchOne=&quot;true&quot; matchAll=&quot;true&quot; selectOneAssumeMatch=&quot;true&quot;/&amp;gt;

&amp;lt;/jencks:connectionManager&amp;gt;
&lt;/pre&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:46 -0700</pubDate>
        </item>
            
        <item>
            <title>Book: JavaScript pour le Web 2.0</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Book%3A+JavaScript+pour+le+Web+2.0/beszv</link>
            <description>	&lt;p&gt;&lt;p&gt;I&#039;m pleased to announce the publishing of the book &quot;JavaScript pour le Web 2.0&quot; (Eyrolles) which I have co-written this book with Arnaud Gougeon.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;The book describes the use of JavaScript and different librairies in order to develop rich internet application or web site with a rich user interface.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;It covers all the aspects of the JavaScript language (basis, object oriented programming, dom, ajax) and its use and its interactions with (X)HTML and CSS in a web page.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;It also covers in depth several JavaScript libraries like Prototype, Dojo, script.aculo.us, Rialto, Behaviour.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;To finish, it deals with additional tools in order to develop and test JavaScript applications.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;A project has been created for this book and can be reached at the following url: &lt;a href=&quot;http://jsweb2.sourceforge.net/&quot;&gt;http://jsweb2.sourceforge.net/&lt;/a&gt;.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can have more details on the book on the website of Eyrolles:&lt;br/&gt;
summary, contents and sample chapters. You can reach the page of the book and download the sample chapters at the following url:&lt;br/&gt;
&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212120097/&quot;&gt;http://www.eyrolles.com/Accueil/Livre/9782212117103/&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can buy online this book on the following sites:&lt;br/&gt;
&lt;ul&gt;&lt;/p&gt;
	&lt;p&gt;&lt;li&gt;&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212120097/&quot;&gt;Eyrolles&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.fr/JavaScript-pour-Web-Thierry-Templier/dp/2212120095/ref=pd_ts_b_42/171-7197751-1493038?ie=UTF8&amp;#38;s=books&quot;&gt;Amazon&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www4.fnac.com/Shelf/article.aspx?PRID=1880263&quot;&gt;Fnac&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;/ul&gt;&lt;/p&gt;</description>
            
            <pubDate>Tue, 17 Jul 2007 07:18:45 -0700</pubDate>
        </item>
            
        <item>
            <title>Book: JavaScript pour le Web 2.0</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Book%3A+JavaScript+pour+le+Web+2.0/tzw2</link>
            <description>                             	&lt;p&gt;&lt;p&gt;I&#039;m pleased to announce the publishing of the book &quot;JavaScript pour le Web 2.0&quot; (Eyrolles) which I have co-written this book with Arnaud Gougeon.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;The book describes the use of JavaScript and different librairies in order to develop rich internet application or web site with a rich user interface.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;It covers all the aspects of the JavaScript language (basis, object oriented programming, dom, ajax) and its use and its interactions with (X)HTML and CSS in a web page.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;It also covers in depth several JavaScript libraries like Prototype, Dojo, script.aculo.us, Rialto, Behaviour.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;To finish, it deals with additional tools in order to develop and test JavaScript applications.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;A project has been created for this book and can be reached at the following url: &lt;a href=&quot;http://jsweb2.sourceforge.net/&quot;&gt;http://jsweb2.sourceforge.net/&lt;/a&gt;.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can have more details on the book on the website of Eyrolles:&lt;br/&gt;
summary, contents and sample chapters. You can reach the page of the book and download the sample chapters at the following url:&lt;br/&gt;
&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212120097/&quot;&gt;http://www.eyrolles.com/Accueil/Livre/9782212117103/&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can buy online this book on the following sites:&lt;br/&gt;
&lt;ul&gt;&lt;/p&gt;
	&lt;p&gt;&lt;li&gt;&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212120097/&quot;&gt;Eyrolles&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.fr/JavaScript-pour-Web-Thierry-Templier/dp/2212120095/ref=pd_ts_b_42/171-7197751-1493038?ie=UTF8&amp;#38;s=books&quot;&gt;Amazon&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www4.fnac.com/Shelf/article.aspx?PRID=1880263&quot;&gt;Fnac&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;/ul&gt;&lt;/p&gt;
         </description>
            
            <pubDate>Sat, 13 Jan 2007 17:47:31 -0800</pubDate>
        </item>
            
        <item>
            <title>Spring at ECOOP 2006 in Nantes</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Spring+at+ECOOP+2006+in+Nantes/f91x</link>
            <description>                             	&lt;p&gt;&lt;p&gt;Next week, Rob Harrop and Adryan Colyer will make a presentation of Spring AOP during ECOOP 2006 in Nantes:&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;&quot;This tutorial provides an introduction to aspect-oriented programming using the Spring framework and AspectJ. Attendees will understand the principles behind AOP, and where it fits in enterprise application development. We demonstrate how to write aspects using the Spring framework, exploiting the AspectJ pointcut language. The @AspectJ (annotation based) style of aspect declaration supported by AspectJ 5 will be explained, including support for using such aspects with the Spring AOP framework. Finally we look at the AspectJ language itself, how it goes beyond the capabilities of Spring AOP, and how to get started with some quick wins on your own projects.&quot;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;For more details, see the page decribing this event: &lt;a href=&quot;http://www.emn.fr/x-info/ecoop2006/Tid7.html&quot;&gt;http://www.emn.fr/x-info/ecoop2006/Tid7.html&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
         </description>
            
            <pubDate>Fri, 30 Jun 2006 01:47:51 -0700</pubDate>
        </item>
            
        <item>
            <title>Jencks namespace</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Jencks+namespace/f91w</link>
            <description>                             &lt;p&gt;Jencks is a project hosted on the codehaus site which allows to embed the transaction and connection managers of Geronimo in every applications.&lt;/p&gt;

&lt;p&gt;In order to simply the configuration of the two different managers, we have developped a dedicated namespace handler for Spring called Jencks. It allows applications to use two tags, transactionManager and connectionManager, which will be described in the following sections.&lt;/p&gt;

&lt;p&gt;The XML grammar of these tags is described in the spring-jencks.xsd file. The content of this file is the following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&amp;gt;

&amp;lt;xsd:schema xmlns=&quot;http://www.springframework.org/schema/jencks&quot;
	xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot;
	xmlns:beans=&quot;http://www.springframework.org/schema/beans&quot;
	targetNamespace=&quot;http://www.springframework.org/schema/jencks&quot;
	elementFormDefault=&quot;qualified&quot; attributeFormDefault=&quot;unqualified&quot;&amp;gt;

	&amp;lt;xsd:import namespace=&quot;http://www.springframework.org/schema/beans&quot;/&amp;gt;

	&amp;lt;xsd:element name=&quot;transactionManager&quot;&amp;gt;
		&amp;lt;xsd:complexType&amp;gt;
			&amp;lt;xsd:sequence&amp;gt;
				&amp;lt;xsd:element name=&quot;transactionLog&quot;
					type=&quot;transactionLogType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
			&amp;lt;/xsd:sequence&amp;gt;
			&amp;lt;xsd:attribute name=&quot;id&quot; type=&quot;xsd:ID&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;userTransactionId&quot; type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;transactionContextManagerId&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;connectionTrackerId&quot; type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;defaultTransactionTimeoutSeconds&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
		&amp;lt;/xsd:complexType&amp;gt;
	&amp;lt;/xsd:element&amp;gt;

	&amp;lt;xsd:element name=&quot;connectionManager&quot;&amp;gt;
		&amp;lt;xsd:complexType&amp;gt;
			&amp;lt;xsd:sequence&amp;gt;
				&amp;lt;xsd:element name=&quot;transactionSupport&quot;
					type=&quot;transactionSupportType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
				&amp;lt;xsd:element name=&quot;poolingSupport&quot;
					type=&quot;poolingSupportType&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot; /&amp;gt;
			&amp;lt;/xsd:sequence&amp;gt;
			&amp;lt;xsd:attribute name=&quot;id&quot; type=&quot;xsd:ID&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;transactionContextManager-ref&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
			&amp;lt;xsd:attribute name=&quot;connectionTracker-ref&quot;
				type=&quot;xsd:string&quot; /&amp;gt;
		&amp;lt;/xsd:complexType&amp;gt;
	&amp;lt;/xsd:element&amp;gt;

	&amp;lt;xsd:complexType name=&quot;transactionLogType&quot;&amp;gt;
		&amp;lt;xsd:sequence&amp;gt;
			&amp;lt;xsd:element ref=&quot;beans:bean&quot; /&amp;gt;
		&amp;lt;/xsd:sequence&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;

	&amp;lt;xsd:complexType name=&quot;transactionSupportType&quot;&amp;gt;
		&amp;lt;xsd:attribute name=&quot;useTransactionCaching&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;useThreadCaching&quot; type=&quot;xsd:boolean&quot;
			default=&quot;false&quot; /&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;

	&amp;lt;xsd:complexType name=&quot;poolingSupportType&quot;&amp;gt;
		&amp;lt;xsd:attribute name=&quot;maxSize&quot; type=&quot;xsd:int&quot; default=&quot;2&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;minSize&quot; type=&quot;xsd:int&quot; default=&quot;1&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;blockingTimeoutMilliseconds&quot; type=&quot;xsd:int&quot;
			default=&quot;60&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;idleTimeoutMinutes&quot; type=&quot;xsd:int&quot;
			default=&quot;60&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;matchOne&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;matchAll&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
		&amp;lt;xsd:attribute name=&quot;selectOneAssumeMatch&quot; type=&quot;xsd:boolean&quot;
			default=&quot;true&quot; /&amp;gt;
	&amp;lt;/xsd:complexType&amp;gt;
&amp;lt;/xsd:schema&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that this namespace need the version 2.0 M4 of Spring.&lt;/p&gt;

&lt;h3&gt;Installation&lt;/h3&gt;

&lt;p&gt;In order to use this namespace handler in Spring, we need to add two files in the META-INF directory of your project.&lt;/p&gt;

&lt;p&gt;Firstly, the spring.handlers file specifies the name of implementation of NamespaceHandler. The follwing code describes the content of this file:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
http\://www.springframework.org/schema/jencks=org.springframework.jca.config.JencksNamespaceHandler
&lt;/pre&gt;

&lt;p&gt;Secondly, the spring.schemas file specifies the location of the xsd file in the classpath. The follwing code describes the content of this file:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
http\://www.springframework.org/schema/jencks=org/springframework/jca/config/spring-jencks.xsd
&lt;/pre&gt;

&lt;h3&gt;Configuration of the transaction manager&lt;/h3&gt;

&lt;p&gt;The tag transactionManager is used to configuration the JTA transaction manager of Geronimo. It internally creates four beans:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Transaction manager (identified by the value of the id attribute)&lt;/li&gt;
  &lt;li&gt;Transaction context manager (identified by the value of the transactionContextManagerId attribute)&lt;/li&gt;
  &lt;li&gt;User transaction (identified by the value of the userTransactionId attribute)&lt;/li&gt;
  &lt;li&gt;Connection tracker (identified by the value of the connectionTrackerId attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following code is an example of use of this tag in a application context of Spring:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;jencks:transactionManager id=&quot;transactionManager&quot;
               userTransactionId=&quot;userTransaction&quot;
               transactionContextManagerId=&quot;transactionContextManager&quot;
               connectionTrackerId=&quot;connectionTracker&quot;
               defaultTransactionTimeoutSeconds=&quot;600&quot;&amp;gt;

    &amp;lt;jencks:transactionLog&amp;gt;
        &amp;lt;bean class=&quot;org.apache.geronimo.transaction.log.UnrecoverableLog&quot;/&amp;gt;
    &amp;lt;/jencks:transactionLog&amp;gt;

&amp;lt;/jencks:transactionManager&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Configuration of the connection manager&lt;/h3&gt;

&lt;p&gt;The tag connectionManager is used to configuration the JCA connection manager of Geronimo. It can be used in order to configure a connector for outbound communications. It internally creates one bean:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Connection manager (identified by the value of the id attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tag is based on entites configured by the tag described in the previous section:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Transaction context manager (referenced  by the value of the transactionContextManager-ref attribute)&lt;/li&gt;
  &lt;li&gt;Connection tracker (referenced  by the value of the connectionTracker-ref attribute)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following code is an example of use of this tag in a application context of Spring:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;jencks:connectionManager id=&quot;connectionManager&quot;
          transactionContextManager-ref=&quot;transactionContextManager&quot;
          connectionTracker-ref=&quot;connectionTracker&quot;&amp;gt;

    &amp;lt;jencks:transactionSupport useTransactionCaching=&quot;true&quot;
                               useThreadCaching=&quot;false&quot;/&amp;gt;

    &amp;lt;jencks:poolingSupport maxSize=&quot;2&quot; minSize=&quot;2&quot;
              blockingTimeoutMilliseconds=&quot;60&quot; idleTimeoutMinutes=&quot;60&quot;
              matchOne=&quot;true&quot; matchAll=&quot;true&quot; selectOneAssumeMatch=&quot;true&quot;/&amp;gt;

&amp;lt;/jencks:connectionManager&amp;gt;
&lt;/pre&gt;
         </description>
            
            <pubDate>Fri, 30 Jun 2006 01:47:50 -0700</pubDate>
        </item>
            
        <item>
            <title>Book: Spring par la pratique</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Book%3A+Spring+par+la+pratique/erto</link>
            <description>                             	&lt;p&gt;&lt;p&gt;I&#039;m pleased to announce the publishing of the book &quot;Spring par la pratique&quot; (Eyrolles).&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;I have co-written this book with &lt;a href=&quot;http://julien.dubois.free.fr/&quot;&gt;Julien Dubois&lt;/a&gt; and Jean-Philippe Retaillé. Rod Johnson has written a great preface.&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;The book is the first book dedicated to the Spring framework written in french. It has been added in the list of books on the website of the framework. See the following urls: &lt;a href=&quot;http://www.springframework.org/books&quot;&gt;http://www.springframework.org/books&lt;/a&gt; and &lt;a href=&quot;http://www.springframework.org/bookreview&quot;&gt;http://www.springframework.org/bookreview&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can have more details on the book on the website of Eyrolles:&lt;br/&gt;
summary, contents and sample chapters. You can reach the page of the book and download the sample chapters at the following url:&lt;br/&gt;
&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212117103/&quot;&gt;http://www.eyrolles.com/Accueil/Livre/9782212117103/&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;

	&lt;p&gt;&lt;p&gt;You can buy online this book on the following sites:&lt;br/&gt;
&lt;ul&gt;&lt;/p&gt;
	&lt;p&gt;&lt;li&gt;&lt;a href=&quot;http://www.eyrolles.com/Accueil/Livre/9782212117103/&quot;&gt;Eyrolles&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.amazon.fr/exec/obidos/ASIN/2212117108/qid=1149756504/sr=1-1/ref=sr_1_0_1/403-6381974-1482861&quot;&gt;Amazon&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;li&gt;&lt;a href=&quot;http://www.fnac.com/Shelf/article.asp?PRID=1824114&quot;&gt;Fnac&lt;/a&gt;&lt;/li&gt;&lt;br/&gt;
&lt;/ul&gt;&lt;/p&gt;
         </description>
            
            <pubDate>Thu, 08 Jun 2006 02:31:23 -0700</pubDate>
        </item>
            
        <item>
            <title>Use the JMS support of Spring with Joram</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Use+the+JMS+support+of+Spring+with+Joram/czsn</link>
            <description>                             &lt;p&gt;The aim of this entry is to describe the way to use the JMS support of Spring in order to develop Java/J2EE applications based on the JMS provider Joram.&lt;/p&gt;

&lt;p&gt;Firstly, we will describe the way to configure the ConnectionFactory of Joram in a context of Spring. Then, we will show how to handle the destinations with both JNDI and administration API of Joram. Finally, we will see how to use the JmsTemplate class of Spring in order to send and receive JMS messages basing on Joram.&lt;/p&gt;

&lt;h3&gt;Configuration of the ConnectionFactory instance&lt;/h3&gt;

&lt;p&gt;The first thing to do is to configure the ConnectionFactory of Joram in order to inject it in the JmsTemplate class of Spring. Joram offers several implementations of the JMS interface ConnectionFactory. We will see the configurations of the one based on tcp and an other used for embedded server.&lt;/p&gt;

&lt;p&gt;Firstly, if you need to access a Joram server with tcp, you must use the TcpConnectionFactory class. This class can be configured as a Bean as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot;
     class=&quot;org.objectweb.joram.client.jms.tcp.TcpConnectionFactory&quot;&amp;gt;
    &amp;lt;constructor-arg index=&quot;0&quot; value=&quot;tcp://localhost/&quot;/&amp;gt;
    &amp;lt;constructor-arg index=&quot;1&quot; value=&quot;16010&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In the case of the class LocalConnectionFactory, you need to use a static factory method in order to instanciate a ConnectionFactory of this type.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
ConnectionFactory connectionFactory=LocalConnectionFactory.create(&quot;root&quot;,&quot;root&quot;);
&lt;/pre&gt;

&lt;p&gt;For this class, you can choose to use the support of factory method of Spring or develop a custom FactoryBean as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class LocalConnectionFactoryBean
                  implements FactoryBean,InitializingBean {
    private ConnectionFactory connectionFactory;

    public Object getObject() throws Exception {
        return connectionFactory;
    }

    public Class getObjectType() {
        return ConnectionFactory.class;
    }

    public boolean isSingleton() {
        return true;
    }

    public void afterPropertiesSet() throws Exception {
        this.connectionFactory=LocalConnectionFactory.create();
    }
}
&lt;/pre&gt;

&lt;p&gt;This class will be configured in Spring as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot;
         class=&quot;test.joram.LocalConnectionFactoryBean&quot;/&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that you can too choose to use the JndiObjectFactoryBean in order to get
an instance of a ConnectionFactory from JNDI. The following code shows how to configure this strategy:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot; class=&quot;...JndiObjectFactoryBean&quot;&amp;gt;
    &amp;lt;property name=&quot;jndiName&quot; value=&quot;cnf&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Working with destintations&lt;/h3&gt;

&lt;p&gt;After having configured your JMS ConnectionFactory for Joram, the strategy to resolve the destinations must be configured. As a matter of fact, the JmsTemplate of Spring can be used both with a parameter &#039;destination&#039; of type Destionation or a parameter &#039;destinationName&#039; of type String.&lt;/p&gt;

&lt;p&gt;In the first case, the application is entirely responsible to get the instance of the destination. You can use both JNDI or administration API of Joram. Here is an example of the latter:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
(...)
JmsTemplate template=createTemplate();

List destinations=AdminModule.getDestinations();
Destination destination=null;
for(Iterator i=destinations.iterator();i.hasNext();) {
    Destination tmpDestination=(Destination)i.next();
    if( !isQueue(destination) ) {
        continue;
    }

    if( destinationName.equals(destination.getAdminName()) ) {
        destination=tmpDestination;
    }
}

template.send(destination,new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
        (...)
        return (...);
    }
});
&lt;/pre&gt;

&lt;p&gt;In the second case, the JMS support of Spring delegates the task to get the
destination instance basing on the name of destination to an instance of the
interface DestinationResolver. There are two implementations provides by the
support: DynamicDestinationResolver (based on the method createQueue and
createTopic of JMS API) and JndiDestionationResolver (based on Jndi).&lt;p&gt;
&lt;p&gt;By defaut, the template uses the first one, but you can provide your own one
with the method setDestinationResolver of this class.&lt;/p&gt;

&lt;p&gt;Here is a custom one for Joram named JoramDestinationResolver which looks for the destination thanks to the administration API of the provider. If it doesn&#039;t exist, the class uses the same API in order to create it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class JoramDestinationResolver
                     implements DestinationResolver,InitializingBean {
    private static final Object JORAM_QUEUE_TYPE = &quot;queue&quot;;
    private static final Object JORAM_TOPIC_TYPE = &quot;topic&quot;;

    private JoramAdmin admin;
    private String hostName;
    private int port;
    private String userName;
    private String password;

    public Destination resolveDestinationName(
                 Session session,String destinationName,
                 boolean pubSubDomain) throws JMSException {
        List destinations = doGetDestinations();
        for(Iterator i=destinations.iterator();i.hasNext();) {
            Destination destination=(Destination)i.next();
            if( !isPubSubDomain(destination,pubSubDomain) ) {
                continue;
            }

            if( destinationName.equals(destination.getAdminName()) ) {
                return destination;
            }
        }

        return doCreateDestination(destinationName,pubSubDomain);
    }

    private Destination doCreateDestination(
                  String destinationName, boolean pubSubDomain) {
        try {
            Destination destination=null;
            if( !pubSubDomain ) {
                destination=(Destination)admin.createQueue(destinationName);
            } else {
                destination=(Destination)admin.createTopic(destinationName);
            }
            destination.setFreeReading();
            destination.setFreeWriting();
            return destination;
        } catch(AdminException ex) {
            throw new JoramAdminException(
                         &quot;Unable to create the destination&quot;+
                         &quot; with the name &quot;+destinationName,ex);
        } catch (ConnectException ex) {
            throw new JoramAdminException(
                         &quot;Unable to create the destination with&quot;+
                         &quot; the name &quot;+destinationName,ex);
        }
    }

    private List doGetDestinations() {
        try {
            List destinations=AdminModule.getDestinations();
            return destinations;
        } catch(Exception ex) {
            throw new JoramAdminException(&quot;Unable to get the&quot;+
                                       &quot; list of destinations&quot;,ex);
        }
    }

    private boolean isPubSubDomain(
                 Destination destination, boolean pubSubDomain) {
        if( !pubSubDomain
               &amp;&amp; JORAM_QUEUE_TYPE.equals(destination.getType()) ) {
            return true;
        }

        if( pubSubDomain
               &amp;&amp; JORAM_TOPIC_TYPE.equals(destination.getType()) ) {
            return true;
        }

        return false;
    }

    public void afterPropertiesSet() throws Exception {
        if( hostName==null || port==0 ) {
            throw new IllegalArgumentException(
                         &quot;Both hostName and port are required&quot;);
        }

        if( userName==null || password==null ) {
            throw new IllegalArgumentException(
                         &quot;Both userName and password are required&quot;);
        }

        admin=new JoramAdmin(hostName,port,userName,password,60);
    }

    public String getHostName() {
        return hostName;
    }

    public void setHostName(String hostName) {
        this.hostName = hostName;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }
}
&lt;/pre&gt;

&lt;h3&gt;Sending JMS messages using the JoramDestinationResolver class&lt;/h3&gt;

&lt;p&gt;This DestinationResolver implementation can be used as following in order to send JMS messages with the JmsTemplate class.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
(...)
JmsTemplate template=createTemplate();
JoramDestinationResolver resolver=new JoramDestinationResolver();
resolver.setHostName(&quot;localhost&quot;);
resolver.setPort(16010);
resolver.setUserName(&quot;root&quot;);
resolver.setPassword(&quot;root&quot;);
resolver.afterPropertiesSet();
template.setDestinationResolver(resolver);

template.send(destinationName,new MessageCreator() {
    public Message createMessage(Session session) throws JMSException {
        (...)
        return (...);
    }
});
&lt;/pre&gt;

&lt;h3&gt;Receiving JMS messages using the JoramDestinationResolver&lt;/h3&gt;

&lt;p&gt;Since its version 2.0, Spring offers support for JMS asynchronous communications
with the classes SimpleMessageListenerContainer and ServerSessionMessageListenerContainer which must be configured with an instance of the class MessageListener of the JMS specification.&lt;/p&gt;

&lt;p&gt;These two classes support the mechanism based on the DestinationResolver interface in order to get an instance of a destination using its name.&lt;/p&gt;

&lt;p&gt;Here is an example based on a JMS MessageListener:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;myJmsListener&quot; class=&quot;test.joram.MyJmsListener&quot;/&amp;gt;

&amp;lt;bean id=&quot;destinationResolver&quot;
      class=&quot;joram.JoramDestinationResolver&quot;&amp;gt;
    &amp;lt;property name=&quot;hostName&quot; value=&quot;localhost&quot;/&amp;gt;
    &amp;lt;property name=&quot;port&quot; value=&quot;16010&quot;/&amp;gt;
    &amp;lt;property name=&quot;userName&quot; value=&quot;root&quot;/&amp;gt;
    &amp;lt;property name=&quot;password&quot; value=&quot;root&quot;/&amp;gt;
&amp;lt;bean&amp;gt;

&amp;lt;bean id=&quot;jmsContainer&quot;
      class=&quot;org.springframework.jms.listener.DefaultMessageListenerContainer&quot;&amp;gt;
    &amp;lt;property name=&quot;connectionFactory&quot; ref=&quot;connectionFactory&quot;/&amp;gt;
    &amp;lt;property name=&quot;destinationResolver&quot; ref=&quot;destinationResolver&quot;/&amp;gt;
    &amp;lt;property name=&quot;destinationName&quot; value=&quot;test.queue&quot;/&amp;gt;
    &amp;lt;property name=&quot;messageListener&quot; ref=&quot;myJmsListener&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;
         </description>
            
            <pubDate>Fri, 31 Mar 2006 03:51:47 -0800</pubDate>
        </item>
            
        <item>
            <title>Jencks in action</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Jencks+in+action/bbjo</link>
            <description>                             &lt;p&gt;The aim of this article is to describe the use of Jencks (&lt;a href=&quot;http://jencks.org/&quot;&gt;http://jencks.org&lt;/a&gt;). It is based on the version 1.1.1 of the project.&lt;/p&gt;

&lt;p&gt;This project allows application to use the transaction and connector modules with the JCA support of Spring in order to use JCA in a managed mode outside a J2EE application server. It allows to develop more lightweight applications and to embed XA features into every applications even if they are not deployed in an application server.&lt;/p&gt;

&lt;h3&gt;JCA support of Spring&lt;/h3&gt;

&lt;p&gt;The JCA support of Spring provides a dedicated FactoryBean implementation, &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/api/index.html&quot;&gt;LocalConnectionFactoryBean&lt;/a&gt;, to configure a JCA connector in a non managed mode. You can too use it to configure a connector in a managed mode if you specify an implementation of the JCA ConnectionManager interface in addition to the ManagedConnectionFactort as described in the following code.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionFactory&quot; class=&quot;org.springframework.jca.support.LocalConnectionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;managedConnectionFactory&quot;&amp;gt;&amp;lt;ref local=&quot;managedConnectionFactory&quot;/&amp;gt;&amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;connectionManager&quot;&amp;gt;&amp;lt;ref local=&quot;connectionManager&quot;/&amp;gt;&amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Note that the LocalConnectionFactoryBean class can be used to expose different interfaces like the JMS ConnectionFactory, the JDBC DataSource, the Hibernate SessionFactory, of course the JCA ConnectionFactory...&lt;/p&gt;

&lt;p&gt;When using this feature, you are now able to add your resources in the context of global transactions and use them with JTA.&lt;/p&gt;

&lt;h3&gt;Jencks&lt;/h3&gt;

&lt;p&gt;Jencks is very close to the Geronimo and Spring projects. As a matter of fact, it provides dedicated FactoryBean to configure resources of the connector and transaction modules of Geronimo.&lt;/p&gt;

&lt;p&gt;The first step to use Jencks is to configure the transaction module as following.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;connectionTracker&quot;
      class=&quot;org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator&quot;/&amp;gt;

&amp;lt;bean id=&quot;transactionManagerImpl&quot; class=&quot;org.jencks.factory.TransactionManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;defaultTransactionTimeoutSeconds&quot; value=&quot;600&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionLog&quot;&amp;gt;
    &amp;lt;bean class=&quot;org.apache.geronimo.transaction.log.UnrecoverableLog&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;transactionContextManager&quot; class=&quot;org.jencks.factory.TransactionContextManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManagerImpl&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;userTransaction&quot; class=&quot;org.jencks.factory.UserTransactionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionContextManager&quot; ref=&quot;transactionContextManager&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionTrackingCoordinator&quot; ref=&quot;connectionTracker&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The connector module will use the entities in order to be able to use global transactions.&lt;/p&gt;

&lt;p&gt;The next step is to configure the ConnectionManager implementation of Geronimo. It provides a pooling mechanism and a contract with the transaction manager. So you must configure a ConnectionManager for each factories (DataSource, SessionFactory, ConnectionManager...).&lt;/p&gt;

&lt;p&gt;The configuration of the XA JMS ConnectionFactory of ActiveMQ is described in the following code. It is based on the ActiveMQ JCA connector. Firstly, you must configure the ConnectionManager and then the connector using it. Note that the configuration of ConnectionManager is similar for every connector.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;transactionSupport&quot;
      class=&quot;org.jencks.factory.XATransactionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;useTransactionCaching&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;useThreadCaching&quot; value=&quot;false&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;poolingSupport&quot; class=&quot;org.jencks.factory.SinglePoolFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;maxSize&quot; value=&quot;2&quot;/&amp;gt;
  &amp;lt;property name=&quot;minSize&quot; value=&quot;1&quot;/&amp;gt;
  &amp;lt;property name=&quot;blockingTimeoutMilliseconds&quot; value=&quot;60&quot;/&amp;gt;
  &amp;lt;property name=&quot;idleTimeoutMinutes&quot; value=&quot;60&quot;/&amp;gt;
  &amp;lt;property name=&quot;matchOne&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;matchAll&quot; value=&quot;true&quot;/&amp;gt;
  &amp;lt;property name=&quot;selectOneAssumeMatch&quot; value=&quot;true&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsConnectionManager&quot; class=&quot;org.jencks.factory.ConnectionManagerFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;transactionSupport&quot; ref=&quot;transactionSupport&quot;/&amp;gt;
  &amp;lt;property name=&quot;poolingSupport&quot; ref=&quot;poolingSupport&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionContextManager&quot; ref=&quot;transactionContextManager&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionTracker&quot; ref=&quot;connectionTracker&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Then you need to configure the connector basing the ConnectionManager previously configured. Here is a sample with the connector of ActiveMQ. In this case, you can inject the JMS ConnectionFactory configured which is internally XA compliant. So it can participate in a 2PC transaction.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;jmsResourceAdapter&quot; class=&quot;org.activemq.ra.ActiveMQResourceAdapter&quot;&amp;gt;
  &amp;lt;property name=&quot;serverUrl&quot; value=&quot;tcp://localhost:61616&quot;/&amp;gt;
  &amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsManagedConnectionFactory&quot; class=&quot;org.activemq.ra.ActiveMQManagedConnectionFactory&quot;&amp;gt;
  &amp;lt;property name=&quot;resourceAdapter&quot; ref=&quot;jmsResourceAdapter&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;jmsConnectionFactory&quot; class=&quot;org.springframework.jca.support.LocalConnectionFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;managedConnectionFactory&quot; ref=&quot;jmsManagedConnectionFactory&quot;/&amp;gt;
  &amp;lt;property name=&quot;connectionManager&quot; ref=&quot;jmsConnectionManager&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Transaction demarcation with Spring&lt;/h3&gt;

&lt;p&gt;With the use of Jencks, you can manage transactions in your application normally with the classic support of Spring. In this case, the implementation of the PlatformTransactionManager interface to use is JtaTransactionManager.&lt;/p&gt;

&lt;p&gt;For more information, see the chapter &lt;a href=&quot;http://static.springframework.org/spring/docs/1.2.x/reference/transaction.html&quot;&gt;Transaction management&lt;/a&gt; in the reference documentation of Spring. The following code shows how to configure the JtaTransactionManager with the previous configured beans.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;transactionManager&quot; class=&quot;org.springframework.transaction.jta.JtaTransactionManager&quot;&amp;gt;
  &amp;lt;property name=&quot;userTransaction&quot; ref=&quot;userTransaction&quot;/&amp;gt;
  &amp;lt;property name=&quot;transactionManager&quot; ref=&quot;transactionManagerImpl&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;In this howto, we have described the way to use Jencks, ActiveMQ and Spring to make global transactions with JCA and Geronimo outside the application server. The article is focused on the outbound communication of JCA. As the ActiveMQ connector is 1.5 compliant, you can use Jencks with inbound communication. I will describe this feature in a next howto.&lt;/p&gt;
         </description>
            
            <pubDate>Wed, 23 Nov 2005 04:07:08 -0800</pubDate>
        </item>
            
        <item>
            <title>JMX notifications with Spring (2)</title>
            <link>http://swik.net/Spring/Spring%27s+corner/JMX+notifications+with+Spring+%282%29/3ka</link>
            <description>                             &lt;p&gt;The second part of the thread describe the end of the support of JMX notifications in Spring. Like the previous one, it describes the patch I have written to address the issue SPR-680 in JIRA.&lt;/p&gt;

&lt;p&gt;See the second zip file (SpringJMX_Notification_v1.1.zip) on the issue for the implementation of this patch.&lt;/p&gt;

&lt;h3&gt;Support of filters&lt;/h3&gt;

&lt;p&gt;When a JMX notification listener is added to an MBean, you can pass a filter to select notifications the listener will accept. In our case, we use the class NotificationFilterSupport which implements NotificationFilter and allow configure the allow and deny of notifications types.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class NotificationListenerSupport {
  ...
  public synchronized boolean isNotificationEnabled(
                       Notification notification) {...}
  public synchronized void enableType(String type)
               throws IllegalArgumentException {...}
  public synchronized void disableType(String type) {...}
  public synchronized void disableAllTypes() {...}
  public synchronized Vector getEnabledTypes() {...}
  ...
}
&lt;/pre&gt;

&lt;p&gt;To associate filters with listeners on the MBeanExporter class, you need to set the notificationFilters property which tokens are delimited by the character &#039;,&#039;. If the element starts with the character &#039;+&#039;, the nofication type is allowed and if it starts with &#039;-&#039;, the type is denied. The following listing shows an example of use.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    ...
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;list&amp;gt;
      &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
    &amp;lt;/list&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationFilters&quot;&amp;gt;
    &amp;lt;value&amp;gt;DENY_ALL_TYPES,+test&amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This feature is supported on the NotifierFactoryBean class too.&lt;/p&gt;

&lt;h3&gt;Support of handback&lt;/h3&gt;

&lt;p&gt;Handback is an object specified on the call of addNotificationListener which is then given to the listener when a notification is triggered. The patch supports now this feature with the handback property of the MBeanExporter class. The following listing shows an example of use.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    ...
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;list&amp;gt;
      &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
    &amp;lt;/list&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationFilters&quot;&amp;gt;
    &amp;lt;value&amp;gt;DENY_ALL_TYPES,+test&amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;handback&quot; value=&quot;test handback&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note:&lt;/b&gt; This feature is supported on the NotifierFactoryBean class too.&lt;/p&gt;
         </description>
            
            <pubDate>Fri, 04 Nov 2005 08:33:03 -0800</pubDate>
        </item>
            
        <item>
            <title>JMX notifications with Spring</title>
            <link>http://swik.net/Spring/Spring%27s+corner/JMX+notifications+with+Spring/3fa</link>
            <description>                             &lt;p&gt;The Spring framework offers a great support of JMX. The aims of this support are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;automatically convert simple beans into MBeans&lt;/li&gt;
&lt;li&gt;automatically register simple beans and MBeans declaratively&lt;/li&gt;
&lt;li&gt;configure an embedded JMX server&lt;/li&gt;
&lt;li&gt;configure JMX connectors to access to the components of the agent layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this time, the support doesn&#039;t include JMX notifications but it&#039;s planned for the version 1.3RC2. See the issue SPR-680 in JIRA:
&lt;a href=&quot;http://opensource2.atlassian.com/projects/spring/browse/SPR-680&quot;&gt;http://opensource2.atlassian.com/projects/spring/browse/SPR-680&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have developped some code to implement this issue. Its aims are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;provide a way to add/remove JMX listeners on registred MBeans based on their object names&lt;/li&gt;
&lt;li&gt;provide a way to add/remove JMX listeners on simple beans and MBean exported on the JMX server with Spring facilities.&lt;/li&gt;
&lt;li&gt;offer an abstraction to allow bean or MBean exported with to send notifications&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Add/remove JMX listeners on registered MBeans&lt;/h3&gt;

&lt;p&gt;The aim of this part is to add/remove listeners on MBean not registered with Spring facilities. The common example is to listen events triggered by the MBean server delegate. This entity sends notifications on register/unregister MBean events. The following listing shows how to configure it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;delegateListeners&quot; class=&quot;org.springframework.jmx.export.notifier.NotifierFactoryBean&quot;&amp;gt;
  &amp;lt;property name=&quot;server&quot;&amp;gt;&amp;lt;ref local=&quot;mbeanServer&quot;/&amp;gt;&amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;objectName&quot;&amp;gt;
    &amp;lt;value&amp;gt;
      JMImplementation:type=MBeanServerDelegate
    &amp;lt;/value&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;listener&quot; class=&quot;TestNotificationListener&quot;/&amp;gt;
&lt;/pre&gt;

&lt;p&gt;The class testNotificationListener is a classic JMX notification listener as shown in the following listing:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class TestNotificationListener
                 implements NotificationListener {
  public void handleNotification(
                 Notification notification, Object handback) {
    System.out.println(&quot;Notification received.&quot;);
    System.out.println(&quot; -&gt; &quot;+notification);
  }
}
&lt;/pre&gt;

&lt;p&gt;The listener receives the following notifications for example:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
Notification received.
 -&gt; javax.management.MBeanServerNotification
          [source=JMImplementation:type=MBeanServerDelegate]
                       [type=JMX.mbean.registered][message=]
Notification received.
 -&gt; javax.management.MBeanServerNotification
          [source=JMImplementation:type=MBeanServerDelegate]
          [type=JMX.mbean.unregistered][message=]
&lt;/pre&gt;

&lt;h3&gt;Add/remove JMX listeners on MBeans registered with Spring&lt;/h3&gt;

&lt;p&gt;The support distinguishes two possibilities according to the kind of instance to export.&lt;/p&gt;

&lt;p&gt;First the bean ot export is &lt;b&gt;a simple bean not tied with JMX&lt;/b&gt;. In this case, the JMX support of Spring uses model MBean to convert the bean into an MBean according to different strategies to know attributes and methods to expose. The RequiredModelMBean already implements the NotificationBroadcaster, so there is nothing to do, but the listeners must be added not on the bean but on the created model MBean.&lt;/p&gt;

&lt;p&gt;Secondly the bean is &lt;b&gt;a MBean (so tied with JMX)&lt;/b&gt;. In this case, the support looks if the MBean implements the &lt;code&gt;NotificationBroadcaster&lt;/code&gt;. This JMX interface allows MBean to register and unregister notification listeners.&lt;/p&gt;

&lt;p&gt;If not, AOP is used to add this interface to the bean with the method introduction feature. The implementation of this interface is the GenericBroadcaster class based on the &lt;code&gt;NotificationBroadcasterSupport&lt;/code&gt; of JMX.&lt;/p&gt;

&lt;p&gt;The following listing shows an example of use in this case.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;bean id=&quot;exporter&quot; class=&quot;org.springframework.jmx.export.MBeanExporter&quot;&amp;gt;
  &amp;lt;property name=&quot;beans&quot;&amp;gt;
    &amp;lt;map&amp;gt;
      &amp;lt;entry key=&quot;bean:name=testBean1&quot;
                value-ref=&quot;testBean&quot;/&amp;gt;
      &amp;lt;entry key=&quot;bean:name=testBean2&quot;
                value-ref=&quot;testSimpleBean&quot;/&amp;gt;
    &amp;lt;/map&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;notificationListeners&quot;&amp;gt;
    &amp;lt;ref local=&quot;listener&quot;/&amp;gt;
  &amp;lt;/property&amp;gt;
  &amp;lt;property name=&quot;server&quot; ref=&quot;mbeanServer&quot;/&amp;gt;
&amp;lt;/bean&amp;gt;

&amp;lt;bean id=&quot;listener&quot; class=&quot;TestNotificationListener&quot;/&amp;gt;
&lt;/pre&gt;

&lt;h3&gt;Send notifications from simple beans and MBeans registered with Spring&lt;/h3&gt;

&lt;p&gt;To send a notification, the simple bean or the MBean needs an abstraction. This abstraction must just have a method to send a notification. I define the Notifier interface as following:&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public interface Notifier {
  void notify(NotificationCreator creator,Object handback);
}
&lt;/pre&gt;

&lt;p&gt;One of the challenge is to give an instance of this interface. The simple bean or MBean must tell the JMX support that it can accept this by implementing the NotifierAware interface. It works like the other *Aware interfaces (ApplicationContextAware, BeanFactoryAware) in Spring. If the support detects this interface, it will call the method setNotifier on it.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public interface NotifierAware {
  void setNotifier(Notifier notifier);
}
&lt;/pre&gt;

&lt;p&gt;The following listing shows an example to send a notification.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
public class MyBean
  public void test() {
    notifier.notify(new NotificationCreator() {
      public Notification createNotification() {
        return new Notification(&quot;test&quot;,this,0);
      }
    },null);
  }

  public void setNotifier(Notifier notifier) {
    System.out.println(&quot;TestSimpleBean.setNotifier&quot;);
    this.notifier=notifier;
  }
}
&lt;/pre&gt;

&lt;p&gt;&lt;b&gt;Note&lt;/b&gt;: I have a doubt about the utility of the NotificationCreator which offers a callback to create the Notification. As a matter of fact, the creation of a notification instance is just a new... I&#039;m thinking of removing it.&lt;/p&gt;

&lt;h3&gt;Improve the support&lt;/h3&gt;

&lt;p&gt;An improvement could be the support of filter for notification and the management of the handback instance...&lt;/p&gt;

&lt;p&gt;To be continued ;-)&lt;/p&gt;
         </description>
            
            <pubDate>Fri, 04 Nov 2005 00:28:59 -0800</pubDate>
        </item>
            
        <item>
            <title>My blog has moved...</title>
            <link>http://swik.net/Spring/Spring%27s+corner/My+blog+has+moved.../vq7</link>
            <description>                             	&lt;p&gt;&lt;p&gt;I have moved my old blog on this blog with a new skin. You can have access to my old entries at the following url: &lt;a href=&quot;http://templth.blogspot.com&quot;&gt;http://templth.blogspot.com&lt;/a&gt;&lt;/p&gt;&lt;/p&gt;
         </description>
            
            <pubDate>Tue, 18 Oct 2005 14:19:47 -0700</pubDate>
        </item>
            
        <item>
            <title>Integrate P6Spy with Spring</title>
            <link>http://swik.net/Spring/Spring%27s+corner/Integrate+P6Spy+with+Spring/vq6</link>
            <description>                             &lt;br/&gt;&lt;br/&gt;

&lt;p&gt;P6Spy is a tool to &lt;b&gt;debug JDBC&lt;/b&gt; interaction with a database. It&#039;s a &lt;b&gt;wrapper&lt;/b&gt; of all JDBC elements ( Connection, PreparedStatement, ResultSet... ) and it has a powerful feature in order to log all informations about those interactions.&lt;/p&gt;

&lt;p&gt;JDBC wrapper is described in the &lt;a href=&quot;http://www.oreilly.com/catalog/javapt2/&quot;&gt;&quot;Java Performance Tuning&quot;&lt;/a&gt; book of Jack Shirazi ( O&#039;Reilly) in the chapter 16.&lt;/p&gt;

&lt;p&gt;All elements wrappers have a constructor with the element to wrap. We can use it but there is another mode for datasource. This last mode must be used to wrap a datasource defined in an application server for example.&lt;/p&gt;

&lt;p&gt;However since we can manage our objects ( &lt;b&gt;beans&lt;/b&gt; ) in Spring ( and datasources too ), it&#039;s possible to add a P6Spy datasource and link it with the real datasource with constructor injection.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;ISO-8859-1&quot;?&amp;gt;

&amp;lt;!DOCTYPE beans PUBLIC &quot;-//SPRING//DTD BEAN//EN&quot; 
                   &quot;http://www.springframework.org/dtd/spring-beans.dtd&quot;&amp;gt;

&amp;lt;beans&amp;gt;
    &amp;lt;bean id=&quot;myDataSourceTarget&quot; 
          class=&quot;org.apache.commons.dbcp.BasicDataSource&quot;
          destroy-method=&quot;close&quot;&amp;gt;
        &amp;lt;property name=&quot;driverClassName&quot;&amp;gt;
            &amp;lt;value&amp;gt;org.hsqldb.jdbcDriver&amp;lt;/value&amp;gt;
        &amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;url&quot;&amp;gt;
            &amp;lt;value&amp;gt;jdbc:hsqldb:hsql://localhost:9001&amp;lt;/value&amp;gt;
        &amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;username&quot;&amp;gt;&amp;lt;value&amp;gt;sa&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;
        &amp;lt;property name=&quot;password&quot;&amp;gt;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&amp;lt;/property&amp;gt;
    &amp;lt;/bean&amp;gt;

    &amp;lt;bean id=&quot;myDataSource&quot; class=&quot;com.p6spy.engine.spy.P6DataSource&quot; 
                                                 destroy-method=&quot;close&quot;&amp;gt;
        &amp;lt;constructor-arg&amp;gt;
            &amp;lt;ref local=&quot;myDataSourceTarget&quot;/&amp;gt;
        &amp;lt;/constructor-arg&amp;gt;
    &amp;lt;/bean&amp;gt;

&amp;lt;/beans&amp;gt;
&lt;/pre&gt;

&lt;p&gt;Moreover a p6spy.log file must be add to the classpath of the application to specify the location of the log file.&lt;/p&gt;

&lt;pre class=&quot;code&quot;&gt;
module.log=com.p6spy.engine.logging.P6LogFactory

executionthreshold=
outagedetection=false
outagedetectioninterval=
filter=false
include     = 
exclude     =
sqlexpression = 
autoflush   = true
dateformat=
includecategories=
excludecategories=info,debug,result,batch

stringmatcher=
stacktraceclass=

reloadproperties=false
reloadpropertiesinterval=60

useprefix=false

appender=com.p6spy.engine.logging.appender.FileLogger
logfile     = c:/spy.log

append=true

log4j.appender.STDOUT=org.apache.log4j.ConsoleAppender
log4j.appender.STDOUT.layout=org.apache.log4j.PatternLayout
log4j.appender.STDOUT.layout.ConversionPattern=p6spy - %m%n

log4j.logger.p6spy=INFO,STDOUT

&lt;/pre&gt;

&lt;p&gt;The output can be graphically view with a tool like &lt;a href=&quot;http://www.irongrid.com/documentation/irontracksql/indexIronTrackSQL.html&quot;&gt;Iron Track SQL&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The advantages of this solution are the following:&lt;/p&gt;
&lt;li&gt;It isn&#039;t necessary to modify the configuration of the application server datasource in order to integrate P6Spy.&lt;/li&gt;
&lt;li&gt;The use of P6Spy is much easier. No deep knowledge of the format
of the P6Spy configuration file is required ( only specify the location of log file ).&lt;/li&gt;&lt;/p&gt;
         </description>
            
            <pubDate>Tue, 18 Oct 2005 14:19:47 -0700</pubDate>
        </item>
            
    </channel>
</rss>
