1 © Luxoft Training 2013 Spring Framework Module 10 JMS & EJB
2 © Luxoft Training 2013 Contents Overview of JEE technologies JMS support in Spring EJB support Spring
3 © Luxoft Training 2013
4
5
6
7
8
9
10 © Luxoft Training 2013 Spring :: JMS :: JmsTemplate JMS – Java Messaging Service: message exchange Publisher-Subscriber Point-to-Point
11 © Luxoft Training 2013 Spring :: JMS :: JmsTemplate JmsTemplate – is used to work with JMS ; JmsTemplate needs ConnectionFactory ConnectionFactory : JMS contract object; Is get from JNDI; Used by client application to create connection to JMS provider; Includes various configuration parameters
12 © Luxoft Training 2013 Spring :: JMS :: JmsTemplate connecionFactory & jmsTemplate configuration:
13 © Luxoft Training 2013 Spring :: JMS :: JmsTemplate Destination: JMS contract object; Received from JNDI; Often known only on runtime; DestinationResolver : To get Destination in a runtime; Message sending:
14 © Luxoft Training 2013 Spring :: JMS :: Example Synchronous message receive:
15 © Luxoft Training 2013 Spring :: JMS Message Listener: register and receive messages; manage resources; take part in transactions; exception handling; the simplest implementation is SimpleMessageListenerContainer Asynchronous receive of the message:
16 © Luxoft Training 2013 Spring :: EJB ::Example Business Interface Controller
17 © Luxoft Training 2013 Spring :: EJB :: Example Configuring local interface
18 © Luxoft Training 2013 Spring :: EJB :: Example Configuring remote interface
19 © Luxoft Training 2013 ConceptsEJB 3.0Spring Framework Dependency Injection Can inject anything in the container including EJBs, data sources, JMS and JPA resources Can inject almost anything including lists, maps, properties and JNDI resources Transaction management Works right out of the box, but only JTA is supported Supports a number of strategies including JTA, JDBC and Hibernate Persistence Tightly integrated through JPASupport for JPA, Hibernate, JDBC. State management Robust support through Stateful Session Beans. Indirect support dependent on web container session management Web Services Seamless support for JAX-WS 2.0Poor direct support. Messaging Supported out of the box through Message Driven Beans. JMSTemplate adds nice abstraction over JMS. AOP Simple but limited support through interceptors. Robust support through AspectJ and Spring AOP alliance. Security Integrated support for declarative and programmatic security (JAAS). Must add and configure Spring Security. Scheduling Simple scheduling possible through EJB Timer Must add and configure Quartz for scheduling. Remoting Integrated support through Session Bean remote interfaces. Supports distributed transactions, security. Remoting support may be added via configuration. Remote transactions and security are not supported. Spring :: EJB or Spring?
20 © Luxoft Training 2013 Any questions!?