1 / 15

SpringFramework.Java Developer Session

SpringFramework.Java Developer Session. The Peer Frameworks Series - .Net and Java. Solomon Duskis. SpringFramework Release. "Simple thing should be simple, and complex things should be possible." - Alan Kay "Unless simple things are simple, complex things are impossible." - Rod Johnson

omana
Download Presentation

SpringFramework.Java Developer Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SpringFramework.Java Developer Session The Peer Frameworks Series - .Net and Java Solomon Duskis

  2. SpringFramework Release • "Simple thing should be simple, and complex things should be possible." - Alan Kay "Unless simple things are simple, complex things are impossible." - Rod Johnson • Spring 0.9 announced at The Serverside Java Symposium 2002

  3. J2EE Design and Development

  4. Anti-EJB • Spring In Action (Craig Walls) – EJB is complex, not for just being complex. It is complex because it attempts to provide solutions for complex problems • The complex problems include distributed transactions across a variety of system types, including Relational Databases, MoM and Legacy Systems • 2004

  5. J2EE Development without EJB

  6. Martin Fowloer on IoC Containers • Martin Fowler (IoC Containers and the DIP) – Inversion of control is a common characteristic of frameworks, so saying that these lightweight containers are special because they use inversion of control is like saying my car is special because it has wheels… For this new breed of containers the inversion is about how they lookup a plugin implementation.

  7. Today

  8. People • Interface21 – International consulting company run by Rod Johnson. The Interface21 consultants are the core Spring Framework Developers. • Matt Raible: Creator of AppFuse Strategic adoption in many enterprises moving away from traditional costly, inefficient J2EE approaches This new paradigm is realized through WebLogic Real Time (WLRT). Extensive and growing usage across many industrites including: Retail and Investment banks, Insurance companies (US and Europe) and even Governments. In Banking: 5 out of the world's 10 largest banks are Spring users and Interface21 clients. That's pretty impressive IMO. Spring 2.0: builds on the solid base, pursues vision of POJO-based development and adds new capabilities and makes many tasks more elegant. They're hoping to release 2.0 in May 2006.

  9. Java Frameworks Galore

  10. Spring DataSource Configuration <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="org.hsqldb.jdbcDriver"/> <property name="url" value="jdbc:hsqldb:hsql://localhost:9001"/> <property name="username" value="sa"/> <property name="password" value=""/> </bean> <bean id="myDataSource" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiName" value="java:comp/env/jdbc/myds"/> </bean>

  11. Spring Session Factory Configuration <bean id="sessionFactory" class="org.springframework.orm.hibernate.LocalSessionFactoryBean”> <property name="dataSource" ref="dataSource"/> <property name="mappingResources"> <list> <value>product.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> </props> </property> </bean>

  12. Spring Dao Configuration <bean id="myProductDao" class="product.ProductDaoImpl"> <property name="sessionFactory" ref="mySessionFactory"/> </bean>

  13. Java Hibernate Dao Code public class ProductDaoImpl extends HibernateDaoSupport implements ProductDao { public Collection loadProductsByCategory(String category) throws DataAccessException { return getHibernateTemplate().find( "from test.Product product where product.category=?", category); } }

  14. Declarative Transaction Configuration <bean id="myTxManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory" ref="mySessionFactory"/> </bean> <bean id="myTxInterceptor" class="org.springframework.transaction.interceptor.TransactionInterceptor"> <property name="transactionManager" ref="myTxManager"/> <property name="transactionAttributeSource"> <value> product.ProductService.increasePrice*=PROPAGATION_REQUIRED product.ProductService.someOtherBusinessMethod=PROPAGATION_MANDATORY </value> </property> </bean> <bean id="myProductServiceTarget" class="product.ProductServiceImpl"> <property name="productDao" ref="myProductDao"/> </bean> <bean id="myProductService" class="org.springframework.aop.framework.ProxyFactoryBean"> <property name="proxyInterfaces"> <value>product.ProductService</value> </property> <property name="interceptorNames"> <list> <value>myTxInterceptor</value> <value>myProductServiceTarget</value> </list> </property> </bean>

  15. Service Code, Fully Transactional via IoC/AOP public class ProductServiceImpl implements ProductService { private ProductDao productDao; public void setProductDao(ProductDao productDao) { this.productDao = productDao; } public void increasePriceOfAllProductsInCategory(final String category) { List productsToChange = this.productDAO.loadProductsByCategory(category); ... } ... }

More Related