Spring

From Wiki RB4
Revision as of 23:34, 27 February 2021 by UweHeuer (talk | contribs) (→‎Introduction)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Introduction[edit]

The Spring Framework is an open-source application framework, introduced and developed in 2004. The main ideas were suggested by an experienced J2EE architect, Rod Johnson. Just as Hibernate attacks CMP as primitive ORM technology, Spring attacks EJB as unduly complicated and not susceptible to unit-testing. Instead of EJB, Spring suggests that we make use of ordinary Java beans, with some slight modifications, to get all the supposed advantages of EJB environment. Thus, Spring is posed as an alternative to EJB essentially. However, as a concession to the existing EJB investments, Spring is designed to operate with EJB if required.

Dependency Injection[edit]

Ein wesentliches Feature des Spring-Frmeworls ist die sogenannte Dependency Injection, bzw. Inversion of Controll. Hierbei handelt es sich um ein Design-Pattern, welches im Objektorientierten Umfeld im häufiger zum Einsatz kommt. Wesentliches Prinzip dieses Patterns ist die stärkere Trennung von Verknüpfungen zwischen Komponenten zu ermöglichen, ohne diese Verknüpfungen (Relationen) fest im Code zu integrieren.

Anstelle von festen Verknüpfungen werden diese Abhängigkeiten von anderen Komponten über Konfigurationsdateien realisiert. Im Rahmen von Spring kommt hier ein definiertes XML-Format zum Einsatz. Das Spring-Framework nutzt das Prinzip der Dependency Injection in großem Umfang.

Versions[edit]

Version 2.5[edit]

s. http://steelheart.kr/tc/163

Packaging[edit]

  • spring.jar
  • spring-webmvc.jar

Installation[edit]

  1. Downloaded spring-framework-2.5.1-with-dependencies.zip and spring-framework-2.5.1.zip (for a description s. readme.txt).

Deployment Structure[edit]

The directory 'dist' contains the Spring binary jar file spring.jar. The subdirectory 'modules' contains the module-specific jar files.

spring.jar[edit]

Convient jar file with all standard modules except the test and MVC support.

Application Building[edit]

<ServletName>-servlet.xml[edit]

This file contains the bean definitions (plain old Java objects) used by the DispatcherServlet. It is the WebApplicationContext where all web-related components go. The name of this file is determined by the value of the <servlet-name/> element from the 'web.xml', with '-servlet' appended to it.

<bean>[edit]

This defines the controller that our application will be using to service a request with the corresponding URL mapping. The Spring Web MVC framework uses an implementation class of the interface called HandlerMapping to define the mapping between a request URL and the object that is going to handle that request (the handler). Unlike the DispatcherServlet, the HelloController is responsible for handling a request for a particular page of the website and is also known as a 'Page Controller' (Fowler). The default HandlerMapping that the DispatcherServlet uses is the BeanNameUrlHandlerMapping; this class will use the bean name to map to the URL in the request so that the DispatcherServlet knows which controller must be invoked for handling different URLs.

Projects[edit]

Literature[edit]

  1. Tutorial http://www.roseindia.net/spring/springpart2.shtml
  2. Spring in bestehende Anwendungen integrieren, Javamagazin 07.2008