Your SlideShare is downloading. ×
0
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Whoops! Where did my architecture go?

5,709

Published on

Slides of the talk at Spring I/O 2012

Slides of the talk at Spring I/O 2012

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

No Downloads
Views
Total Views
5,709
On Slideshare
0
From Embeds
0
Number of Embeds
11
Actions
Shares
0
Downloads
57
Comments
0
Likes
13
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Whoops! Where did my architecture go?Approaches to architecture management for Java and Spring applications Oliver Gierke
  • 2. Oliver GierkeSpringSource EngineerSpring Dataogierke@vmware.comolivergierkewww.olivergierke.de
  • 3. Background 5 years of consulting Lots of code reviewsEoin Woods‘ talk on InfoQ
  • 4. Roadmap Architecture 101A plain Java based approach Hera
  • 5. The 3 C ofArchitecture Constraints Complexity Change © Uwe Friedrichsen
  • 6. The 2 Cs ofArchitecture Complexity Change
  • 7. Architecture 101
  • 8. Know yourdependencies
  • 9. Granularity Modules Layers Vertical slices Subsystems
  • 10. Granularity Java ARchive Package Class
  • 11. Of layersand slices…
  • 12. Slice A Slice B Slice CLayer 1Layer 2Layer 3
  • 13. Layers Well understood Known to developersLess important to business
  • 14. SlicesHardly understoodNew to developersKey for business req
  • 15. Slice A Slice B Slice CLayer 1Layer 2Layer 3
  • 16. " How to implement an architecture inside a codebase?
  • 17. Architecture VS. Codebase
  • 18. " How to implement an architecture inside a codebase?
  • 19. " How to enforce an architecture inside a codebase?
  • 20. Code analysis JDepend Sonar
  • 21. Demo
  • 22. SonargraphFormerly known as SonarJ
  • 23. Demo
  • 24. A plain Javabased approach
  • 25. " How far can we get with plain Java means only?
  • 26. Slice A Slice B Slice CLayer 1Layer 2Layer 3
  • 27. Packages
  • 28. ….${layer}.${slice} VS.….${slice}.${layer}
  • 29. …domain.core …service.core…repository.core
  • 30. …core.domain …core.service…core.repository
  • 31. Layers first Leaks slice internalsLower layers visible to everyone
  • 32. " Start with less packages and the least visibility possible…
  • 33. Slice A Slice B Slice CLayer 1Layer 2Layer 3
  • 34. Slice A Slice B Slice CLayer 1Layer 2Layer 3
  • 35. Slices first Start with package per sliceExpose interfaces and domain types Keep implementations private
  • 36. Slices firstEncapsulates business moduleInternals understood anyway
  • 37. Subsystems
  • 38. Background Risk mgmt. at German public bankQuite a few other SpringSource clients
  • 39. Systemsgrow big!
  • 40. Rememberthe 2 Cs?
  • 41. Complexity & Change
  • 42. " How to localize change?
  • 43. " Separate frequent from infrequent change!
  • 44. Granularity Class Package Java ARchive
  • 45. HostSPI SPI SPI Plugin Plugin
  • 46. Context No OSGi Spring based Build-time compositionDon‘t touch the host system
  • 47. AppPlugin Plugin Host
  • 48. " How to make the host aware of the plugins?
  • 49. " How to dynamically collect Spring beans of a given type?
  • 50. classpath*:META-INF/spring/plugin-context.xml
  • 51. HostSPI SPI SPI Plugin Plugin
  • 52. classpath*:META-INF/ spring/plugin-context.xmlSPI SPI SPI META-INF/ META-INF/spring/plugin- spring/plugin- context.xml context.xml
  • 53. @Componentpublic class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } …}public interface MyPlugin { void doSomething();}
  • 54. Demo
  • 55. XML?Back in the days
  • 56. (XML?) Back in the daysProbably not a big deal anymore
  • 57. Easy access?
  • 58. @Componentpublic class MyComponentImpl implements TransferService { private List<MyPlugin> plugins; @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } …}public interface MyPlugin { void doSomething();}
  • 59. @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? }}
  • 60. Hera
  • 61. " The smallest plugin system ever!
  • 62. Plugins Selection criterion Callback methodLet the implementation decide
  • 63. Registry Equipped with pluginsCommon access patterns
  • 64. 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); …}
  • 65. @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();}
  • 66. @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()); }}
  • 67. OrderAwarePluginRegistryRespects @Order/Ordered OAPR.reverse()
  • 68. Bells‘n‘whistles FactoryBean Spring namespace Lazy-eval
  • 69. Herahttp://hera.synyx.org Apache 2.0Soon to be on GitHub
  • 70. Spring Integration2
  • 71. <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" />
  • 72. Demo
  • 73. Take-aways Know your dependencies On every granularity Start as strict as possibleGet lenient where necessary
  • 74. Thanks & credits Eoin Woods - Talk @ InfoQUwe Friedrichsen - Slides @ Slideshare
  • 75. ResourcesSpring Data JPA @ GitHub Sonargraph Hera

×