Skip to end of metadata
Go to start of metadata

Spring Bean and Factory Bean can be managed by Nuts.

Syntax

Here's an example, for a regular Spring bean configuration:

The corresponding Nuts configuration is very similar:

Spring FactoryBean and AOP can also be represented in Nuts. For the following Spring interceptor:

A corresponding Nuts syntax is:

Spring Lifecycle

Spring life cycle can be directly ported to Nuts. Both Nuts style "initializer", "disposer" atributes and Spring style "init-method", "destroy-method" can be used on <ctor>, <bean>, <method> tags.
For example:

or

Spring Plugin

The core of Yan and Nuts has no dependency on Spring. The reason Spring's beans and FactoryBean can be used inside Nuts is because of Nuts' flexible plug-in tag system. A few spring-specific Nut classes are included in the spring integration package. <ctor>, <bean>, <method> tags are customized to support Spring beans.

In order to enable spring tags, the jfun.yan.xml.nuts.spring.SpringNuts class needs to be used. The following code creates a NutsProcessor object that's aware of Spring beans:

This NutsProcessor object can then be used to process a configuration file that contains spring beans:

Declarativeness Plugin

Transactional conrol is made declarative in Nuts using the customized tags.
For the following spring transactional control that needs an explicit TransactionProxyFactoryBean:

Nuts can simplify it to:

The "transactionalAttributes" is made an attribute of the <bean> tag, thus more declarative. The missing "transaction manager" is autowired bytype. Of course, you can always explicitly specify it as:

In fact, we can customize the tags to express any logic with attributes and sub-elements, as long as we feel it's important enough.


Created by benyu
On Sun Nov 20 21:33:56 CST 2005
Using TimTam

Labels
  • None