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

Spring 3 - An Introduction

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

  • 24.
    <oxm:xmlbeans-marshaller ! !id="marshaller“! !options=„XMLOptionsFactoryBean“/>!
  • 25.
    <oxm:jibx-marshaller ! !id="marshaller" ! !target-class=“mypackage.Customer"/>!
  • 26.
    <beans>! <bean id="xstreamMarshaller" !class="org.springframework.oxm.xstream.XStreamMarshaller">! <property name="aliases">! <props>! <prop key=“Customer">mypackage.Customer</prop>! </props>! !</property>! </bean>! ...! </beans>!
  • 27.
    Spring MVC @Controller @RequestMapping @PathVariable
  • 28.
    @Controller The C of MVC <context:component- scan/> Mapping to an URI (optional)
  • 29.
    @RequestMapping Mapping a Controller or Methods to an URI URI-Pattern Mapping to a HTTP- Method Works with @PathVariable
  • 30.
    @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
  • 31.
    @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/list“,! ! ! ! ! !method=RequestMethod.GET)! !public List<Customer> list(){! ! !return customerList;! !}! }!
  • 32.
    @Controller! @RequestMapping(„/customer“)! public class CustomerController{! !@RequestMapping(value=„/show/{customerId}“,! ! ! ! ! !method=RequestMethod.GET)! !public Customer show(! ! @PathVariable(„customerId“) long customerId){! ! !return customer;! !}! }!
  • 33.
    @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:...“;! !}! }!
  • 34.
    RestTemplate Delete Get Head Options Post Put
  • 35.
    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) {! !...! }!
  • 36.
    public class VistorForm(! !@NotNull! !@Size(max=40)! !private String name;! JSR-303 !@Min(18)! !private int age;! }! <bean id="validator" ! !class=“...LocalValidatorFactoryBean" />!
  • 37.
    HSQL H2 Derby ...
  • 38.
    <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();!
  • 39.
    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();! }! }!
  • 40.
    @Async (out of EJB3.1) JSR-303 JSF 2.0 JPA 2
  • 42.
    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
  • 48.
    Grails for Spring Best AOP- Java Practices driven Nice Test-driven Console
  • 49.
    @Roo* Command AspectJ Annotations Line Shell Intertype Metadata RoundTrip (Source- Declarations Level)
  • 53.
    roo> project --topLevelPackagecom.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
  • 56.
    Roo for Best Groovy- Groovy Practices driven Test- Nice driven Console
  • 57.
    Have your nextWeb 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
  • 58.
    Support Grails Project Project Wizard different Grails Converter Versions Grails Full Groovy Grails Tooling Command Support Prompt
  • 60.
  • 62.
    >grails create-app tenminutes-grails! <grailscreate-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!
  • 64.
    •  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
  • 66.
    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