introduction to a groovy based dsl for apache ofbiz...ofbiz committer since before the project...
TRANSCRIPT
![Page 1: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/1.jpg)
Introduction to a Groovy based
DSL for Apache OFBiz™
Jacopo Cappellato
![Page 2: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/2.jpg)
“How to write better business logic code
with the new OFBiz DSL”
Presented by Jacopo Cappellato
OFBiz committer since before the project joined the ASF (2006) ASF member since 2007
OFBiz PMC Chair since 2010 VP Technology at HotWax Media www.hotwaxmedia.com
Email: [email protected] or [email protected]
![Page 3: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/3.jpg)
Outline
11/17/2014 3
• Introduction to the business logic in OFBiz
– Business logic contexts
– Languages currently adopted
• Introduction to the OFBiz DSL
• Language comparison by examples
• Summary and references
![Page 4: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/4.jpg)
Introduction to the business logic in OFBiz
![Page 5: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/5.jpg)
Business logic contexts in OFBiz and
languages currently adopted
11/17/2014 5
Contexts
Services
Events
Data Preparation
Scriptlets
![Page 6: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/6.jpg)
Business logic contexts in OFBiz and
languages currently adopted
11/17/2014 6
Contexts
Services
Events
Data Preparation
Scriptlets
Languages
Java
Groovy
Minilang
![Page 7: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/7.jpg)
From different languages for different
contexts…
11/17/2014 7
Minilang
• Services
• Events
Java
• Services
• Events
Groovy
• Data preparation
• Scriptlets
![Page 8: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/8.jpg)
… to one language for all the contexts.
11/17/2014 8
OFBiz DSL
• Services
• Events
• Data preparation
• Scriptlets
![Page 9: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/9.jpg)
Introduction to the OFBiz DSL
![Page 10: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/10.jpg)
Definitions
11/17/2014 10
• Domain Specific Language
– “A Domain Specific Language (DSL) is a
programming language designed specifically to
express solutions to problems in a specific
domain”
• OFBiz DSL
– A simple Groovy-based DSL for the
implementation of business logic in OFBiz
(events, services, data preparation scripts,
scriptlets)
![Page 11: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/11.jpg)
The OFBiz DSL as an evolution of the
existing languages used in OFBiz
OFBiz DSL
Minilang
Java
Groovy
11/17/2014 The OFBiz DSL brings together into one unified language all the
powerful features of Java, Groovy and Minilang 11
![Page 12: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/12.jpg)
How to use the OFBiz DSL
11/17/2014 12
• Full support available in the OFBiz trunk
• All Groovy code in OFBiz is already enabled to use the DSL
– Services • engine=“groovy”
– Events • type="groovy”
– Data preparation scripts • *.groovy
– Scriptlets • ${groovy:
![Page 13: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/13.jpg)
How to implement OFBiz DSL code
11/17/2014 13
• DSL methods currently available
– Service operations • runService
– Entity operations • findOne, findList, makeValue, select, from
– Results • success, failure, error
– Logging • logInfo, logWarning, logError
• In evolution
![Page 14: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/14.jpg)
Language comparison by examples
![Page 15: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/15.jpg)
Service method definitions
11/17/2014 15
![Page 16: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/16.jpg)
Service method definitions
11/17/2014 16
![Page 17: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/17.jpg)
Service method definitions
11/17/2014 17
![Page 18: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/18.jpg)
Logging
11/17/2014 18
![Page 19: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/19.jpg)
Logging
11/17/2014 19
![Page 20: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/20.jpg)
Logging
11/17/2014 20
![Page 21: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/21.jpg)
Arithmetic operations
11/17/2014 21
![Page 22: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/22.jpg)
Arithmetic operations
11/17/2014 22
![Page 23: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/23.jpg)
Service calls
11/17/2014 23
![Page 24: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/24.jpg)
Service calls
11/17/2014 24
![Page 25: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/25.jpg)
Service calls
11/17/2014 25
![Page 26: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/26.jpg)
Service calls
11/17/2014 26
![Page 27: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/27.jpg)
Service calls
11/17/2014 27
![Page 28: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/28.jpg)
Database operations
11/17/2014 28
![Page 29: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/29.jpg)
Database operations
11/17/2014 29
![Page 30: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/30.jpg)
Database operations
11/17/2014 30
![Page 31: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/31.jpg)
Summary and references
![Page 32: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/32.jpg)
Highlights of OFBiz DSL features
11/17/2014 32
• Available in all the contexts (events, services, data
preparation, scriptlets)
• Clean and simple API (in evolution)
• Powerful programming language (Groovy)
• Programming by exception pattern:
– “Unless specified differently, the framework will apply the default
rules”
• Automatic context detection
– return success()
• Automatic parameter detection (e.g. userLogin)
– runSync(‘createProduct’, [productId:’TEST-PRODUCT’])
• Transparent error and db transaction handling
![Page 33: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/33.jpg)
Next steps
11/17/2014 33
• Migrating Java/Minilang/Groovy code
• Testing and bug fixing
• Enhancing the OFBiz DSL
• IDE integration (Eclipse, IntelliJ available)
![Page 34: Introduction to a Groovy based DSL for Apache OFBiz...OFBiz committer since before the project joined the ASF (2006) ASF member since 2007 OFBiz PMC Chair since 2010 VP Technology](https://reader034.vdocuments.site/reader034/viewer/2022042508/5f59d02df5e44305f6481277/html5/thumbnails/34.jpg)
References
11/17/2014 34
• Further information (and code samples):
– https://cwiki.apache.org/confluence/x/_M_oAQ
• Apache OFBiz website:
– http://ofbiz.apache.org
• Emails:
– [email protected] • Trademarks
– Apache OFBiz, Apache are trademarks of The Apache Software Foundation
– Java is a registered trademark of Oracle and/or its affiliates
– Groovy is a registered trademark of The Codehaus