@spring Tag Reference

@spring Class Level Tag Usage

@spring.biz-object

Marks a class as a business object. An interface will be generated for this class, which it needs to implement. Each of the methods tagged with @spring.interface-method will be placed in the interface.

ParameterTypeApplicabilityDescriptionMandatory
idtextID for the bean. This should be unique within the spring configuration.true
singletonbooleanIf "true", one shared instance of this bean will be returned with every call to getBean(). If "false" each call results in a new instance.true
lazy-initbooleanIf "true", Spring will instantiate this bean when it's needed, rather than at bean factory startup.true

@spring.transaction

Defines transactional control.

ParameterTypeApplicabilityDescriptionMandatory
transaction-typetextThe TransactionDefinition for this method-pattern.
Uses Spring types REQUIRED, REQUIRES_NEW, NEVER, NOT_SUPPORTED, MANDATORY and SUPPORTS.
REQUIRED = Support a current transaction, create a new one if none exists.
REQUIRES_NEW = Create a new transaction, suspend the current transaction if one exists.
NEVER = Execute non-transactionally, throw an exception if a transaction exists.
NOT_SUPPORTED = Execute non-transactionally, suspend the current transaction if one exists.
MANDATORY = Support a current transaction, throw an exception if none exists.
SUPPORTS = Support a current transaction, execute non-transactionally if none exists.
Default : REQUIRED
false
rollback
alse
textComma seperated list (-/+)Exception Class
i.e. +java.lang.NullPointerException,-java.sql.SQLException
This will cause the transaction to commit even if a NullPointerException is thrown, however if a SQLException is thrown the transaction will rollback.
method-patterntextA pattern match string of methodNames to apply this transaction definition to.
i.e. find*
true
read-onlyboolFlags this method-pattern as read only.

Example

The following XDoclet markup

/**
 *      @spring.transaction
 *              transaction-type="SUPPORTS"
 *              method-pattern="find*"
 *              read-only="true"
 *
 */

will place the following XML in the spring-transaction.xml file

<prop key="find*">PROPAGATION_SUPPORTS,readOnly</prop>

The following XDoclet markup

/**
 *      @spring.transaction
 *              transaction-type="REQUIRED"
 *              method-pattern="update*"
 *              rollback="-java.lang.Throwable"
 *
 */

will place the following XML in the spring-transaction.xml file

<prop key="update*">PROPAGATION_REQUIRED,-java.lang.Throwable</prop>

@spring Method Level Tag Usage

@spring.interface-method

Marks a method as an interface method on the business object.

Example

The following XDoclet markup

public class MyBizClass implements MyBizClassInterface {

  ...

/**
 *      @spring.interface-method
 *
 */
 public void myInterfaceMethod( Object o1, Object o2 ) throws Exception {
                ...
 }

 ...

}

will place the following in the generated MyBizClassInterface.java

public interface MyBizClassInterface {

  ...
  
  public void myInterfaceMethod( Object o1, Object o2 ) throws Exception;

  ...

}

@spring.transaction

Defines transactional control.

ParameterTypeApplicabilityDescriptionMandatory
transaction-typetextThe TransactionDefinition for this method.
Uses Spring types REQUIRED, REQUIRES_NEW, NEVER, NOT_SUPPORTED, MANDATORY and SUPPORTS.
REQUIRED = Support a current transaction, create a new one if none exists.
REQUIRES_NEW = Create a new transaction, suspend the current transaction if one exists.
NEVER = Execute non-transactionally, throw an exception if a transaction exists.
NOT_SUPPORTED = Execute non-transactionally, suspend the current transaction if one exists.
MANDATORY = Support a current transaction, throw an exception if none exists.
SUPPORTS = Support a current transaction, execute non-transactionally if none exists.
Default : REQUIRED
false
rollback
alse
textComma seperated list (-/+)Exception Class
i.e. +java.lang.NullPointerException,-java.sql.SQLException
This will cause the transaction to commit even if a NullPointerException is thrown, however if a SQLException is thrown the transaction will rollback.
read-onlyboolFlags this method-pattern as read only.

Example

The following XDoclet markup

/**
 *      @spring.interface-method
 *
 *      @spring.transaction
 *              transaction-type="REQUIRED"
 *              rollback="-java.lang.RuntimeException,-org.myorg.SomeException"
 *
 */
 public void myTransactionalMethod( ... ) {
                ...
 }

will place the following XML in the spring-transaction.xml file

<prop key="myTransactionalMethod">PROPAGATION_REQUIRED,-java.lang.RuntimeException,-org.myorg.SomeException</prop>