SlideShare une entreprise Scribd logo
1  sur  86
 
Ziele der Software-Entwicklung…
Was ist  „gute“  Software?
… und was man dafür braucht
Das Thema heute ist:
 
Technische Infrastruktur
Technische Infrastruktur
Technische Infrastruktur
Technische Infrastruktur
Technische Infrastruktur
 
Leichtgewichtige Architekturen?
Leichtgewichtige Architekturen
Leichtgewichtige Architekturen
Leichtgewichtige Architekturen
 
Beispiel: Das Domänenmodell
Beispiel: Komponenten
Beispiel: Komponenten
Beispiel: Komponenten
Beispiel: Komponenten
Beispiel: Komponenten
Beispiel: Komponenten
 
Exkurs: Maven
Exkurs: Maven - Repositories
Exkurs: Maven
Exkurs: Maven
Exkurs: Maven - Abhängigkeiten <project> <modelVersion>4.0.0</modelVersion> <groupId>spring2.jpa.basic</groupId> <artifactId>spring2-jpa-basic-impl</artifactId> <version>1.0.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.1</version> </dependency> […] </dependencies> […] </project> Artefakt-Beschreibung SNAPSHOT! Abhängigkeit liefert  alle benötigten  Bibliotheken
Exkurs: Maven-PlugIns <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4-SNAPSHOT</version> <configuration> <suiteXmlFiles>   <suiteXmlFile>quick-suite.xml</suiteXmlFile> </suiteXmlFiles>    </configuration> </plugin> </plugins> </build> PlugIn für  Testausführung Lädt  Testsuite
 
Exkurs: Spring [Was ist Spring?] Inversion of Control Ansammlung von API's Programmier- modell
Exkurs: Spring [Komponenten] Spring Core AOP Spring AOP AspectJ-Integration DAO Spring JDBC Transaction- Management ORM JPA Hibernate Toplink JDO JEE JMX JMS JCA Remoting EJB's Email WEB Spring MVC Struts WebWork Tapestry JSF PDF Portlets
Exkurs: Spring [Features]
Exkurs: Spring [Features]
Exkurs: Spring [Features]
Exkurs: Spring [Features]
Exkurs: Spring [Features]
 
Exkurs: Java Persistence API
Exkurs: Java Persistence API
Exkurs: Java Persistence API
 
Exkurs: Groovy
Exkurs: Groovy
Exkurs: Groovy The Groovy Truth Runtime type Evaluation criterion required for truth Boolean Booleanwert muss  true  sein Matcher Der reguläre Ausdruck muss mindestens 1 Treffer haben Collection Die Collection darf nicht leer sein Map Die Map darf nicht leer sein String Der String darf ebenfalls nicht leer sein Number Muss ungleich 0 sein Alles andere Die Objektreferenz muss ungleich  null  sein
Exkurs: Groovy – Listen und Ranges def list = [„item1“, „item2“, „item3“] assert list.size() def emptyList = [] assert !emptyList list << „item4“ assert list.size() == 4 def range = [1..4] assert range.size() == 4 def range1 = [1..<4] assert range1.size() == 3 Eine Liste mit 3 Einträgen Eine leere Liste Der ersten Liste wird ein  Element hinzugefügt Eine Range mit den Werten  1, 2, 3, 4 wird erstellt Eine Range mit den Werten  1, 2, 3 wird erstellt
Exkurs: Groovy – Listen und Closures def list = [„item1“, „item2“, „item3“] list.each{ print it+“ „} > item1 item2 item3  assert list.find{it==„item2“} list = [„a1“, „a2“, „a3“, „i1“, „i2“] assert list.findAll{ it.startsWith(„i“)}.size() == 3 Each-Closure Ein bestimmtes Element  finden Eine Anzahl an Elementen aus der Liste finden
Exkurs: Groovy - Maps def map = [key1: „value1“, key2: „value2“] assert map.size() == 2 assert map.key1 == „value1“ map.key3 == „value3“ assert map.size() == 3 assert map[„key2“] == „value2“ assert map.get(„key2“) == „value2“ def emptyMap = [:] assert !emptyMap Eine Map mit 2 Einträgen  wird erstellt Ein 3. Eintrag wird  hinzugefügt Alternative Zugriffsmethode auf die Elemente der Map Eine leere Map  wird erstellt
 
 
Beispiel: API - Domänenmodell
Beispiel: API
 
