Spezialist für modellbasierte Entwicklungsverfahren


Gründung im Jahr 2003

Niederlassungen in Deutschland, Frankreich,
S...
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}"/> !
  ...
@Repository !
public class MyDatabase { !
     !@Value("#{systemProperties.databaseName}") !
     !public void setDatabase...
Database db = new MyDataBase(„myDb“, „uid“, „pwd“);!

ExpressionParser parser = new SpelExpressionParser();!
Expression ex...
Database db = new MyDataBase(„myDb“, „uid“, „pwd“);!

ExpressionParser parser = new SpelExpressionParser();!
Expression ex...
@Configuration       @Bean            @DependsOn




  @Primary           @Lazy             @Import




        @ImportRes...
@Configuration!
public class AppConfig {!
     !@Value("#{jdbcProperties.url}") !
     !private String jdbcUrl;!
     !!
 ...
@Configuration!
public class AppConfig {!
     !@Bean!
     !public FooService fooService() {!
         return new FooServ...
@Configuration!
public class AppConfig {!
     !@Bean!
     !public FooRepository fooRepository() {!
        return new Hi...
<context:component-scan !
     !base-package="org.example.config"/>


<util:properties id="jdbcProperties" 

     !     !l...
public static void main(String[] args) {!
    ApplicationContext ctx = !
     !new AnnotationConfigApplicationContext(!
  ...
Marshalling      Unmarshalling



JAXB   Castor   JiBX   Xstream   XMLBeans
<oxm:jaxb2-marshaller !
     !id="marshaller" !
     !contextPath=“my.packages.schema"/>!



<oxm:jaxb2-marshaller id="mar...
<beans>!
    <bean id="castorMarshaller"             !
     !class="org.springframework.oxm.castor.CastorMarshaller" >!
  ...
<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">!
      <proper...
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-
        Meth...
@Controller!
@RequestMapping(„/customer“)!
public class CustomerController{!

     !@RequestMapping(method=RequestMethod.G...
@Controller!
@RequestMapping(„/customer“)!
public class CustomerController{!

     !@RequestMapping(value=„/list“,!
     !...
@Controller!
@RequestMapping(„/customer“)!
public class CustomerController{!

     !@RequestMapping(value=„/show/{customer...
@Controller!
@RequestMapping(„/customer“)!
public class CustomerController{!

     !@RequestMapping(!
     !     !value=„/...
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;...
public class VistorForm(!
     !@NotNull!
     !@Size(max=40)!
     !private String name;!




                           ...
HSQL   H2   Derby   ...
<jdbc:embedded-database id="dataSource">!
      <jdbc:script location="classpath:schema.sql"/>!
      <jdbc:script locatio...
public class DataBaseTest {!
    private EmbeddedDatabase db;!

     @Before!
     public void setUp() {!
      !db = new ...
@Async (out
of EJB 3.1)



  JSR-303




  JSF 2.0




   JPA 2
Spring Application Tools




                                                     OSGi




                               ...
Grails for   Spring Best   AOP-
  Java        Practices    driven

                      Nice
      Test-driven
          ...
@Roo*
Command                      AspectJ
             Annotations
Line Shell                  Intertype     Metadata   R...
roo> project --topLevelPackage com.tenminutes
roo> persistence setup --provider HIBERNATE
                  --database HYP...
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.   ...
Support
                                    Grails Project
Project Wizard   different Grails
                             ...
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 {!
...
•  http://www.springframework.org/
Spring     •  http://www.springsource.com/



Grails &   •  http://www.grails.org/
    ...
Erfolg durch Agilität: Scrum-          Von »Exzellenten
Kompakt mit Joseph Pelrine –     Wissensorganisationen« lernen
   ...
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Spring 3 - An Introduction
Upcoming SlideShare
Loading in...5
×

Spring 3 - An Introduction

2,604

Published on

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.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,604
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
108
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Spring 3 - An Introduction

  1. 1. 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
  2. 2. Von und mit Thorsten Kamann 22.02.2010
  3. 3. - jUnit 3 Klassen Commons Attributes Struts 1.x Support
  4. 4. 100% API Spring 3 95% Extension Points
  5. 5. Modules OSGi Enterprise Maven Repository
  6. 6. #{...} @Value Expression Language XML ExpressionParser
  7. 7. <bean class=“MyDatabase"> ! !<property name="databaseName" ! ! value="#{systemProperties.databaseName}"/> ! !<property name="keyGenerator" ! ! value="#{strategyBean.databaseKeyGenerator}"/> ! </bean> !
  8. 8. @Repository ! public class MyDatabase { ! !@Value("#{systemProperties.databaseName}") ! !public void setDatabaseName(String dbName) {…} ! !@Value("#{strategyBean.databaseKeyGenerator}") ! !public void setKeyGenerator(KeyGenerator kg) {…} ! } !
  9. 9. 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);!
  10. 10. Database db = new MyDataBase(„myDb“, „uid“, „pwd“);! ExpressionParser parser = new SpelExpressionParser();! Expression exp = parser.parseExpression("name");! String name = (String) exp.getValue(db);!
  11. 11. @Configuration @Bean @DependsOn @Primary @Lazy @Import @ImportResource @Value
  12. 12. @Configuration! public class AppConfig {! !@Value("#{jdbcProperties.url}") ! !private String jdbcUrl;! !! !@Value("#{jdbcProperties.username}") ! !private String username;! !@Value("#{jdbcProperties.password}") ! !private String password;! }!
  13. 13. @Configuration! public class AppConfig {! !@Bean! !public FooService fooService() {! return new FooServiceImpl(fooRepository());! !}! !@Bean! !public DataSource dataSource() { ! return new DriverManagerDataSource(! ! !jdbcUrl, username, password);! !}! }!
  14. 14. @Configuration! public class AppConfig {! !@Bean! !public FooRepository fooRepository() {! return new HibernateFooRepository! ! !
 ! ! ! ! !(sessionFactory());! }! @Bean! public SessionFactory sessionFactory() {! !...! }! }!
  15. 15. <context:component-scan ! !base-package="org.example.config"/>
 <util:properties id="jdbcProperties" 
 ! !location="classpath:jdbc.properties"/>!
  16. 16. public static void main(String[] args) {! ApplicationContext ctx = ! !new AnnotationConfigApplicationContext(! ! ! ! ! ! !AppConfig.class);! FooService fooService = ctx.getBean(! ! ! ! ! ! !FooService.class);! fooService.doStuff();! }!
  17. 17. Marshalling Unmarshalling JAXB Castor JiBX Xstream XMLBeans
  18. 18. <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>!
  19. 19. <beans>! <bean id="castorMarshaller" ! !class="org.springframework.oxm.castor.CastorMarshaller" >! <property name="mappingLocation" 
 ! !value="classpath:mapping.xml" />! </bean>! </beans>

  20. 20. <oxm:xmlbeans-marshaller ! !id="marshaller“! !options=„XMLOptionsFactoryBean“/>!
  21. 21. <oxm:jibx-marshaller ! !id="marshaller" ! !target-class=“mypackage.Customer"/>!
  22. 22. <beans>! <bean id="xstreamMarshaller" !class="org.springframework.oxm.xstream.XStreamMarshaller">! <property name="aliases">! <props>! <prop key=“Customer">mypackage.Customer</prop>! </props>! !</property>! </bean>! ...! </beans>!
  23. 23. Spring MVC @Controller @RequestMapping @PathVariable
  24. 24. @Controller The C of MVC <context:component- scan/> Mapping to an URI (optional)
  25. 25. @RequestMapping Mapping a Controller or Methods to an URI URI-Pattern Mapping to a HTTP- Method Works with @PathVariable
  26. 26. @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
  27. 27. @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/list“,! ! ! ! ! !method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
  28. 28. @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/show/{customerId}“,! ! ! ! ! !method=RequestMethod.GET)! !public Customer show(! ! @PathVariable(„customerId“) long customerId){! ! !return customer;! !}! }!
  29. 29. @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:...“;! !}! }!
  30. 30. RestTemplate Delete Get Head Options Post Put
  31. 31. 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) {! !...! }!
  32. 32. public class VistorForm(! !@NotNull! !@Size(max=40)! !private String name;! JSR-303 !@Min(18)! !private int age;! }! <bean id="validator" ! !class=“...LocalValidatorFactoryBean" />!
  33. 33. HSQL H2 Derby ...
  34. 34. <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();!
  35. 35. 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();! }! }!
  36. 36. @Async (out of EJB 3.1) JSR-303 JSF 2.0 JPA 2
  37. 37. 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
  38. 38. Grails for Spring Best AOP- Java Practices driven Nice Test-driven Console
  39. 39. @Roo* Command AspectJ Annotations Line Shell Intertype Metadata RoundTrip (Source- Declarations Level)
  40. 40. 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
  41. 41. Roo for Best Groovy- Groovy Practices driven Test- Nice driven Console
  42. 42. 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
  43. 43. Support Grails Project Project Wizard different Grails Converter Versions Grails Full Groovy Grails Tooling Command Support Prompt
  44. 44. CTRL+ALT+G (or CMD+ALT+G on Macs)
  45. 45. >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!
  46. 46. •  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
  47. 47. 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
  1. Gostou de algum slide específico?

    Recortar slides é uma maneira fácil de colecionar informações para acessar mais tarde.

×