Your SlideShare is downloading. ×
Spring survey
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Spring survey

423

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
423
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. An Survey of Spring Chris Roeder March, 2011 This talk summarizes a lot of what is available in: Spring In Action , Craig Walls, Manning 2008
  • 2. Spring is a collection of frameworks:
    • IoC – an “Inversion of Control”
      • AKA: Dependency Injection Framework
    • Data Access,Transaction Management, Security
    • 3. Remote Access Framework
    • 4. Spring Dynamic Modules
    • 5. Aspects – a way to deal with “cross cutting concerns”
    • 6. MVC – an alternative to web application frameworks like Struts
  • 7. Spring does not re-invent the wheel
    • Uses existing logging frameworks
    • 8. Uses existing anything: ORM, transactions, Aspects, Remoting, etc.
    • 9. Spring is there to provide “portability” between frameworks that share a purpose and interface
  • 10. Spring Frameworks are Abstractions
    • Frameworks are collections of Java interfaces
    • 11. Implemented by a variety of solutions:
      • Hibernate, JPA, Toplink
    • “Injected” into your code by the config file using the Java Bean Interface (more)
    • 12. Leaving your code simple and full of POJOs (more later)
    • 13. When needs require a different implementation, very easy to change the config file with no code changes
  • 14. Detail: Java Bean
    • “A JavaBean is a Java Object that is serializable, has a nullary constructor, and allows access to properties using getter and setter methods.”
      • http://en.wikipedia.org/wiki/JavaBean
    • Not an Entity Java Bean or EJB
  • 15. Detail: POJO
    • “The name is used to emphasize that a given object is an ordinary Java Object, not a special object, and in particular not an Enterprise JavaBean”
      • http://en.wikipedia.org/wiki/Plain_Old_Java_Object
    • Meaning it's not tied to a particular framework.
  • 16. Inversion of Control or Dependency Injection?
    • Inversion of Control is a general concept that relates to event-driven programming where the stream of events dictates execution.
    • 17. Dependency Injection is a more specific concept that refers to setting values on objects (Java Beans) from an external source.
    • 18. Spring calls the framework IoC.
    • 19. I call the concept used here DI.
  • 20. Detail: IoC
    • Dependency Injection (DI) involves abstracting out the introduction of a project's components.
    • 21. Even with good modularity, you still hard-code them together with code like this:
    • 22. public static void main(String args[]) { DataProvider dp = new DataProvider(); CorpMetrics metrics = new CorpMetrics(); metrics.calculate(dp);
  • 23. Detail: IoC 2
    • In other situations, JDBC in EJB for example, collaborators aren't hard-coded, but find each other at runtime:
    • 24. A JDBC setup finds its database connection by consulting JNDI, making environmental assumptions: Context initContext = new InitialContext(); Context envContext = (Context)initContext.lookup("java:/comp/env"); DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle"); Connection conn = ds.getConnection(); ( http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html )
    • 25. Changes still involve changing the java code.
  • 26. Detail: IoC 3
    • Separate classes allows flexibility
    • 27. Hard-coded constructor calls limit it.
    • 28. Unit Testing with different configurations is made easier.
    • 29. IoC is used as a supporting technology throughout Spring
    • 30. UIMA users, as described in a 2009 poster paper, would find this eerily familiar
      • A bit of programmer humor would involve using uimaFIT and Spring to define a pipeline in a Spring config file instead of a CPE.
  • 31. Detail: IoC 4
    • Alternate implementations require interfaces:
    • 32. Code to Interfaces
    • 33. Create “new” implementations of Classes that implement them.
    • 34. Easy to swap with a different implementation when both implement the same Java interface.
    • 35. Also works to enable a kind of multiple inheritance in Java.
  • 36. Survey: Data Access
    • POJO model entities can be stored in any ORM tool, just plain JDBC or others
    • 37. Operations on entities built in Data Access Objects (DAO)
      • GetById(), GetListWhere(), Update(), etc.
    • Spring provides “templates” to make building DAOs easy
    • 38. BTW, these are used in FLEX integration
  • 39. Survey: Transaction Management
    • Abstracts on top of JDBC, Hibernate, JPA, JMS, EJB transaction.jta.* classes
    • 40. Databases handle their own transactions:
      • START TRANSACTION, SAVE TRANSACTION
    • EJB containers allow transactions between multiple systems
    • 41. Coding to Spring allows flexibility and growth
  • 42. Survey: Remote Access
    • Compares to RMI, SOAP WS, Hessian, Burlap
    • 43. Abstracts the concept of remoting and provides different implementations.
    • 44. Client and service objects are POJOs.
    • 45. Can make use of JSR-181 Web Services Metadata annotations
  • 46. Survey: Dynamic Modules
    • Spring-DM is an implementation and integration of OSGI modules into Spring.
    • 47. provide another layer of encapsulation over the concept of Class. Now you can have private and public classes as members of a module (jar).
    • 48. allow for a lifecycle, so module can have a “running” state.
    • 49. provide better naming, so versions can be included.
    • 50. provide restricted “class space”, allowing for more than one version of a class at the same time.
    • 51. More: Yuriy is working on this
  • 52. Survey: Aspects
    • Cross-Cutting Concern: “functions that span multiple points of an application”
    • 53. Logging, Transactions, Security
    • 54. Makes use of a proxy facility in Java reflection.
      • Instead of creating and using a new object, you create the object and a proxy around it. Then use the proxy in it's place.
      • 55. The proxy intercepts function calls and allows implementations of a Handler interface to intercept them.
    • Other Implementations exist, but are intrusive.
  • 56. Survey: MVC
    • Spring has a Model, View, Control (MVC) framework for web applications. It separates code into three types:
      • Model – the data and functions to manipulate it
      • 57. View – the JSP pages to render a web page
      • 58. Controller – the plumbing or routing
    • A kind of “Model 2” architecture where a controller servlet controls creates beans and introduces them to JSPs
      • Model 1 architecture is js JSP and Bean, leaving much to the JSP and scriptlets.
  • 59. Links
    • http://www.theserverside.com/news/1364527/Introduction-to-the-Spring-Framework

×