Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Java Developer Session Solomon...
-
Upload
edmund-lloyd -
Category
Documents
-
view
215 -
download
1
Transcript of Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Java Developer Session Solomon...
Copyright © 2005 Finetix LLCAll Rights Reserved 1
SpringFramework.Java Developer SessionSpringFramework.Java Developer Session
Solomon Duskis
The Peer Frameworks Series - .Net and Java
Copyright © 2005 Finetix LLCAll Rights Reserved 2
SpringFramework ReleaseSpringFramework 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
Copyright © 2005 Finetix LLCAll Rights Reserved 3
J2EE Design and DevelopmentJ2EE Design and Development
Copyright © 2005 Finetix LLCAll Rights Reserved 4
Anti-EJBAnti-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
Copyright © 2005 Finetix LLCAll Rights Reserved 5
J2EE Development without EJBJ2EE Development without EJB
Copyright © 2005 Finetix LLCAll Rights Reserved 6
Martin Fowloer on IoC ContainersMartin 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.
Copyright © 2005 Finetix LLCAll Rights Reserved 8
PeoplePeople
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.
Copyright © 2005 Finetix LLCAll Rights Reserved 9
Java Frameworks GaloreJava Frameworks Galore
JNDI AbstractionEJB Access (SLSB - local and Remote)Spring JMS PojosJCAConvenience EJB implementation classes (SLSB, SFSB, MDB)
Spring Framework
Bean Management UI
Spring MVCSpring PortletsSpring WebflowSpring RCP
JSPJSFTiles(SiteMesh)VelocityFreeMarker
XSLTPDF (iText)Excel (POI)JSTLSpring MVC Tags (1.0 & 2.0)
View SupportFrameworks
StrutsTapestryWebWorkSpring MVCSpring Portlets
Spring Original
Middleware
Remoting
RMIHessianBurlapHTTP InvocationJAX-RPCXFire
J2EE Spring Original
DAO AbstractionEmail AbstractionRemoting Abstractions
Configuration
Spring 1.0 XMLSpring "Simplified" XML (2.0)BeanFactory et alPropertyEditorsDatabindingValidation
Spring AOPAspectJ
AOPAcegi - SecuritySpring transaction Managemnt JMX
Value Add
Annotations
JDK 5.0 AnnotationsAspectJ Annotation integrationJPA AnnotationsJakarta Common Attributes
Task Scheduling
OpenSymphony QuartzJDK TimerSpring TaskExecutor (built on JDK 5.0 Executors)
JRubyBeanShellGroovy
Testing
JUnitDBUnitGrinder
DynamicLanguages
Persistence
Spring JPA AnnotationUnified Exception HandlingTransaction ManagemntSpring JDBC
HibernateIBatisJDOJPA
Spring OriginalPersistenceFrameworks
TopLinkApache OJBSpring JDBC
Copyright © 2005 Finetix LLCAll Rights Reserved 10
Spring DataSource ConfigurationSpring 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>
Copyright © 2005 Finetix LLCAll Rights Reserved 11
Spring Session Factory ConfigurationSpring 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>
Copyright © 2005 Finetix LLCAll Rights Reserved 12
Spring Dao Configuration Spring Dao Configuration
<bean id="myProductDao" class="product.ProductDaoImpl">
<property name="sessionFactory" ref="mySessionFactory"/>
</bean>
Copyright © 2005 Finetix LLCAll Rights Reserved 13
Java Hibernate Dao CodeJava Hibernate Dao Code
public class ProductDaoImpl extends HibernateDaoSupportimplements ProductDao { public Collection loadProductsByCategory(String category) throws DataAccessException { return getHibernateTemplate().find( "from test.Product product where product.category=?", category); }}
Copyright © 2005 Finetix LLCAll Rights Reserved 14
Declarative Transaction Configuration 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>
Copyright © 2005 Finetix LLCAll Rights Reserved 15
Service Code, Fully Transactional via IoC/AOPService 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); ... } ...}