• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Spring 3 - Der dritte Frühling
 

Spring 3 - Der dritte Frühling

on

  • 2,554 views

»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Spring 3 verspricht eine verbesserte und dynamischere Konfiguration, einen leistungsfähigen und mächtigen REST-Support ...

»Spring 3« ist da. Vieles ist geblieben, manches verschwunden, manches neu. Spring 3 verspricht eine verbesserte und dynamischere Konfiguration, einen leistungsfähigen und mächtigen REST-Support und viele kleine Verbesserungen. Parallel zu dem Spring 3-Release wurden auch andere Tools und Projekte aktualisiert, auf die wir ebenfalls einen Blick werfen wollen:

* Wichtige Änderungen
* Java Configuration
* Spring Expression Language
* Spring MVC und Rest
* Embedded Database
* SpringSource Toolsuite
* Spring Roo
* Grails

Statistics

Views

Total Views
2,554
Views on SlideShare
2,364
Embed Views
190

Actions

Likes
1
Downloads
0
Comments
0

3 Embeds 190

http://www.thorsten-kamann.de 116
http://blog.kamann.info 66
http://www.slideshare.net 8

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

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 3 - Der dritte Frühling Spring 3 - Der dritte Frühling Presentation Transcript

    • Thorsten Kamann · itemis AG · 15.03.2010
    • What‘s new, what‘s old? Configuration OX/Mapper REST-Support MVC, Embedded Database, EE6 SpringSource Toolsuite Spring Roo Grails
    • - jUnit 3 Klassen Commons Attributes Struts 1.x Support
    • 100% API Spring 3 95% Extension Points
    • Modules OSGi Enterprise Maven Repository
    • #{...} Expression Language Java Config
    • #{...} @Value Expression Language XML ExpressionParser
    • <bean class=“MyDatabase"> ! !<property name="databaseName" ! ! value="#{systemProperties.databaseName}"/> ! !<property name="keyGenerator" ! ! value="#{strategyBean.databaseKeyGenerator}"/> ! </bean> !
    • @Repository ! public class MyDatabase { ! !@Value("#{systemProperties.databaseName}") ! !public void setDatabaseName(String dbName) {…} ! !@Value("#{strategyBean.databaseKeyGenerator}") ! !public void setKeyGenerator(KeyGenerator kg) {…} ! } !
    • Database db = new MyDataBase(„myDb“, „uid“, „pwd“);! ExpressionParser parser = new SpelExpressionParser();! Expression exp = parser.parseExpression("name");! EvaluationContext context = new ! ! !
 ! ! ! !StandardEvaluationContext();! context.setRootObject(db);! String name = (String) exp.getValue(context);!
    • Database db = new MyDataBase(„myDb“, „uid“, „pwd“);! ExpressionParser parser = new SpelExpressionParser();! Expression exp = parser.parseExpression("name");! String name = (String) exp.getValue(db);!
    • @Configuration @Bean @DependsOn @Primary @Lazy @Import @ImportResource @Value
    • @Configuration! public class AppConfig {! @Value("#{jdbcProperties.url}") ! !private String jdbcUrl;! !! !@Value("#{jdbcProperties.username}") ! !private String username;! !@Value("#{jdbcProperties.password}") ! !private String password;! }!
    • @Configuration! public class AppConfig {! @Bean! !public FooService fooService() {! ! !return new FooServiceImpl(fooRepository());! }! !@Bean! public DataSource dataSource() { ! !return new DriverManagerDataSource(! ! ! !jdbcUrl, username, password);! }! }!
    • @Configuration! public class AppConfig {! @Bean! !public FooRepository fooRepository() {! ! !return new HibernateFooRepository ! ! !
 ! ! !(sessionFactory());! }! @Bean! public SessionFactory sessionFactory() {! ! !...! }! }!
    • <context:component-scan ! !base-package="org.example.config"/>
 <util:properties id="jdbcProperties" 
 ! !location="classpath:jdbc.properties"/>!
    • public static void main(String[] args) {! ApplicationContext ctx = ! ! ! !new AnnotationConfigApplicationContext(! ! ! ! ! ! ! ! ! ! ! ! !AppConfig.class);! FooService fooService = ctx.getBean(! ! ! ! ! ! ! ! ! ! ! ! !FooService.class);! fooService.doStuff();! }!
    • <oxm:jaxb2-marshaller ! !id="marshaller" ! !contextPath=“my.packages.schema"/>! <oxm:jaxb2-marshaller id="marshaller">! <oxm:class-to-be-bound name=“Customer"/>! <oxm:class-to-be-bound name=„Address"/>! ...! </oxm:jaxb2-marshaller>!
    • <beans>! <bean id="castorMarshaller" ! !class="org.springframework.oxm.castor.CastorMarshaller" >! <property name="mappingLocation" 
 ! !value="classpath:mapping.xml" />! </bean>! </beans>

    • <oxm:xmlbeans-marshaller ! !id="marshaller“! !options=„XMLOptionsFactoryBean“/>!
    • <oxm:jibx-marshaller ! !id="marshaller" ! !target-class=“mypackage.Customer"/>!
    • <beans>! <bean id="xstreamMarshaller" !class="org.springframework.oxm.xstream.XStreamMarshaller">! <property name="aliases">! <props>! <prop key=“Customer">mypackage.Customer</prop>! </props>! !</property>! </bean>! ...! </beans>!
    • Spring MVC @Controller @RequestMapping @PathVariable
    • @Controller The C of MVC <context:component- scan/> Mapping to an URI (optional)
    • @RequestMapping Mapping a Controller or Methods to an URI URI-Pattern Mapping to a HTTP- Method Works with @PathVariable
    • @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
    • @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/list“,! ! ! ! method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
    • @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/show/{customerId}“,! ! ! ! method=RequestMethod.GET)! !public Customer show(! ! @PathVariable(„customerId“) long customerId){! ! !return customer;! !}! }!
    • @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(! ! !value=„/show/{customerId}/edit/{addressId}“,! ! !method=RequestMethod.GET)! !public String editAddressDetails(! ! @PathVariable(„customerId“) long customerId,! ! @PathVariable(„addressId“) long addressId){! ! !return „redirect:...“;! !}! }!
    • RestTemplate Delete Get Head Options Post Put
    • Host localhost:8080! Accept text/html, application/xml;q=0.9! Accept-Language fr,en-gb;q=0.7,en;q=0.3! Accept-Encoding gzip,deflate! Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7! Keep-Alive 300! public void displayHeaderInfo(! @RequestHeader("Accept-Encoding") String encoding,! @RequestHeader("Keep-Alive") long keepAlive) {! !...! }!
    • JSR-303 public class VistorForm(! !@NotNull! @Size(max=40)! !private String name;! !@Min(18)! !private int age;! }! <bean id="validator" ! !class=“...LocalValidatorFactoryBean" />!
    • HSQL H2 Derby ...
    • <jdbc:embedded-database id="dataSource">! <jdbc:script ! ! ! !location="classpath:schema.sql"/>! <jdbc:script ! ! ! !location="classpath:test-data.sql"/>! </jdbc:embedded-database>! EmbeddedDatabaseBuilder builder = new ! !
 ! ! ! !EmbeddedDatabaseBuilder();! EmbeddedDatabase db = builder.setType(H2)! ! ! ! !.addScript(“schema.sql")! ! ! ! !.addScript(„test-data.sql")! ! ! ! !.build();! //Do somethings: db extends DataSource! db.shutdown();!
    • public class DataBaseTest {! private EmbeddedDatabase db;! @Before! public void setUp() {! ! !db = new EmbeddedDatabaseBuilder()! ! ! ! !.addDefaultScripts().build();! !! }! @Test! public void testDataAccess() {! JdbcTemplate template = ! ! ! ! ! !new JdbcTemplate(db);! template.query(...);! }! @After! public void tearDown() {! db.shutdown();! }! }!
    • @Async (out of EJB 3.1) JSR-303 JSF 2.0 JPA 2
    • • Spring project, • OSGi bundle • Support for all the Spring Application Tools OSGi Flexible Deployments bean and XML file overview and most common wizards visual dependency Java EE • Graphical Spring graph application configuration • Classpath servers editor management • Advanced support • Spring 3.0 support based on OSGi for SpringSource including meta data dm Server @Configuration • Automatic • Advanced support and @Bean styles generation of for SpringSource • Spring Web Flow manifest tc Server and Spring Batch dependency meta • Cloud Foundry visual data targeting for dm development tools • SpringSource Server and tc • Spring Roo project Enterprise Bundle Server wizard and Repository • VMware Lab development shell browser Manager and • Spring • Manifest file Workstation Application blue validation and integration and prints and best best practice deployment practice validation recommendations
    • Grails for Spring Best AOP-driven Java Practices Nice Test-driven Console
    • @Roo* Command AspectJ Annotations Line Shell Intertype Metadata RoundTrip (Source- Declarations Level)
    • roo> project --topLevelPackage com.tenminutes roo> persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY roo> entity --class ~.Timer --testAutomatically roo> field string --fieldName message --notNull roo> controller all --package ~.web roo> selenium test --controller ~.web.TimerController roo> perform tests roo> perform package roo> perform eclipse roo> quit $ mvn tomcat:run
    • Roo for Best Groovy- Groovy Practices driven Test- Nice driven Console
    • Have your next Web 2.0 Get instant feedback, Powered by Spring, project done in weeks See instant results. Grails out performs the instead of months. Grails is the premier competition. Dynamic, Grails delivers a new dynamic language agile web development age of Java web web framework for the without compromises. application productivity. JVM. Rapid Dynamic Robust
    • Support Grails Project Project Wizard different Grails Converter Versions Grails Full Groovy Grails Tooling Command Support Prompt
    • CTRL+ALT+G (or CMD+ALT+G on Macs)
    • >grails create-app tenminutes-grails! <grails create-domain-class tenminutes.domain.Timer! Timer.groovy:! class Timer {! !String message! !static constraints = {! ! !message(nullable: false)! !}! }! >grails create-controller tenminutes.web.TimerController! TimerController.groovy:! class TimerControllerController {! !def scaffold = Timer! }! >grails run-app!
    • •  http://www.springframework.org/ Spring •  http://www.springsource.com/ Grails & •  http://www.grails.org/ •  http://groovy.codehaus.org/ Groovy •  http://www.thorsten-kamann.de Extras •  http://www.itemis.de