SlideShare une entreprise Scribd logo
1  sur  81
Télécharger pour lire hors ligne
Whoops!
      Where did my
     architecture go?
Approaches to architecture management for
      Java and Spring applications



                 Oliver Gierke
Oliver Gierke
SpringSource Engineer
Spring Data

ogierke@vmware.com
olivergierke
www.olivergierke.de
Background
  5 years of consulting
  Lots of code reviews
Eoin Woods‘ talk on InfoQ
Roadmap
   Architecture 101
A Java packages model
        Hera
Architecture 101
Know your
dependencies
Granularity
    Modules
     Layers
  Vertical slices
  Subsystems
Granularity
  Java ARchive
    Package
     Class
Of layers
and slices…
Layer 1


Layer 2


Layer 3
Layer 1


Layer 2


Layer 3
Layer 1


Layer 2


Layer 3
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
Layers
     Well understood
  Known to developers
Less important to business
Slices
Hardly understood
New to developers
Key for business req
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
"   How to implement
    an architecture
    inside a codebase?
Architecture
    VS.
 Codebase
"   How to implement
    an architecture
    inside a codebase?
"   How to implement
    an architecture
    inside a codebase?
"   How to enforce
    an architecture
    inside a codebase?
Code analysis
    JDepend
     Sonar
Demo
Sonargraph
Formerly known as SonarJ
Demo
A plain Java
based approach
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
….${layer}.${slice}
        VS.
….${slice}.${layer}
Layers first
      Leaks slice internals
Lower layers visible to everyone
"   Start with less
    packages and the
    least visibility
    possible…
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
Slice A   Slice B   Slice C


Layer 1


Layer 2


Layer 3
Slices first
   Start with package per slice
Expose interfaces and domain types
  Keep implementations private
Slices first
Encapsulates business module
Internals understood anyway
Subsystems
Background
 Risk mgmt. at German public bank
Quite a few other SpringSource clients
Host
Host

SPI   SPI    SPI
Host

SPI       SPI        SPI



 Plugin          Plugin
Host

SPI       SPI        SPI



 Plugin          Plugin
Host

SPI       SPI        SPI



 Plugin          Plugin
Context
         No OSGi
       Spring based
  Build-time composition
Don‘t touch the host system
Host
Plugin          Plugin


         Host
App

Plugin          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
Host
Host

SPI   SPI    SPI
Host

SPI       SPI        SPI



 Plugin          Plugin
Host

SPI       SPI        SPI



 Plugin          Plugin
Host

SPI       SPI        SPI



 Plugin          Plugin
classpath*:META-INF/
    spring/plugin-context.xml

SPI              SPI            SPI


 META-INF/              META-INF/
spring/plugin-         spring/plugin-
 context.xml            context.xml
@Component
public 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 days
Probably not a big deal anymore
Easy access?
@Component
public class MyComponentImpl implements TransferService {

    private List<MyPlugin> plugins;

    @Autowired
    public MyComponentImpl(List<MyPlugin> plugins) {
      this.plugins = plugins;
    }
    …
}

public interface MyPlugin {
  void doSomething();
}
@Component
public 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 method
Let the implementation decide
Registry
 Equipped with plugins
Common 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);
    …
}
@Component
public 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();
}
@Component
public 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());
  }
}
OrderAware
PluginRegistry
Respects @Order/Ordered
    OAPR.reverse()
Bells‘n‘whistles
     FactoryBean
   Spring namespace
      Lazy-eval
Hera
http://hera.synyx.org
    Apache 2.0
Soon 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 possible
Get lenient where necessary
Thanks & credits
  Eoin Woods - Talk @ InfoQ
Resources
Spring Data JPA @ GitHub
      Sonargraph
         Hera

Contenu connexe

Tendances

Tomcat New Evolution
Tomcat New EvolutionTomcat New Evolution
Tomcat New Evolution
Allan Huang
 
Improving Robustness In Distributed Systems
Improving Robustness In Distributed SystemsImproving Robustness In Distributed Systems
Improving Robustness In Distributed Systems
l xf
 

Tendances (20)

ASP.Net 5 and C# 6
ASP.Net 5 and C# 6ASP.Net 5 and C# 6
ASP.Net 5 and C# 6
 
Lambda Expressions in Java 8
Lambda Expressions in Java 8Lambda Expressions in Java 8
Lambda Expressions in Java 8
 
Building a chatbot – step by step
Building a chatbot – step by stepBuilding a chatbot – step by step
Building a chatbot – step by step
 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
 
Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams Productive Programming in Java 8 - with Lambdas and Streams
Productive Programming in Java 8 - with Lambdas and Streams
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
Parallel and Async Programming With C#
Parallel and Async Programming With C#Parallel and Async Programming With C#
Parallel and Async Programming With C#
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
How Symfony Changed My Life
How Symfony Changed My LifeHow Symfony Changed My Life
How Symfony Changed My Life
 
Software Defined Networking: The OpenDaylight Project
Software Defined Networking: The OpenDaylight ProjectSoftware Defined Networking: The OpenDaylight Project
Software Defined Networking: The OpenDaylight Project
 
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)Java 8 Streams And Common Operations By Harmeet Singh(Taara)
Java 8 Streams And Common Operations By Harmeet Singh(Taara)
 
Tomcat New Evolution
Tomcat New EvolutionTomcat New Evolution
Tomcat New Evolution
 
