• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Spring survey
 

Spring survey

on

  • 547 views

 

Statistics

Views

Total Views
547
Views on SlideShare
547
Embed Views
0

Actions

Likes
0
Downloads
3
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Spring survey Spring survey Presentation Transcript

    • 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
    • Spring is a collection of frameworks:
      • IoC – an “Inversion of Control”
        • AKA: Dependency Injection Framework
      • Data Access,Transaction Management, Security
      • Remote Access Framework
      • Spring Dynamic Modules
      • Aspects – a way to deal with “cross cutting concerns”
      • MVC – an alternative to web application frameworks like Struts
    • Spring does not re-invent the wheel
      • Uses existing logging frameworks
      • Uses existing anything: ORM, transactions, Aspects, Remoting, etc.
      • Spring is there to provide “portability” between frameworks that share a purpose and interface
    • Spring Frameworks are Abstractions
      • Frameworks are collections of Java interfaces
      • Implemented by a variety of solutions:
        • Hibernate, JPA, Toplink
      • “Injected” into your code by the config file using the Java Bean Interface (more)
      • Leaving your code simple and full of POJOs (more later)
      • When needs require a different implementation, very easy to change the config file with no code changes
    • 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
    • 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.
    • 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.
      • Dependency Injection is a more specific concept that refers to setting values on objects (Java Beans) from an external source.
      • Spring calls the framework IoC.
      • I call the concept used here DI.
    • Detail: IoC
      • Dependency Injection (DI) involves abstracting out the introduction of a project's components.
      • Even with good modularity, you still hard-code them together with code like this:
      • public static void main(String args[]) { DataProvider dp = new DataProvider(); CorpMetrics metrics = new CorpMetrics(); metrics.calculate(dp);
    • Detail: IoC 2
      • In other situations, JDBC in EJB for example, collaborators aren't hard-coded, but find each other at runtime:
      • 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 )
      • Changes still involve changing the java code.
    • Detail: IoC 3
      • Separate classes allows flexibility
      • Hard-coded constructor calls limit it.
      • Unit Testing with different configurations is made easier.
      • IoC is used as a supporting technology throughout Spring
      • 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.
    • Detail: IoC 4
      • Alternate implementations require interfaces:
      • Code to Interfaces
      • Create “new” implementations of Classes that implement them.
      • Easy to swap with a different implementation when both implement the same Java interface.
      • Also works to enable a kind of multiple inheritance in Java.
    • Survey: Data Access
      • POJO model entities can be stored in any ORM tool, just plain JDBC or others
      • Operations on entities built in Data Access Objects (DAO)
        • GetById(), GetListWhere(), Update(), etc.
      • Spring provides “templates” to make building DAOs easy
      • BTW, these are used in FLEX integration
    • Survey: Transaction Management
      • Abstracts on top of JDBC, Hibernate, JPA, JMS, EJB transaction.jta.* classes
      • Databases handle their own transactions:
        • START TRANSACTION, SAVE TRANSACTION
      • EJB containers allow transactions between multiple systems
      • Coding to Spring allows flexibility and growth
    • Survey: Remote Access
      • Compares to RMI, SOAP WS, Hessian, Burlap
      • Abstracts the concept of remoting and provides different implementations.
      • Client and service objects are POJOs.
      • Can make use of JSR-181 Web Services Metadata annotations
    • Survey: Dynamic Modules
      • Spring-DM is an implementation and integration of OSGI modules into Spring.
      • provide another layer of encapsulation over the concept of Class. Now you can have private and public classes as members of a module (jar).
      • allow for a lifecycle, so module can have a “running” state.
      • provide better naming, so versions can be included.
      • provide restricted “class space”, allowing for more than one version of a class at the same time.
      • More: Yuriy is working on this
    • Survey: Aspects
      • Cross-Cutting Concern: “functions that span multiple points of an application”
      • Logging, Transactions, Security
      • 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.
        • The proxy intercepts function calls and allows implementations of a Handler interface to intercept them.
      • Other Implementations exist, but are intrusive.
    • 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
        • View – the JSP pages to render a web page
        • 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.
    • Links
      • http://www.theserverside.com/news/1364527/Introduction-to-the-Spring-Framework