180 likes | 391 Views
Spring , Hibernate and Web Services. 13 th September 2014. Software Framework. Refers to set of libraries or classes, which are used in the creation of an application .
E N D
Spring , Hibernate and Web Services 13th September 2014
Software Framework • Refers to set of libraries or classes, which are used in the creation of an application. • An application framework provides a foundation for developing the application and alleviates from putting additional efforts for it. • Techniques used in framework • Configuration files • Central Controller • Presentation System
What does Spring offer? • Dependency Injection • Also known as IoC (Inversion of Control) • Inversion of controltakes the integration and configuration of the system out of the application, and instead performs dependency injection. • Aspect Oriented Programming • Runtime injection-based • Service Abstractions • ORM, DAO, Web MVC etc. • Allows access to these without knowing how they actually work • Open source project on SourceForge • founded by Rod Johnson & Jürgen Höller • Apache license
What does Spring offer? • Enable applications to be coded from POJOs • Allow enterprise services to be applied to those POJOs in a declarative, non-invasive way • POJOs can be made transactional without the need to know about transaction APIs • Collaborating instances are injected using plain Java constructors or setter methods • True POJOs are testable in isolation • Decouples your application objects from their environment • Switch to global transactions over JTA • Export your business objects in different environments • Switch between SLSB, web service etc.
What does Spring offer? • Core Lightweight Container(The heart of Spring) • Aspect-Oriented Programming (AOP) framework • Modularizes behavior that would otherwise be scattered through different methods • Decorates your POJOs with cross-cutting behavior in a transparent manner • Container instantiates objects and injects dependencies on collaborating objects and configuration properties through Java methods • Uses Hollywood Principle - “Don’t call me, I’ll call you”
Benefits • Portability • Your core business logic is implemented once and runs anywhere • Leverage • Your core code is decoupled from volatile infrastructure • Consistency • Common configuration strategy everywhere • Productivity • Test-driven development • Don’t need to reinvent your own infrastructure
Struts Vs Spring - MVC Spring Struts
Spring Modules JSP, JSF, Velocity, Jasper Reports… Presentation tier Remote exporters Service objects / Business Facades Middle tier Domain objects DAO interfaces DAO implementations RDBMS
Dependency Injection • Example: public class Department{ private Employee employee; public Department(Employee emp) { employee= emp; } } Spring is a framework for wiring up your entire application Characteristics • Cons • You must create dependencies to pass along • Pros • Easy to understand • Testable • Flexible • Extensible • Enforces separation of interface from implementation • Code is simple and clear
What does hibernate offer? • Open Source light-weight ORM solution • Java Object/Relational Mapping, Maps JavaBeans (POJOs) to tables, • Lets you avoid SQL • Works with (almost) all relational Databases, Easy migration from one vendor database to another • Hibernate generates the JDBC Code based on the underlying vendor database • Support CRUD (Create, Read, Update and Delete) operations • Very well matured and adopted by a large developer community
ORM – Hibernate Introduction • Traditional Solutions • JDBC/SQL code embedded in Class, EJB (J2EE) solution etc. • More coding, container dependent etc. are the issues • Best practice would be to keep the Persistence separate from classes
Webservice Introduction • SOA is a software design principle and an architectural pattern for implementing loosely coupled, reusable and coarse grained services. You can implement SOA using any protocols such as HTTP, HTTPS, JMS. Messages can be in XML or Data Transfer Objects (DTOs). • Web service is an implementation technology and one of the ways to implement SOA. • Web services offer is the standards based and platform-independent service via HTTP, XML, SOAP, WSDL and UDDI, thus allowing interoperability between heterogeneous technologies such as J2EE and .NET
Webservice Introduction • Web Services support loosely coupled connections. • The loosely coupled applications reduce the cost of maintenance and increases re-usability. • Web Services present a new form of middle-ware based on XML and HTTP. • Web services are language and platform independent. • Styles of Web Services used for application integration • SOAP WS and RESTful Web Service