• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Whoops! Where did my architecture go?
 

Whoops! Where did my architecture go?

on

  • 5,492 views

Slides of the talk at Spring I/O 2012

Slides of the talk at Spring I/O 2012

Statistics

Views

Total Views
5,492
Views on SlideShare
4,456
Embed Views
1,036

Actions

Likes
11
Downloads
47
Comments
0

19 Embeds 1,036

http://www.martinahrer.at 370
http://coridio.blogspot.com.es 216
http://coridio.blogspot.com 198
http://www.jmiguel.eu 145
https://twitter.com 51
http://coridio.blogspot.mx 19
http://7750988227162852637_918681e8b4e5d809479869c975077ff9f98da2f9.blogspot.com 9
http://feeds.feedburner.com 8
http://coridio.blogspot.com.ar 6
http://coridio.blogspot.com.br 3
http://localhost 3
http://coridio.blogspot.ch 1
http://www.coridio.blogspot.com.ar 1
http://coridio.blogspot.de 1
http://coridio.blogspot.fr 1
http://translate.googleusercontent.com 1
http://blog.eisele.net 1
http://a0.twimg.com 1
http://www.directrss.co.il 1
More...

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

    Whoops! Where did my architecture go? Whoops! Where did my architecture go? Presentation Transcript

    • Whoops! Where did my architecture go?Approaches to architecture management for Java and Spring applications Oliver Gierke
    • Oliver GierkeSpringSource EngineerSpring Dataogierke@vmware.comolivergierkewww.olivergierke.de
    • Background 5 years of consulting Lots of code reviewsEoin Woods‘ talk on InfoQ
    • Roadmap Architecture 101A plain Java based approach Hera
    • The 3 C ofArchitecture Constraints Complexity Change © Uwe Friedrichsen
    • The 2 Cs ofArchitecture Complexity Change
    • Architecture 101
    • Know yourdependencies
    • Granularity Modules Layers Vertical slices Subsystems
    • Granularity Java ARchive Package Class
    • Of layersand slices…
    • Slice A Slice B Slice CLayer 1Layer 2Layer 3
    • Layers Well understood Known to developersLess important to business
    • SlicesHardly understoodNew to developersKey for business req
    • Slice A Slice B Slice CLayer 1Layer 2Layer 3
    • " How to implement an architecture inside a codebase?
    • Architecture VS. Codebase
    • " How to implement an architecture inside a codebase?
    • " How to enforce an architecture inside a codebase?
    • Code analysis JDepend Sonar
    • Demo
    • SonargraphFormerly known as SonarJ
    • Demo
    • A plain Javabased approach
    • " How far can we get with plain Java means only?
    • Slice A Slice B Slice CLayer 1Layer 2Layer 3
    • Packages
    • ….${layer}.${slice} VS.….${slice}.${layer}
    • …domain.core …service.core…repository.core
    • …core.domain …core.service…core.repository
    • Layers first Leaks slice internalsLower layers visible to everyone
    • " Start with less packages and the least visibility possible…
    • Slice A Slice B Slice CLayer 1Layer 2Layer 3
    • Slice A Slice B Slice CLayer 1Layer 2Layer 3
    • Slices first Start with package per sliceExpose interfaces and domain types Keep implementations private
    • Slices firstEncapsulates business moduleInternals understood anyway
    • Subsystems
    • Background Risk mgmt. at German public bankQuite a few other SpringSource clients
    • Systemsgrow big!
    • Rememberthe 2 Cs?
    • Complexity & Change
    • " How to localize change?
    • " Separate frequent from infrequent change!
    • Granularity Class Package Java ARchive
    • HostSPI SPI SPI Plugin Plugin
    • Context No OSGi Spring based Build-time compositionDon‘t touch the host system
    • AppPlugin Plugin Host
    • " How to make the host aware of the plugins?
    • " How to dynamically collect Spring beans of a given type?
    • classpath*:META-INF/spring/plugin-context.xml
    • HostSPI SPI SPI Plugin Plugin
    • classpath*:META-INF/ spring/plugin-context.xmlSPI SPI SPI META-INF/ META-INF/spring/plugin- spring/plugin- context.xml context.xml
    • @Componentpublic class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } …}public interface MyPlugin { void doSomething();}
    • Demo
    • XML?Back in the days
    • (XML?) Back in the daysProbably not a big deal anymore
    • Easy access?
    • @Componentpublic class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } …}public interface MyPlugin { void doSomething();}
    • @Componentpublic class MyComponentImpl implements TransferService { // Constructor omitted public Result myMethod(SomeParameter parameter) { // Select the first one to match to invoke? // Select multiple ones to invoke? // Select and fallback to one if none found? // Select and throw an exception if none found? }}
    • Hera
    • " The smallest plugin system ever!
    • Plugins Selection criterion Callback methodLet the implementation decide
    • Registry Equipped with pluginsCommon access patterns
    • public interface Plugin<T> { public boolean supports(T delimiter );}public interface PluginRegistry<S extends Plugin<T>, T> { T getPluginFor(S delimiter); T getPluginFor(S delimiter, T default); <E extends Exception> T getPluginFor(S del, E e) throws E; List<T> getPluginsFor(S delimiter); …}
    • @Componentpublic class MyComponentImpl implements TransferService { private PluginRegistry<MyPlugin, String> plugins; @Autowired public MyComponentImpl( PluginRegistry<MyPlugin, String> plugins) { this.plugins = plugins; }}public interface MyPlugin extends Plugin<String> { void doSomething();}
    • @Componentpublic class MyComponentImpl implements TransferService { private final MyPlugin defaultPlugin = new MyDefaultPlugin(); public Result myMethod(String parameter) { // Select the first one to match to invoke? … = plugins.getPluginFor(parameter); // Select multiple ones to invoke? … = plugins.getPluginsFor(parameter); // Select and fallback to one if none found? … = plugins.getPluginFor(parameter, defaultPlugin); // Select and throw an exception if none found? … = plugins.getPluginsFor(parameter, new RuntimeException()); }}
    • OrderAwarePluginRegistryRespects @Order/Ordered OAPR.reverse()
    • Bells‘n‘whistles FactoryBean Spring namespace Lazy-eval
    • Herahttp://hera.synyx.org Apache 2.0Soon to be on GitHub
    • Spring Integration2
    • <bean class="….FirstSamplePlugin" /><bean class="….SecondSamplePlugin" /><int:channel id="input" /><int:channel id="output" /><int-hera:dynamic-service-activator input-channel="input" outputChannel="output" plugin-type= "….MyPlugin" method= "myBusinessMethod" delimiter="payload" invocation-arguments= "payload" />
    • Demo
    • Take-aways Know your dependencies On every granularity Start as strict as possibleGet lenient where necessary
    • Thanks & credits Eoin Woods - Talk @ InfoQUwe Friedrichsen - Slides @ Slideshare
    • ResourcesSpring Data JPA @ GitHub Sonargraph Hera