SPRING 3.0

I’m pleased to inform that SPRING 3.0 M1 is finally available to download.

This release has several major changes like

Ø  revised project layout and build system with module-based sources

Ø  updated entire codebase for Java 5 code style (generics, varargs)

Ø  updated to JUnit 4.5 and JRuby 1.1

Ø  introduced Spring EL parser (org.springframework.expression package)

Ø  introduced support for #{…} expressions in bean definitions

Ø  introduced expression-enabled @Value annotation for embedded expressions

Ø  introduced @PathVariable annotation for URI template handling in MVC handlers

Ø  introduced default value support for @RequestParam in MVC handlers

Ø  introduced @RequestHeader annotation for HTTP header access in MVC handlers

Ø  introduced AbstractAtomFeedView and AbstractRssFeedView base classes

Ø  introduced <spring:url> and <spring:param> JSP tags

Ø  Support EL and REST

Ø  new support for the Java EE 6 JPA (Java Persistence API) 2, in addition to already existing support for JDBC, Hibernate, iBatis, and much more.

Ø  Use the now fully integrated SpringSecurity framework, formerly Acegi.

 

As well as various minor changes.

This version is specifically based on JAVA 6 and J2EE 5 .but its compatibility with JAVA 5 and J2EE1.4 or above.

 

Encapsulation

Encapsulation refers to an object hiding its attributes behind its operations.

 

For more information:

It seals the attributes in a capsule, with operations on the edge.

Hidden attributes are said to be private.

 

 

Way to think of encapsulation is to imagine that objects are courteous to one another. If you wanted to borrow some money from a colleague to buy food in the staff canteen, you wouldn’t grab their wallet and look through it to see if they had enough cash.

Instead, you would ask them whether they could lend you some money and they would look

in their own wallet.

 

Polymorphism (satic and dynamic binding)

Static Binding:

           

Static binding is deciding at compile time which methods to invoke.

The method gets invoked is determined by the type of the reference.

 

In Java, static methods are statically bound.

Also class member variable is applicable for static binding because,

In Java does not support polymorphic behavior for member variables.

 

 

 

For example,

 

public class Animal

{

            public String type = “mammal”;

           

            public void show()

            {

                        System.out.println(“The animal is a: “ + type);

            }

}

 

 

public class Dog extends Animal

{

            public String type;  //same member variable name as in base class

           

            public Dog(String type)

            {

                        this.type = type;

            }

 

            public void show()  //same method signature as in base class

            {

                        System.out.println(“The dog is a: “ + type);

            }

}

 

 

 

public class DemoStaticBinding

{

            public static void main(String[] args)

            {

                        Animal doggie = new Dog(“daschund”);

                        doggie.show(); // “The dog is a: daschund”  (dynamic binding)

                        System.out.println(“The type is: “ + doggie.type); //”The type is: mammal” (static binding)

            }

}

 

 

 

Dynamic Binding:

           

Dynamic binding is deciding at run time which methods to invoke.

 

 

Here I explain the concepts,

 

public class Shape {

            private String name;

 

            public Shape(String aName) {

                        name = aName;

            }

 

            public String getName() {

                        return name;

            }

 

            public float calculateArea() {

                        return 0.0f;

            }

 

            public static void main(String argv[]) {

            Circle c = new Circle(“Circle C”);

            Square s = new Square(“Square S”);

            Shape shapeArray[] = {c, s};

            for (int i=0; i<shapeArray.length; i++) {

                        System.out.println(“The area of “ + shapeArray[i].getName()

                                                + ” is “ + shapeArray[i].calculateArea()+” sq. cm.\n”);

            }

            }

}

public class Circle extends Shape {

            private int radius;

 

             Circle(String aName) {

                        super(aName);

                        radius = 3;

            }

 

            public float calculateArea() {

                        float area;

                        area = (float) (3.14 * radius * radius);

                        return area;

            }

}

 

 

class Square extends Shape {

            private int side;

 

             Square(String aName) {

                        super(aName);

                        side = 3;

            }

 

            public float calculateArea() {

                        int area;

                        area = side * side;

                        return area;

            }

}

 

 

Based on the output from the code, it is clear that the appropriate method for

responding to the choice in shapeArray has been used:

The area of Circle C is 28.26 sq. cm.

The area of Square S is 9 sq. cm.

 

The method has been selected based on the class of the shape referenced in

shapeArray at run-time. This is only possible in programming languages that support

dynamic binding. With dynamic binding, the variable shapeArray[i] is bound

to an object method at run time when the class definition of the shape referenced is

known.

 

Note:

            Static binding is limited and may lead to difficulty software maintenance.

On the other hand dynamic binding is very flexibility and easy to maintain.