Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Plugging the users in - extend your application with pluggable Groovy DSL

Plugging the users in - extend your application with pluggable Groovy DSL

t is often beneficial to allow users extend your software with their own logic. With the rise of dynamic languages on the JVM it is also much more easier to do than ever before. In this session we will share our experience in creating Groovy authored user plugins interface.

After a brief introduction to domain specific languages (DSLs), their relevance to user plugins and how they can be easily implemented in Groovy, we’ll look at more user-friendly, but developer-challenging type of DSLs, which support plugins written both in Groovy or Java.

Good public API design is another very important aspect - while the APIs have to be broad enough to allow interesting functionality, internals should stay close to allow changes and further development. Exposing APIs to the world come with great responsibility - once ublished they can’t be changed without a price, so it is important keep backwards compatibility in mind.

Another very important aspect is security - you let strangers into your chambers, and you better be ready. Leveraging security mechanisms is essential to establish proper sandboxing and protect your application from malicious or faulty plugins.

Finally, we will cover another very important and nontrivial aspect of user plugins exposure - the classpath isolation when your plugins require dependencies. We will compare different solutions like establishing classpath hierarchies, OSGi, JBoss modules and the long-awaited Project Jigsaw.

Baruch Sadogursky

September 12, 2013
Tweet

More Decks by Baruch Sadogursky

Other Decks in Technology

Transcript

  1. © 2013 SpringOne 2GX. All rights reserved. Do not distribute without permission.
    Plugging the users in
    extend your application with pluggable Groovy DSL

    View Slide

  2. View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. View Slide

  7. View Slide

  8. View Slide

  9. View Slide

  10. View Slide

  11. View Slide

  12. View Slide

  13. View Slide

  14. View Slide

  15. – scheduled tasks

    View Slide

  16. – scheduled tasks
    – Custom security realms

    View Slide

  17. – scheduled tasks
    – Custom security realms
    – Change resolution rules

    View Slide

  18. – scheduled tasks
    – Custom security realms
    – Change resolution rules
    – Manipulate downloaded
    content

    View Slide

  19. – scheduled tasks
    – Custom security realms
    – Change resolution rules
    – Manipulate downloaded
    content
    – Listeners on storage
    events

    View Slide

  20. – Custom security realms
    – Change resolution rules
    – Manipulate downloaded
    content
    – Listeners on storage
    events
    – searches

    View Slide

  21. – Change resolution rules
    – Manipulate downloaded
    content
    – Listeners on storage
    events
    – searches
    – New rest commands

    View Slide

  22. – Manipulate downloaded
    content
    – Listeners on storage
    events
    – searches
    – New rest commands
    – Custom promotions

    View Slide

  23. – Listeners on storage
    events
    – searches
    – New rest commands
    – Custom promotions
    – Deploy and query
    artifacts and metadata

    View Slide

  24. – Etc.

    View Slide

  25. View Slide

  26. Requirements
    ___________

    View Slide

  27. Requirements
    –Familiar to Java users
    ___________

    View Slide

  28. Requirements
    –Familiar to Java users
    –Simple DSL
    ___________

    View Slide

  29. Requirements
    –Familiar to Java users
    –Simple DSL
    –Simple deployment:
    ___________

    View Slide

  30. Requirements
    –Familiar to Java users
    –Simple DSL
    –Simple deployment:
    –No packaging
    ___________

    View Slide

  31. Requirements
    –Familiar to Java users
    –Simple DSL
    –Simple deployment:
    –No packaging
    –No restart
    ___________

    View Slide

  32. View Slide

  33. View Slide

  34. Small helpers

    View Slide

  35. Small helpers Totally new language

    View Slide

  36. Small helpers Totally new language

    View Slide

  37. View Slide

  38. View Slide

  39. Small helpers Totally new language

    View Slide

  40. <3

    View Slide

  41. Parse groovy scripts
    Create closure objects
    Cast to SAM Find SAMs in classpath
    SAMs map
    Cast to Closure
    Execute

    View Slide

  42. Show me
    the code!

    View Slide

  43. View Slide

  44. Public API Design
    _____________

    View Slide

  45. Public API Design
    –Papi is contract
    _____________

    View Slide

  46. Public API Design
    –Papi is contract
    –Maintain backwards
    compatibility at all costs
    _____________

    View Slide

  47. Public API Design
    –Papi is contract
    –Maintain backwards
    compatibility at all costs
    – Breaking API might crash the
    server!
    _____________

    View Slide

  48. Public API Design
    –Papi is contract
    –Maintain backwards
    compatibility at all costs
    – Breaking API might crash the
    server!
    – Start small
    _____________

    View Slide

  49. Public API Design
    –Maintain backwards
    compatibility at all costs
    – Breaking API might crash the
    server!
    – Start small
    – Listen to users
    _____________

    View Slide

  50. Public API Design
    compatibility at all costs
    – Breaking API might crash the
    server!
    – Start small
    – Listen to users
    – Fluent API is your friend
    _____________

    View Slide

  51. Public API Design
    – Breaking API might crash the
    server!
    – Start small
    – Listen to users
    – Fluent API is your friend
    – Strong Java Types, compatibility
    _____________

    View Slide

  52. Show me
    the code!

    View Slide

  53. View Slide

  54. View Slide

  55. View Slide

  56. View Slide

  57. View Slide

  58. View Slide

  59. The conflict
    __________

    View Slide

  60. The conflict
    – Need to access Artifactory jars
    (PAPI)
    __________

    View Slide

  61. The conflict
    – Need to access Artifactory jars
    (PAPI)
    – Need to be isolated from
    Artifactory jars (3rd party)
    __________

    View Slide

  62. View Slide

  63. View Slide

  64. View Slide

  65. View Slide

  66. We’ll do it ourselves!
    ________________

    View Slide

  67. View Slide

  68. We’ll do it ourselves!
    1. Pull up what’s common
    ________________

    View Slide

  69. We’ll do it ourselves!
    1. Pull up what’s common
    2. isolate the rest
    ________________

    View Slide

  70. We’ll do it ourselves!
    1. Pull up what’s common
    2. isolate the rest
    ________________

    View Slide

  71. View Slide

  72. View Slide

  73. View Slide

  74. View Slide

  75. View Slide