Zum Beispiel: Impl - Entities @Entity(table=„CUSTOMERS“) public class Customer{ @Id @GeneratedValue( strategy = GenerationType.AUTO) private Long id; @OneToOne(targetEntity = Address.class,    cascade = { CascadeType.ALL}) private IAddress address; @Column(length = 40) private String firstName; … } Entity auf Tabelle  CUSTOMERS mappen Primary Key 1-zu-1 Beziehung Konfiguration einer  Column in der Tabelle  CUSTOMERS
Zum Beispiel: Impl – persistence.xml <persistence …>   <persistence-unit  name=&quot;spring2-jpa-basic-persistence-unit&quot;> <properties> <property  name=&quot;hibernate.jdbc.batch_size&quot;  value=&quot;0&quot;/> <property  name=&quot;hibernate.default_batch_fetch_size&quot;  value=&quot;5&quot;/> […] </properties> </persistence-unit> </persistence> Eindeutiger Name der  Persistence-Unit Eigenschaften der  Persistence-Unit
Zum Beispiel: Impl – DAO‘s @Repository public class CustomerDao  implements ICustomerDao { @PersistenceContext( unitName = &quot;spring2-jpa-basic-persistence-unit&quot;) protected EntityManager entityManager; public List<ICustomer> findAll() { return entityManager .createQuery(&quot;from Customer c&quot;) .getResultList(); } […] } Sorgt für die  Übersetzung von Exceptions Injection des  Entity-Managers über Spring Plain Java
Zum Beispiel: Impl – Spring-Config <bean class=„PersistenceAnnotationBeanPostProcessor&quot; /> <bean class=„PersistenceExceptionTranslationPostProcessor&quot; /> Support der Annotations in den DAO‘s Excpetion Translation
Zum Beispiel: Impl – Spring-Config <bean id=&quot;entityManagerFactory&quot; class=„LocalContainerEntityManagerFactoryBean&quot;> <property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /> <property name=&quot;jpaVendorAdapter&quot;> <bean class=„HibernateJpaVendorAdapter&quot;> <property name=&quot;databasePlatform&quot; value=&quot;${jpa.provider.databasePlatform}&quot; /> <property name=&quot;showSql&quot;  value=&quot;${jpa.provider.showSql}&quot; /> <property name=&quot;generateDdl&quot;  value=&quot;${jpa.provider.generateDdl}&quot; /> </bean> </property> </bean> JPA-Vendor Eigenschaften des JPA-Vendors Kein JNDI
Zum Beispiel: Impl – Spring-Config <bean id=&quot;dataSource&quot; class=„DriverManagerDataSource&quot; p:driverClassName=&quot;${jdbc.driver.classname}&quot; p:url=&quot;${jdbc.connection.url}&quot;  p:username=&quot;${jdbc.connection.uid}&quot; p:password=&quot;${jdbc.connection.pwd}&quot; /> DataSource  Konfiguration
Zum Beispiel: Impl - Services @Transactional public class CustomerService  implements ICustomerService { private ICustomerDao customerDao; private IAddressDao addressDao; […] @Transactional(readOnly = true) public List<ICustomer> findAllCustomers() { return customerDao.findAll(); } […] } ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Diese Methode hat nur einen lesenden Zugriff
Zum Beispiel: Impl – Spring-Config <bean id=&quot;transactionManager&quot; class=„JpaTransactionManager&quot;> <property name=&quot;entityManagerFactory&quot; ref=&quot;entityManagerFactory&quot; /> </bean> <tx:annotation-driven  transaction-manager=&quot;transactionManager&quot; /> JPA Transaction-Manager Transaktionen werden  per Annotations  konfiguriert
Zum Beispiel: Impl – Spring-Config <tx:advice id=&quot;txAdvice&quot; transaction-manager=&quot;transactionManager&quot;> <tx:attributes> <tx:method name=&quot;get*&quot; read-only=&quot;true&quot; /> <tx:method name=&quot;*&quot; /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id=“dataaccess&quot; expression=&quot;execution(* […].dataaccess.*.*(..))&quot; /> <aop:advisor advice-ref=&quot;txAdvice&quot; pointcut-ref=“dataaccess&quot; /> </aop:config> Alternative Transaktionskonfiguration
Zum Beispiel: Problem Annotation @Service public class CustomerService{ @Autowired private ICustomerDao customerDao; } Spring-eigene Annotations @Target(value = ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Service public @interface MyService { } Eigene Annotation  Basierend auf @Service @MyService public class CustomerService{ } Verwendung der eigenen  Annotation
Zum Beispiel: Impl – Unit Testing
Zum Beispiel: Impl – Unit Testing
Zum Beispiel: Impl – Unit Testing public final void testChangeAddress() { IAddress expAddress = new Address( street: &quot;s1&quot;, city: &quot;c1&quot;,  country: &quot;c1&quot;, zipCode: &quot;z1&quot;); def addressDao = [ store:{entity -> expAddress}] as IAddressDao   ICustomerService customerService =  new CustomerService(addressDao: addressDao) def result = customerService .changeAddress(expAddress) assert expAddress == result } Erzeugung einer neuen Instanz mit Constructor- Enhancement Implementierung des IAddressDao Neue Instanz des  ICustomerService Ausführen und  Ergebnis vergleichen
 
Zum Beispiel: Webapp
 
Zum Beispiel: Integration
Zum Beispiel: Integration
Zum Beispiel: Integration
Zum Beispiel: Integration
Zum Beispiel: Integration
Zum Beispiel: Integration
Zum Beispiel: Integration (Selenium)
[object Object],Zum Beispiel: Integration (Testcode) public class SimpleWebtest{ @BeforeClass() @Parameters([&quot;browser&quot;])    final void prepareSelenium(String browser){} @BeforeMethod final void startSelenium(){} @AfterMethod final void stopSelenium(){} @Test final void testTheStuff(){} } Parameterisierte Methode wird  einmal pro Klasseninstanz  ausgeführt Wird pro Testmethode  ausgeführt
Zum Beispiel: Integration (Testsuite) <suite name=&quot;gidp-sample-integration&quot;> <test verbose=&quot;2&quot; name=&quot;FFIntegrationtests&quot; annotations=&quot;JDK&quot;> <parameter name=&quot;browser&quot; value=&quot;firefox&quot;/> <packages> <package name=“[…].integration&quot;/> </packages> </test> <test verbose=&quot;2&quot; name=&quot;IEIntegrationtests&quot; annotations=&quot;JDK&quot;> <parameter name=&quot;browser&quot; value=&quot;iexplore&quot;/> <packages> <package name=&quot;de.gidp.sample.integration&quot;/> </packages> </test> </suite>
 
Fazit
Fazit
 
Ressourcen: Links
Über den Referenten

Contenu connexe

En vedette

2009 Meet The Principal
2009 Meet The Principal2009 Meet The Principal
2009 Meet The Principalph0enix74
 
Úvod do optimalizace pro vyhledávače
Úvod do optimalizace pro vyhledávačeÚvod do optimalizace pro vyhledávače
Úvod do optimalizace pro vyhledávačeguest8375ba
 
Bildspel om hembygdsforskning
Bildspel om hembygdsforskningBildspel om hembygdsforskning
Bildspel om hembygdsforskninghembygdsigtuna
 
Pure Visibility Ppc Judo
Pure Visibility Ppc JudoPure Visibility Ppc Judo
Pure Visibility Ppc JudoJon Gatrell
 
First Innovi Corp Brands Presentation
First Innovi Corp Brands PresentationFirst Innovi Corp Brands Presentation
First Innovi Corp Brands Presentationyocard
 
Rainbows
RainbowsRainbows
Rainbowsnonnon
 
Religion in Blue Jeans
Religion in Blue JeansReligion in Blue Jeans
Religion in Blue JeansAlvin Reyes
 
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITY
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITYSIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITY
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITYZAKIR
 
No Such Thing As Social Products
No Such Thing As Social ProductsNo Such Thing As Social Products
No Such Thing As Social ProductsJon Gatrell
 
Per5_HistoryandFlow_Hamilton10/11/07
Per5_HistoryandFlow_Hamilton10/11/07Per5_HistoryandFlow_Hamilton10/11/07
Per5_HistoryandFlow_Hamilton10/11/07guest6a29c7
 
人生百味
人生百味人生百味
人生百味nonnon
 

En vedette (17)

2009 Meet The Principal
2009 Meet The Principal2009 Meet The Principal
2009 Meet The Principal
 
Aurora Borealis
Aurora BorealisAurora Borealis
Aurora Borealis
 
Are Surveys Useful?
Are Surveys Useful?Are Surveys Useful?
Are Surveys Useful?
 
Úvod do optimalizace pro vyhledávače
Úvod do optimalizace pro vyhledávačeÚvod do optimalizace pro vyhledávače
Úvod do optimalizace pro vyhledávače
 
Bildspel om hembygdsforskning
Bildspel om hembygdsforskningBildspel om hembygdsforskning
Bildspel om hembygdsforskning
 
Pure Visibility Ppc Judo
Pure Visibility Ppc JudoPure Visibility Ppc Judo
Pure Visibility Ppc Judo
 
First Innovi Corp Brands Presentation
First Innovi Corp Brands PresentationFirst Innovi Corp Brands Presentation
First Innovi Corp Brands Presentation
 
Web2 KM
Web2 KMWeb2 KM
Web2 KM
 
Uka S Art No Music Ii
Uka S Art No Music IiUka S Art No Music Ii
Uka S Art No Music Ii
 
Klimenko
KlimenkoKlimenko
Klimenko
 
Rainbows
RainbowsRainbows
Rainbows
 
Aapt 2010
Aapt 2010Aapt 2010
Aapt 2010
 
Religion in Blue Jeans
Religion in Blue JeansReligion in Blue Jeans
Religion in Blue Jeans
 
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITY
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITYSIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITY
SIMILARITIES_BETWEEN_ISLAM_AND_CHRISTIANITY
 
No Such Thing As Social Products
No Such Thing As Social ProductsNo Such Thing As Social Products
No Such Thing As Social Products
 
Per5_HistoryandFlow_Hamilton10/11/07
Per5_HistoryandFlow_Hamilton10/11/07Per5_HistoryandFlow_Hamilton10/11/07
Per5_HistoryandFlow_Hamilton10/11/07
 
人生百味
人生百味人生百味
人生百味
 

Similaire à Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy

Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...
Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...
Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...kaftanenko
 
Atom Publishing Protocol
Atom Publishing ProtocolAtom Publishing Protocol
Atom Publishing ProtocolRichard Metzler
 
Xhtml Coding (nicht nur für Bibliotheken)
Xhtml Coding (nicht nur für Bibliotheken)Xhtml Coding (nicht nur für Bibliotheken)
Xhtml Coding (nicht nur für Bibliotheken)Luka Peters
 
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g - DOAG SI...
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g   - DOAG SI...Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g   - DOAG SI...
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g - DOAG SI...OPITZ CONSULTING Deutschland
 
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins Christian Kauhaus
 
Guided Navigation - Beispiele von Schweizer Websites
Guided Navigation - Beispiele von Schweizer WebsitesGuided Navigation - Beispiele von Schweizer Websites
Guided Navigation - Beispiele von Schweizer WebsitesWalter Schärer
 
Einführung in die webOS Programmierung
Einführung in die webOS ProgrammierungEinführung in die webOS Programmierung
Einführung in die webOS ProgrammierungMarkus Leutwyler
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Sven Haiges
 
Parallele Softwareentwicklung mit .NET 4.0
Parallele Softwareentwicklung mit .NET 4.0Parallele Softwareentwicklung mit .NET 4.0
Parallele Softwareentwicklung mit .NET 4.0Qiong Wu
 
Von Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtVon Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtAndreas Schiweck
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeFrank Müller
 
Einführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungEinführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungDigicomp Academy AG
 
JdbcTemplate aus Spring
JdbcTemplate aus SpringJdbcTemplate aus Spring
JdbcTemplate aus Springtutego
 

Similaire à Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy (20)

ARIA
ARIAARIA
ARIA
 
Scala XML
Scala XMLScala XML
Scala XML
 
Wicket Kurzübersicht
Wicket KurzübersichtWicket Kurzübersicht
Wicket Kurzübersicht
 
Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...
Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...
Einführung in die Java-Webentwicklung - Part II - [3 of 3] - Java Server Face...
 
Atom Publishing Protocol
Atom Publishing ProtocolAtom Publishing Protocol
Atom Publishing Protocol
 
JBoss jBPM 4
JBoss jBPM 4JBoss jBPM 4
JBoss jBPM 4
 
Web Entwicklung mit PHP - Teil 1
Web Entwicklung mit PHP - Teil 1Web Entwicklung mit PHP - Teil 1
Web Entwicklung mit PHP - Teil 1
 
Xhtml Coding (nicht nur für Bibliotheken)
Xhtml Coding (nicht nur für Bibliotheken)Xhtml Coding (nicht nur für Bibliotheken)
Xhtml Coding (nicht nur für Bibliotheken)
 
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g - DOAG SI...
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g   - DOAG SI...Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g   - DOAG SI...
Integration und Betriebsüberwachung mit der Oracle SOA Suite 11g - DOAG SI...
 
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins
nagiosplugin - eine Python-Biblioth­ek für Monitoring-Plug­ins
 
jQuery & CouchDB - Die zukünftige Webentwicklung?
jQuery & CouchDB - Die zukünftige Webentwicklung?jQuery & CouchDB - Die zukünftige Webentwicklung?
jQuery & CouchDB - Die zukünftige Webentwicklung?
 
Guided Navigation - Beispiele von Schweizer Websites
Guided Navigation - Beispiele von Schweizer WebsitesGuided Navigation - Beispiele von Schweizer Websites
Guided Navigation - Beispiele von Schweizer Websites
 
Einführung in die webOS Programmierung
Einführung in die webOS ProgrammierungEinführung in die webOS Programmierung
Einführung in die webOS Programmierung
 
Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006Grails 0.3-SNAPSHOT Presentation WJAX 2006
Grails 0.3-SNAPSHOT Presentation WJAX 2006
 
Parallele Softwareentwicklung mit .NET 4.0
Parallele Softwareentwicklung mit .NET 4.0Parallele Softwareentwicklung mit .NET 4.0
Parallele Softwareentwicklung mit .NET 4.0
 
Von Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein MigrationsberichtVon Typo3 zu Plone - Ein Migrationsbericht
Von Typo3 zu Plone - Ein Migrationsbericht
 
Go - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare SystemeGo - Googles Sprache für skalierbare Systeme
Go - Googles Sprache für skalierbare Systeme
 
Einführung in die funktionale Programmierung
Einführung in die funktionale ProgrammierungEinführung in die funktionale Programmierung
Einführung in die funktionale Programmierung
 
JBoss jBPM 4 bei der JBUG München
JBoss jBPM 4 bei der JBUG MünchenJBoss jBPM 4 bei der JBUG München
JBoss jBPM 4 bei der JBUG München
 
JdbcTemplate aus Spring
JdbcTemplate aus SpringJdbcTemplate aus Spring
JdbcTemplate aus Spring
 

Plus de Thorsten Kamann

Scrum and distributed teams
Scrum and distributed teamsScrum and distributed teams
Scrum and distributed teamsThorsten Kamann
 
Effizente Entwicklung für verteilte Projekte
Effizente Entwicklung für verteilte ProjekteEffizente Entwicklung für verteilte Projekte
Effizente Entwicklung für verteilte ProjekteThorsten Kamann
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingThorsten Kamann
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An IntroductionThorsten Kamann
 
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenWebtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenThorsten Kamann
 
My Daily Spring - Best Practices with the Springframework
My Daily Spring - Best Practices with the SpringframeworkMy Daily Spring - Best Practices with the Springframework
My Daily Spring - Best Practices with the SpringframeworkThorsten Kamann
 
Vortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsVortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsThorsten Kamann
 
Let’s groove with Groovy
Let’s groove with GroovyLet’s groove with Groovy
Let’s groove with GroovyThorsten Kamann
 
Maven2 - Die nächste Generation des Buildmanagements?
Maven2 - Die nächste Generation des Buildmanagements?Maven2 - Die nächste Generation des Buildmanagements?
Maven2 - Die nächste Generation des Buildmanagements?Thorsten Kamann
 
Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy
Leichtgewichtige Architekturen mit Spring, JPA, Maven und GroovyLeichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy
Leichtgewichtige Architekturen mit Spring, JPA, Maven und GroovyThorsten Kamann
 

Plus de Thorsten Kamann (14)

Scrum on rails
Scrum on railsScrum on rails
Scrum on rails
 
Scrum and distributed teams
Scrum and distributed teamsScrum and distributed teams
Scrum and distributed teams
 
Effizente Entwicklung für verteilte Projekte
Effizente Entwicklung für verteilte ProjekteEffizente Entwicklung für verteilte Projekte
Effizente Entwicklung für verteilte Projekte
 
Spring 3 - Der dritte Frühling
Spring 3 - Der dritte FrühlingSpring 3 - Der dritte Frühling
Spring 3 - Der dritte Frühling
 
Spring 3 - An Introduction
Spring 3 - An IntroductionSpring 3 - An Introduction
Spring 3 - An Introduction
 
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and MavenWebtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
Webtests Reloaded - Webtest with Selenium, TestNG, Groovy and Maven
 
My Daily Spring - Best Practices with the Springframework
My Daily Spring - Best Practices with the SpringframeworkMy Daily Spring - Best Practices with the Springframework
My Daily Spring - Best Practices with the Springframework
 
Vortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development EnvironmentsVortragsreihe Dortmund: Unified Development Environments
Vortragsreihe Dortmund: Unified Development Environments
 
Let’s groove with Groovy
Let’s groove with GroovyLet’s groove with Groovy
Let’s groove with Groovy
 
Groovy - Rocks or Not?
Groovy - Rocks or Not?Groovy - Rocks or Not?
Groovy - Rocks or Not?
 
Maven2 - Die nächste Generation des Buildmanagements?
Maven2 - Die nächste Generation des Buildmanagements?Maven2 - Die nächste Generation des Buildmanagements?
Maven2 - Die nächste Generation des Buildmanagements?
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Spring 2.0
Spring 2.0Spring 2.0
Spring 2.0
 
Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy
Leichtgewichtige Architekturen mit Spring, JPA, Maven und GroovyLeichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy
Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy
 

Leichtgewichtige Architekturen mit Spring, JPA, Maven und Groovy

  • 1.  
  • 3. Was ist „gute“ Software?
  • 4. … und was man dafür braucht
  • 6.  
  • 12.  
  • 17.  
  • 25.  
  • 27. Exkurs: Maven - Repositories
  • 30. Exkurs: Maven - Abhängigkeiten <project> <modelVersion>4.0.0</modelVersion> <groupId>spring2.jpa.basic</groupId> <artifactId>spring2-jpa-basic-impl</artifactId> <version>1.0.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>org.springframework</groupId> <artifactId>spring</artifactId> <version>2.5.1</version> </dependency> […] </dependencies> […] </project> Artefakt-Beschreibung SNAPSHOT! Abhängigkeit liefert alle benötigten Bibliotheken
  • 31. Exkurs: Maven-PlugIns <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.4-SNAPSHOT</version> <configuration> <suiteXmlFiles> <suiteXmlFile>quick-suite.xml</suiteXmlFile> </suiteXmlFiles> </configuration> </plugin> </plugins> </build> PlugIn für Testausführung Lädt Testsuite
  • 32.  
  • 33. Exkurs: Spring [Was ist Spring?] Inversion of Control Ansammlung von API's Programmier- modell
  • 34. Exkurs: Spring [Komponenten] Spring Core AOP Spring AOP AspectJ-Integration DAO Spring JDBC Transaction- Management ORM JPA Hibernate Toplink JDO JEE JMX JMS JCA Remoting EJB's Email WEB Spring MVC Struts WebWork Tapestry JSF PDF Portlets
  • 40.  
  • 44.  
  • 47. Exkurs: Groovy The Groovy Truth Runtime type Evaluation criterion required for truth Boolean Booleanwert muss true sein Matcher Der reguläre Ausdruck muss mindestens 1 Treffer haben Collection Die Collection darf nicht leer sein Map Die Map darf nicht leer sein String Der String darf ebenfalls nicht leer sein Number Muss ungleich 0 sein Alles andere Die Objektreferenz muss ungleich null sein
  • 48. Exkurs: Groovy – Listen und Ranges def list = [„item1“, „item2“, „item3“] assert list.size() def emptyList = [] assert !emptyList list << „item4“ assert list.size() == 4 def range = [1..4] assert range.size() == 4 def range1 = [1..<4] assert range1.size() == 3 Eine Liste mit 3 Einträgen Eine leere Liste Der ersten Liste wird ein Element hinzugefügt Eine Range mit den Werten 1, 2, 3, 4 wird erstellt Eine Range mit den Werten 1, 2, 3 wird erstellt
  • 49. Exkurs: Groovy – Listen und Closures def list = [„item1“, „item2“, „item3“] list.each{ print it+“ „} > item1 item2 item3 assert list.find{it==„item2“} list = [„a1“, „a2“, „a3“, „i1“, „i2“] assert list.findAll{ it.startsWith(„i“)}.size() == 3 Each-Closure Ein bestimmtes Element finden Eine Anzahl an Elementen aus der Liste finden
  • 50. Exkurs: Groovy - Maps def map = [key1: „value1“, key2: „value2“] assert map.size() == 2 assert map.key1 == „value1“ map.key3 == „value3“ assert map.size() == 3 assert map[„key2“] == „value2“ assert map.get(„key2“) == „value2“ def emptyMap = [:] assert !emptyMap Eine Map mit 2 Einträgen wird erstellt Ein 3. Eintrag wird hinzugefügt Alternative Zugriffsmethode auf die Elemente der Map Eine leere Map wird erstellt
  • 51.  
  • 52.  
  • 53. Beispiel: API - Domänenmodell
  • 55.  
  • 56. Zum Beispiel: Impl - Entities @Entity(table=„CUSTOMERS“) public class Customer{ @Id @GeneratedValue( strategy = GenerationType.AUTO) private Long id; @OneToOne(targetEntity = Address.class, cascade = { CascadeType.ALL}) private IAddress address; @Column(length = 40) private String firstName; … } Entity auf Tabelle CUSTOMERS mappen Primary Key 1-zu-1 Beziehung Konfiguration einer Column in der Tabelle CUSTOMERS
  • 57. Zum Beispiel: Impl – persistence.xml <persistence …> <persistence-unit name=&quot;spring2-jpa-basic-persistence-unit&quot;> <properties> <property name=&quot;hibernate.jdbc.batch_size&quot; value=&quot;0&quot;/> <property name=&quot;hibernate.default_batch_fetch_size&quot; value=&quot;5&quot;/> […] </properties> </persistence-unit> </persistence> Eindeutiger Name der Persistence-Unit Eigenschaften der Persistence-Unit
  • 58. Zum Beispiel: Impl – DAO‘s @Repository public class CustomerDao implements ICustomerDao { @PersistenceContext( unitName = &quot;spring2-jpa-basic-persistence-unit&quot;) protected EntityManager entityManager; public List<ICustomer> findAll() { return entityManager .createQuery(&quot;from Customer c&quot;) .getResultList(); } […] } Sorgt für die Übersetzung von Exceptions Injection des Entity-Managers über Spring Plain Java
  • 59. Zum Beispiel: Impl – Spring-Config <bean class=„PersistenceAnnotationBeanPostProcessor&quot; /> <bean class=„PersistenceExceptionTranslationPostProcessor&quot; /> Support der Annotations in den DAO‘s Excpetion Translation
  • 60. Zum Beispiel: Impl – Spring-Config <bean id=&quot;entityManagerFactory&quot; class=„LocalContainerEntityManagerFactoryBean&quot;> <property name=&quot;dataSource&quot; ref=&quot;dataSource&quot; /> <property name=&quot;jpaVendorAdapter&quot;> <bean class=„HibernateJpaVendorAdapter&quot;> <property name=&quot;databasePlatform&quot; value=&quot;${jpa.provider.databasePlatform}&quot; /> <property name=&quot;showSql&quot; value=&quot;${jpa.provider.showSql}&quot; /> <property name=&quot;generateDdl&quot; value=&quot;${jpa.provider.generateDdl}&quot; /> </bean> </property> </bean> JPA-Vendor Eigenschaften des JPA-Vendors Kein JNDI
  • 61. Zum Beispiel: Impl – Spring-Config <bean id=&quot;dataSource&quot; class=„DriverManagerDataSource&quot; p:driverClassName=&quot;${jdbc.driver.classname}&quot; p:url=&quot;${jdbc.connection.url}&quot; p:username=&quot;${jdbc.connection.uid}&quot; p:password=&quot;${jdbc.connection.pwd}&quot; /> DataSource Konfiguration
  • 62.
  • 63. Zum Beispiel: Impl – Spring-Config <bean id=&quot;transactionManager&quot; class=„JpaTransactionManager&quot;> <property name=&quot;entityManagerFactory&quot; ref=&quot;entityManagerFactory&quot; /> </bean> <tx:annotation-driven transaction-manager=&quot;transactionManager&quot; /> JPA Transaction-Manager Transaktionen werden per Annotations konfiguriert
  • 64. Zum Beispiel: Impl – Spring-Config <tx:advice id=&quot;txAdvice&quot; transaction-manager=&quot;transactionManager&quot;> <tx:attributes> <tx:method name=&quot;get*&quot; read-only=&quot;true&quot; /> <tx:method name=&quot;*&quot; /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut id=“dataaccess&quot; expression=&quot;execution(* […].dataaccess.*.*(..))&quot; /> <aop:advisor advice-ref=&quot;txAdvice&quot; pointcut-ref=“dataaccess&quot; /> </aop:config> Alternative Transaktionskonfiguration
  • 65. Zum Beispiel: Problem Annotation @Service public class CustomerService{ @Autowired private ICustomerDao customerDao; } Spring-eigene Annotations @Target(value = ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @Service public @interface MyService { } Eigene Annotation Basierend auf @Service @MyService public class CustomerService{ } Verwendung der eigenen Annotation
  • 66. Zum Beispiel: Impl – Unit Testing
  • 67. Zum Beispiel: Impl – Unit Testing
  • 68. Zum Beispiel: Impl – Unit Testing public final void testChangeAddress() { IAddress expAddress = new Address( street: &quot;s1&quot;, city: &quot;c1&quot;, country: &quot;c1&quot;, zipCode: &quot;z1&quot;); def addressDao = [ store:{entity -> expAddress}] as IAddressDao ICustomerService customerService = new CustomerService(addressDao: addressDao) def result = customerService .changeAddress(expAddress) assert expAddress == result } Erzeugung einer neuen Instanz mit Constructor- Enhancement Implementierung des IAddressDao Neue Instanz des ICustomerService Ausführen und Ergebnis vergleichen
  • 69.  
  • 71.  
  • 79.
  • 80. Zum Beispiel: Integration (Testsuite) <suite name=&quot;gidp-sample-integration&quot;> <test verbose=&quot;2&quot; name=&quot;FFIntegrationtests&quot; annotations=&quot;JDK&quot;> <parameter name=&quot;browser&quot; value=&quot;firefox&quot;/> <packages> <package name=“[…].integration&quot;/> </packages> </test> <test verbose=&quot;2&quot; name=&quot;IEIntegrationtests&quot; annotations=&quot;JDK&quot;> <parameter name=&quot;browser&quot; value=&quot;iexplore&quot;/> <packages> <package name=&quot;de.gidp.sample.integration&quot;/> </packages> </test> </suite>
  • 81.  
  • 82. Fazit
  • 83. Fazit
  • 84.