Whoops! Where Did My Architecture Go?

Whoops! Where Did My Architecture Go?

Slides of my talk at 33degree conference, Warszaw in March 2013

977c74bb044a9d4fa90b305824eda390?s=128

Oliver Drotbohm

March 15, 2013
Tweet

Transcript

  1. 1.
  2. 13.
  3. 14.
  4. 30.
  5. 32.
  6. 36.
  7. 42.
  8. 54.
  9. 60.
  10. 66.
  11. 72.

    @Component public class MyComponentImpl implements TransferService { private List<MyPlugin> plugins;

    @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } … } public interface MyPlugin { void doSomething(); }
  12. 73.
  13. 77.

    @Component public class MyComponentImpl implements TransferService { private List<MyPlugin> plugins;

    @Autowired public MyComponentImpl(List<MyPlugin> plugins) { this.plugins = plugins; } … } public interface MyPlugin { void doSomething(); }
  14. 78.

    @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? } }
  15. 83.

    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); … }
  16. 84.

    @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(); }
  17. 85.

    @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()); } }
  18. 90.

    <bean class="….FirstSamplePlugin" /> <bean class="….SecondSamplePlugin" /> <int:channel id="input" /> <int:channel

    id="output" /> <int-plugin:dynamic-service-activator input-channel="input" outputChannel="output" plugin-type= "….MyPlugin" method= "myBusinessMethod" delimiter="payload" invocation-arguments= "payload" />
  19. 91.
  20. 93.

    Thanks & credits Eoin Woods - Talk @ InfoQ Uwe

    Friedrichsen - Slides @ Slideshare