Dirk Burkholz
My project Overview & Motivation Core principles and techniques Spotlight on one technique Further features Conclusion Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 2
GLOBUS group, hypermarkets Spring for Java in use for several J2EE projects Launch of software-aided business process management based on .NET Project: Evaluation if the knowledge and experience about Spring for Java can easily be transferred to projects in C#.NET using Spring.NET Sample project using some core features of Spring Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 3
Core Principles Inversion of Control (IoC) Dependency Injection (DI) Aspect Oriented Programming (AOP) Further features Template-based database access (DAO support) Webservices … Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 4
Rod Johnson, J2EE consultant, found some drawbacks in J2EE design He collected best practices to avoid this drawbacks in his book „Expert One -on-one J2EE Design and Development“ in 2002; a very basic framework was already included Now: Spring Framework for Java 2.5 in 2007 Mark Pollack‘s first .NET port in 2003 Now: Spring.NET 1.2 in 2008 Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 5
Responsibility to instatiate new objects not by the using object but by the IoC container Coding against interfaces and superclasses, not implementations Uses Dependency Injection XML-based context describing managed objects, their properties and dependencies to other managed objects Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 6
<bean id =„student1“ class =„Student“> <property name =„ studentid “ value =„42“ /> … </bean> … <bean id =„university0“ class =„University“> <property name =„ bestStudent “ ref =„student1“ /> … </bean> Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 7
Injecting dependencies of managed objects by the IoC container instead of instatiating dependent objects by new ObjectType() Spring uses Setter Injection: matching properties by name String property xy – setXy(String s) Constructor Injection: matching constructur arguments by order and type Object obj, int argument i – new obj(i) Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 8
Crosscutting concerns are requirements orthogonal to the software design/ decomposition, e.g. logging Joinpoints are points in the program flow, Pointcuts select a subset of them Advices add the desired functionality at the joinpoints selected by pointcuts Spring supports Before-, Around-, After-, AfterException and AfterReturning Advices Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 9
Drawbacks to classic AOP (e.g. AspectJ) Advising managed objects only Advising public methods only No advices for advised methods Advices are singletons Access to method invocation: arguments, return value, thrown exception Possibility to check, change or omit return values Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 10
SPRING JAVA SPRING.NET AspectJ-like J2SE dynamic proxies to Full advising of advice interfaces interfaces only CGlib2 proxies to Advising virtual advice classes methods of classes only Annotation-based syntax possible Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 11
Central concept: Template Capsules and manages connection to data source Provides methods mapping result sets to more generic collections/types Provides many helper methods Translates vendor- specific exceptions to Spring‘s generic DataAccessException hierarchy (using SQLExceptionTranslator) Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 12
SPRING JAVA SPRING.NET DataSource DbProvider JdbcTemplate AdoTemplate Mapping to Map/List Mapping to DataSet queryForMap()/List DataSetCreateWithParams() Statement parameters Statement parameters by object array by IDbParameters queryForObject() and ExecuteScalar() only specialized methods Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 13
Goal: Webservice support easier than with J2EE/ASP.NET Using webservice proxies Testing scenario: Cut between DataProvider and Factory Connections via webservice Java – Java .NET – .NET Java - .NET .NET – Java Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 14
Core principles are the same except for Java/.NET core technology differences Spring for Java developers can easily apply their knowledge when developing Spring.NET applications Some differences in details, especially naming Developers can easily overcome this by using code completion and looking up the reference’s section Spring.NET for Java developers Spring for Java has more features than Spring.NET Core features are already well supported, so certain features are only missing for special cases More features: Web MVC, Security, Validation, … Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 15
The Spring Framework - Reference Documentation: http://static.springframework.org/spring/docs/2 .5.x/reference/index.html The Spring.NET Framework – Reference Documentation: http://www.springframework.net/docs/1.2.0/ref erence/html/index.html Rod Johnson. Expert One-on-one J2EE Design and Development (Programmer to Programmer). Wiley & Sons 2003. ISBN: 978-0764543852 Dirk Burkholz - The Spring Framework 14.01.2009 for Java and .NET 16
Recommend
More recommend