Java8
Java8Java8
Java8
 
Reactive Micro Services with Java seminar
Reactive Micro Services with Java seminarReactive Micro Services with Java seminar
Reactive Micro Services with Java seminar
 
Java 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & StreamsJava 8 Lambda Expressions & Streams
Java 8 Lambda Expressions & Streams
 
Java RMI
Java RMIJava RMI
Java RMI
 
The Eclipse Transformer Project
The Eclipse Transformer Project The Eclipse Transformer Project
The Eclipse Transformer Project
 
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard WolffArchitecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
Architecture | The Future of Messaging: RabbitMQ and AMQP | Eberhard Wolff
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Improving Robustness In Distributed Systems
Improving Robustness In Distributed SystemsImproving Robustness In Distributed Systems
Improving Robustness In Distributed Systems
 

En vedette

Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
Oliver Gierke
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10
Stephan Hochdörfer
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!
Oliver Gierke
 

En vedette (19)

Coding & Music Passion And Profession
Coding & Music   Passion And ProfessionCoding & Music   Passion And Profession
Coding & Music Passion And Profession
 
Generic DAOs With Hades
Generic DAOs With HadesGeneric DAOs With Hades
Generic DAOs With Hades
 
Sophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & HadesSophisticated JPA with Spring & Hades
Sophisticated JPA with Spring & Hades
 
REST based web applications with Spring 3
REST based web applications with Spring 3REST based web applications with Spring 3
REST based web applications with Spring 3
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
Mylyn - Increasing developer productivity
Mylyn - Increasing developer productivityMylyn - Increasing developer productivity
Mylyn - Increasing developer productivity
 
Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)Increasing developer procutivity with Mylyn (Devoxx 2010)
Increasing developer procutivity with Mylyn (Devoxx 2010)
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 
Spring Data and MongoDB
Spring Data and MongoDBSpring Data and MongoDB
Spring Data and MongoDB
 
Spring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep DiveSpring Roo 1.0.0 Technical Deep Dive
Spring Roo 1.0.0 Technical Deep Dive
 
Spring in action - Hades & Spring Roo
Spring in action - Hades & Spring RooSpring in action - Hades & Spring Roo
Spring in action - Hades & Spring Roo
 
Mylyn
MylynMylyn
Mylyn
 
Real world dependency injection - DPC10
Real world dependency injection - DPC10Real world dependency injection - DPC10
Real world dependency injection - DPC10
 
Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!Data Access 2.0? Please welcome, Spring Data!
Data Access 2.0? Please welcome, Spring Data!
 
An introduction into Spring Data
An introduction into Spring DataAn introduction into Spring Data
An introduction into Spring Data
 
Spring integration
Spring integrationSpring integration
Spring integration
 
Spring Data JPA - Repositories done right
Spring Data JPA - Repositories done rightSpring Data JPA - Repositories done right
Spring Data JPA - Repositories done right
 
Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!Data access 2.0? Please welcome: Spring Data!
Data access 2.0? Please welcome: Spring Data!
 
Whoops! Where did my architecture go?
Whoops! Where did my architecture go?Whoops! Where did my architecture go?
Whoops! Where did my architecture go?
 

Similaire à Whoops! where did my architecture go?

Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart Frog
Steve Loughran
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
Greg.Helton
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
Tsai Tsung-Yi
 

Similaire à Whoops! where did my architecture go? (20)

SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Taming Deployment With Smart Frog
Taming Deployment With Smart FrogTaming Deployment With Smart Frog
Taming Deployment With Smart Frog
 
JavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In DepthJavaOne 2009 BOF-5189 Griffon In Depth
JavaOne 2009 BOF-5189 Griffon In Depth
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
JDD2015: ClassIndex - szybka alternatywa dla skanowania klas - Sławek Piotrowski
JDD2015: ClassIndex - szybka alternatywa dla skanowania klas - Sławek PiotrowskiJDD2015: ClassIndex - szybka alternatywa dla skanowania klas - Sławek Piotrowski
JDD2015: ClassIndex - szybka alternatywa dla skanowania klas - Sławek Piotrowski
 
A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworks
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
Design Pattern Mastery - Momentum Dev Con 19 Apr 2018
 
Scala at Netflix
Scala at NetflixScala at Netflix
Scala at Netflix
 
Declaring Server App Components in Pure Java
Declaring Server App Components in Pure JavaDeclaring Server App Components in Pure Java
Declaring Server App Components in Pure Java
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Spring boot
Spring bootSpring boot
Spring boot
 
Griffon Presentation
Griffon PresentationGriffon Presentation
Griffon Presentation
 
Unit Testing RPG with JUnit
Unit Testing RPG with JUnitUnit Testing RPG with JUnit
Unit Testing RPG with JUnit
 
Open Source XMPP for Cloud Services
Open Source XMPP for Cloud ServicesOpen Source XMPP for Cloud Services
Open Source XMPP for Cloud Services
 
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API EconomyRewriting a Plugin Architecture 3 Times to Harness the API Economy
Rewriting a Plugin Architecture 3 Times to Harness the API Economy
 
Rifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobotRifartek Robot Training Course - How to use ClientRobot
Rifartek Robot Training Course - How to use ClientRobot
 

Dernier

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Dernier (20)

The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 

Whoops! where did my architecture go?