; Role and Competency management - iCALMS
Learning Center
Plans & pricing Sign in
Sign Out
Your Federal Quarterly Tax Payments are due April 15th Get Help Now >>

Role and Competency management - iCALMS


  • pg 1
									Part III. Portable Service Abstractions and Spring MVC

Buenos Aires, June 2009.
 The problem
 The Spring Framework
 Dependency Injection
 Aspect-Oriented Programming
 Portable Service Abstractions

 Best Practices
 The problem
 The Spring Framework
 Dependency Injection
 Aspect-Oriented Programming

  Portable Service Abstractions
 Best Practices
•   Consistent integration with various standard and 3rd party APIs.

•   Allows access to these frameworks without knowing how they actually work.

•   Spring provides abstraction and integration for:

     – Transaction Management: JTA, JDBC, others

     – Data Access: JDBC, Hibernate, JDO, TopLink, iBatis

     – Email

     – Remoting

     – EJB, Web Services, RMI

     – Integrates nicely with Struts, JSF, Tapestry, Velocity and other web frameworks

•   Spring also provides it’s own web framework, Spring Web MVC

•   Insulates you from the underlying APIs

•   Greater reusability

•   Spring abstractions always consist of interfaces

•   This makes testing simpler

•   For data access, Spring uses a generic transaction infrastructure and DAO exception
    hierarchy that is common across all supported platforms
•      Define a DataSource bean
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
          <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
          <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE"/>
          <property name="username" value=“pepe"/>
          <property name="password" value=“1234"/>

•      Define a Session Factory bean
<bean id="sessionFactory"
      <property name="annotatedClasses">
      <property name="dataSource“ ref="dataSource" />
      <property name="hibernateProperties">
                  <prop key="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</prop>
•      Define an Hibernate Template bean
    <bean id="hibernateTemplate“ class="org.springframework.orm.hibernate3.HibernateTemplate">
          <property name="sessionFactory" ref="sessionFactory" />

•      Define a Transaction Manager bean
<bean id="transactionManager“       class="org.springframework.orm.hibernate3.HibernateTransactionManager">
      <property name="sessionFactory">
            <ref bean="sessionFactory" />

•      Define a Parent DAO bean for CRUD operations
    <bean id="baseDao" abstract="true" class="demo.dao.HibernateGenericDAO">
          <property name="hibernateTemplate" ref="hibernateTemplate" />
•    Define an Transaction Proxy Template bean
<bean id="parentService"      class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean"
      <property name="transactionManager" ref="transactionManager" />
      <property name="transactionAttributes">
                  <prop key="*">PROPAGATION_REQUIRED</prop>

•    Service interface and implementation
<bean id="contactServiceImpl" class="demo.service.impl.ContactServiceImpl">
      <property name="contactDAO" ref="contactDAOImpl"/>

<bean id="contactService" parent="parentService">
      <property name="target" ref="contactServiceImpl"/>
      <property name="proxyInterfaces" value="demo.service.ContactService" />
•   DAO interface and implementation
<bean id="contactDAOImpl" class="demo.dao.impl.HibernateContactDAO" parent="baseDao" />

<bean id="contactDAO" parent="parentService">
      <property name="target" ref="contactDAOImpl" />
•   Spring can effectively organize your middle tier objects, whether or not you choose to
    use EJB.

•   Spring can eliminate the proliferation of Singletons seen on many projects.

•   Spring can eliminate the need to use a variety of custom properties file formats, by
    handling configuration in a consistent way throughout applications and projects.

•   Spring can facilitate good programming practice by reducing the cost of
    programming to interfaces, rather than classes, almost to zero.

•   Spring is designed so that applications built with it depend on as few of its APIs as

•   Applications built using Spring are very easy to unit test.
•   Spring can make the use of EJB an implementation choice, rather than the
    determinant of application architecture.

•   Spring helps you solve many problems without using EJB. For example, using AOP
    to deliver declarative transaction management without using an EJB container.

•   Spring provides a consistent framework for data access, whether using JDBC or an
    O/R mapping product such as TopLink, Hibernate or a JDO implementation.

•   Spring provides a consistent, simple programming model in many areas, making it an
    ideal architectural "glue."

    Spring is essentially a technology dedicated to enabling you to build applications
    using POJOs.
Thank You

To top