AspectJ support
From Spring 2.5 onwards, Spring’s AspectJ support can be utilised. In this example we first define a <tx:advice> that indicates that all methods starting with "get" are PROPAGATION_REQUIRED and all methods starting with "set" are PROPAGATION_REQUIRES_NEW. All other methods use the default transaction settings.
|
|
Another alternative mechanism for declaring transaction settings is to use the Spring annotation-based transaction support. This requires the use of Java 5+, and therefore cannot be used with WebSphere Application Server V6.0.2.x.
First add the following to the spring.xml configuration:
<tx:annotation-driven/>
|
The EJB 3.0 specification defines the Java Persistence API (JPA) as the means for providing portable persistent Java entities. WebSphere Application Server V7 and the WebSphere Application Server V6.1 EJB 3 feature pack both provide implementations of EJB 3 and JPA; it is also possible to use the Apache OpenJPA implementation of JPA with WebSphere Application Server V6.1
Using an Annotation style injection of a JPA EntityManager is possible:
@PersistenceContext |
<!-- bean post-processor for JPA annotations --> |
For JMS message sending or synchronous JMS message receipt, JMSTemplates can be used. This includes the use of Spring’s dynamic destination resolution functionality both via JNDI and true dynamic resolution.
The following example shows the configuration of a resource reference for a ConnectionFactory. This reference is mapped during application deployment to point to a configured, managed ConnectionFactory stored in the application server’s JNDI namespace. The ConnectionFactory is required to perform messaging and should be injected into the Spring JMSTemplate.
<resource-ref> |
<jee:jndi-lookup id="jmsConnectionFactory" jndi-name=" jms/myCF "/> |
JNDI resolution:
jmsTemplate.send("java:comp/env/jms/myQueue", messageCreator);
Dynamic resolution:
jmsTemplate.send("myQueue", messageCreator);
If you have been using the Spring Framework with WebSphere Application Server already, you may have come across this developerWorks article http://www.ibm.com/developerworks/websphere/techjournal/0609_alcott/0609_alcott.html
It has had a facelift recently, and is updated with new content including further configuration details of using WebSphere Application Server with the Spring Framework.
