Spring 3 - An Introduction
Upcoming SlideShare
Loading in...5
×
 

Spring 3 - An Introduction

on

  • 3,850 views

Since late 2009 there is Spring 3 published. Some things are new, something keep and something was removed....

Since late 2009 there is Spring 3 published. Some things are new, something keep and something was removed.
Thos talk discuss the changes of the 3rd edition of Spring and introduce Spring Roo, Grails and the SpringSource Toolsuite.

Statistics

Views

Total Views
3,850
Views on SlideShare
3,703
Embed Views
147

Actions

Likes
2
Downloads
107
Comments
0

4 Embeds 147

http://www.thorsten-kamann.de 100
http://blog.kamann.info 23
http://www.slideshare.net 23
http://torpedovip.com 1

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 - An Introduction Spring 3 - An Introduction Presentation Transcript

  • Spezialist für modellbasierte Entwicklungsverfahren Gründung im Jahr 2003 Niederlassungen in Deutschland, Frankreich, Schweiz und Kanada 140 Mitarbeiter Strategisches Mitglied der Eclipse Foundation Intensive Verzahnung im Bereich der Forschung Mitglied von ARTEMISIA Embedded Software Development Enterprise Application Development
  • Von und mit Thorsten Kamann 22.02.2010
  • - jUnit 3 Klassen Commons Attributes Struts 1.x Support
  • 100% API Spring 3 95% Extension Points
  • Modules OSGi Enterprise Maven Repository
  • #{...} @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();! }!
  • Marshalling Unmarshalling JAXB Castor JiBX Xstream XMLBeans
  • <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) {! !...! }!
  • public class VistorForm(! !@NotNull! !@Size(max=40)! !private String name;! JSR-303 !@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 Application Tools OSGi Flexible Deployments •  Spring project, bean •  OSGi bundle •  Support for all the and XML file overview and visual most common Java wizards dependency graph EE application •  Graphical Spring •  Classpath servers configuration editor management based •  Advanced support •  Spring 3.0 support on OSGi meta data for SpringSource including •  Automatic dm Server @Configuration generation of •  Advanced support and @Bean styles manifest for SpringSource tc •  Spring Web Flow dependency meta Server and Spring Batch data •  Cloud Foundry visual development •  SpringSource targeting for dm tools Enterprise Bundle Server and tc Server •  Spring Roo project Repository browser •  VMware Lab wizard and •  Manifest file Manager and development shell validation and best Workstation •  Spring Application practice integration and blue prints and best recommendations deployment practice validation
  • Grails for Spring Best AOP- Java Practices driven 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
  • Erfolg durch Agilität: Scrum- Von »Exzellenten Kompakt mit Joseph Pelrine – Wissensorganisationen« lernen 14:00 bis 18:00 – 13:00 bis 18:30 25. Februar 2010 25. Februar 2010 Joseph Pelrine, Jena, Lise-Meitner-Allee 6, 44801 Veranstalter: itemis AG Bochum, Veranstalter: ck 2 Hands On Model-Based Embedded World 2010 – Halle Development with Eclipse – 10 – Stand 529 09:30 bis 16:30 02.-04. März 2010 04. März 2010 Nürnberg - Messezentrum 1 Axel Terfloth, Andreas Unger, embeddedworld Nürnberg Zukunft der Wissensarbeit. Best Practice Sharing auf der CeBIT 2010 – 10:00 bis 13:00 04. März 2010 Exzellente Wissensorganisation, Hannover, Veranstalter: ck 2, kostenlos