SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
Java DSLs
                        with Xtext
                           Jan Koehnlein




Mittwoch, 27. März 13
Mittwoch, 27. März 13
Mittwoch, 27. März 13
public class Customer implements Serializable {

                        	   private String name;
                        	   private Address address;
                        	   private List<Item> purchase;

                        	   public String getName() {
                        	   	   return name;
                        	   }
                        	   public void setName(String name) {
                        	   	   this.name = name;
                        	   }

                        	   public Address getAddress() {
                        	   	   return address;
                        	   }
                        	   public void setAddress(Address address) {
                        	   	   this.address = address;
                        	   }
                        	
                        	   public List<Item> getPurchase() {
                        	   	   return purchase;
                        	   }
                        	   public void setPurchase(List<Item> items) {
                        	   	   this.purchase = purchase;
                        	   }
                        }




Mittwoch, 27. März 13
@Entity
                        public class Customer implements Serializable {
                        	   @Id
                        	   private String name;
                        	   private Address address;
                        	   private List<Item> purchase;

                        	   public String getName() {
                        	   	   return name;
                        	   }
                        	   public void setName(String name) {
                        	   	   this.name = name;
                        	   }
                        	   @Column(name="ADDR", nullable=false)
                        	   public Address getAddress()
                        	   	   return address;
                        	   }
                        	   public void setAddress(Address address) {
                        	   	   this.address = address;
                        	   }
                        	   @ManyToMany
                        	   public List<Item> getPurchase() {
                        	   	   return purchase;
                        	   }
                        	   public void setPurchase(List<Item> items) {
                        	   	   this.purchase = purchase;
                        	   }
                        }




Mittwoch, 27. März 13
Domain-Specific Languages




Mittwoch, 27. März 13
DSL                        Java
            entity Customer {
                                 @Entity
              name: String       public class Customer implements Serializable {
                                 	   @Id
              address: Address   	   private String name;
              purchase: Item*    	
                                 	
                                     private Address address;
                                     private List<Item> purchase;
            }
                                 	   public String getName() {
                                 	   	   return name;
                                 	   }
                                 	   public void setName(String name) {
                                 	   	   this.name = name;
                                 	   }
                                 	   @Column(name="ADDR", nullable=false)


            Code                 	
                                 	
                                 	
                                 	
                                     public Address getAddress() {
                                     	
                                     }
                                         return address;

                                     public void setAddress(Address address) {



          Generation
                                 	   	   this.address = address;
                                 	   }
                                 	   @ManyToMany
                                 	   public List<Item> getPurchase() {
                                 	   	   return purchase;
                                 	   }
                                 	   public void setPurchase(List<Item> items) {
                                 	   	   this.purchase = purchase;
                                 	   }
                                 }



Mittwoch, 27. März 13
?
                         Methods
                           Logic
                        Arithmetics
                         Behavior



Mittwoch, 27. März 13
entity Customer {
                          name: String
                          address: Address
                          purchase: Item*
                          double sales() {
                            double result = 0.0;
                            for(Item item: purchase)
                              result += item.getPrice();
                            return result;
                          }
                        }




Mittwoch, 27. März 13
Expressions



                          Complex Syntax
                             Typesystem
                        Compiler / Interpreter

Mittwoch, 27. März 13
Integration Patterns
                         Manually
                         written
                           code




                            Generated
                              code



Mittwoch, 27. März 13
Reusable powerful expression
                                    library language


                        Java‘s Typesystem


                            Access to Java-elements

                                       Compile to Java Code


Mittwoch, 27. März 13
DSLs
                         for
                        Java
Mittwoch, 27. März 13
grammar inheritance

                               Grammar (Parser, Lexer)
                                           Linker
                                           Type System




                                JvmModel
              MyLanguage                   Interpreter /
                                           Advanced Editor
                                           Eclipse Integration
                                           Debugger


                                      JvmModelInferrer



Mittwoch, 27. März 13
Model Inference
                                             Class Customer
                   entity Customer {
                     name: String               Field name
                     address: Address
                     purchasedItems: Item*      Method getName
                     double sales() {
                       purchasedItems
                                                   returnType String
                         .map[price]
                         .reduce[a,b|a+b]
                     }                         Method setName
                   }
                                                   parameter name

                                                       type String


Mittwoch, 27. März 13
Model Inference
                   entity Customer {
                     name: String
                     address: Address
                     purchasedItems: Item*
                     double sales() {        Method sales
                       purchasedItems
                         .map[price]           returnType double
                         .reduce[a,b|a+b]
                     }
                                                body Expression
                   }




Mittwoch, 27. März 13
class ScriptingJvmModelInferrer extends AbstractModelInferrer {
                        	
                           	
                           @Inject extension JvmTypesBuilder

                             	
                             def dispatch void infer(Script script,
                                    IJvmDeclaredTypeAcceptor acceptor,
                                    boolean isPreIndexingPhase) {
                             	
                             	 acceptor.accept(script.toClass('MyClass'))
                                    .initializeLater [
                             	
                             	 	 // the class gets one main method
                             	
                             	 	 members += script.toMethod(
                                           'main',
                                           script.newTypeRef(Void::TYPE)) [
                             	
                             	 	 	 parameters += script.toParameter("args",
                                           script.newTypeRef(typeof(String))
                                                  .addArrayTypeDimension)
                             	
                             	 	 	 static = true
                             	
                             	 	 	 varArgs = true
                             	
                             	 	 	 // Associate the script as the body of the main method
                             	
                             	 	 	 body = script
                             	
                             	 	 ]	
                             	
                             	 ]
                            	}
                        }




Mittwoch, 27. März 13
The 7 Languages
                            Scripting Language
                           DSL for MongoDB
                          Http Routing Language
                           Templates Language
                             DSL for Guice
                             Build Language
                                Tortoise

Mittwoch, 27. März 13
Find more at
                        www.eclipse.org/Xtext/7languages.html




Mittwoch, 27. März 13

Contenu connexe

En vedette

Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with XtextGlobalLogic Ukraine
 
Executable specifications for xtext
Executable specifications for xtextExecutable specifications for xtext
Executable specifications for xtextmeysholdt
 
Using Xcore with Xtext
Using Xcore with XtextUsing Xcore with Xtext
Using Xcore with XtextHolger Schill
 
Language Engineering With Xtext
Language Engineering With XtextLanguage Engineering With Xtext
Language Engineering With XtextSven Efftinge
 
Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2Dr. Jan Köhnlein
 
Extending the Xbase Typesystem
Extending the Xbase TypesystemExtending the Xbase Typesystem
Extending the Xbase TypesystemSebastian Zarnekow
 
Introduction to Xbase
Introduction to XbaseIntroduction to Xbase
Introduction to XbaseHolger Schill
 
Enhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesEnhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesUniversity of York
 
Eclipse DemoCamp in Paris: Language Development with Xtext
Eclipse DemoCamp in Paris: Language Development with XtextEclipse DemoCamp in Paris: Language Development with Xtext
Eclipse DemoCamp in Paris: Language Development with XtextSebastian Zarnekow
 
From Stairway to Heaven onto the Highway to Hell with Xtext
From Stairway to Heaven onto the Highway to Hell with XtextFrom Stairway to Heaven onto the Highway to Hell with Xtext
From Stairway to Heaven onto the Highway to Hell with XtextKarsten Thoms
 
Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With XtextSven Efftinge
 
Xtext's new Formatter API
Xtext's new Formatter APIXtext's new Formatter API
Xtext's new Formatter APImeysholdt
 

En vedette (20)

Building Your Own DSL with Xtext
Building Your Own DSL with XtextBuilding Your Own DSL with Xtext
Building Your Own DSL with Xtext
 
Executable specifications for xtext
Executable specifications for xtextExecutable specifications for xtext
Executable specifications for xtext
 
Xtext Best Practices
Xtext Best PracticesXtext Best Practices
Xtext Best Practices
 
Using Xcore with Xtext
Using Xcore with XtextUsing Xcore with Xtext
Using Xcore with Xtext
 
Xtext, diagrams and ux
Xtext, diagrams and uxXtext, diagrams and ux
Xtext, diagrams and ux
 
Language Engineering With Xtext
Language Engineering With XtextLanguage Engineering With Xtext
Language Engineering With Xtext
 
Scoping
ScopingScoping
Scoping
 
Scoping Tips and Tricks
Scoping Tips and TricksScoping Tips and Tricks
Scoping Tips and Tricks
 
Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2Pragmatic DSL Design with Xtext, Xbase and Xtend 2
Pragmatic DSL Design with Xtext, Xbase and Xtend 2
 
Extending the Xbase Typesystem
Extending the Xbase TypesystemExtending the Xbase Typesystem
Extending the Xbase Typesystem
 
Future of Xtext
Future of XtextFuture of Xtext
Future of Xtext
 
Introduction to Xbase
Introduction to XbaseIntroduction to Xbase
Introduction to Xbase
 
Graphical Views For Xtext
Graphical Views For XtextGraphical Views For Xtext
Graphical Views For Xtext
 
Enhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose LanguagesEnhancing Xtext for General Purpose Languages
Enhancing Xtext for General Purpose Languages
 
Eclipse DemoCamp in Paris: Language Development with Xtext
Eclipse DemoCamp in Paris: Language Development with XtextEclipse DemoCamp in Paris: Language Development with Xtext
Eclipse DemoCamp in Paris: Language Development with Xtext
 
From Stairway to Heaven onto the Highway to Hell with Xtext
From Stairway to Heaven onto the Highway to Hell with XtextFrom Stairway to Heaven onto the Highway to Hell with Xtext
From Stairway to Heaven onto the Highway to Hell with Xtext
 
Parsing Expression With Xtext
Parsing Expression With XtextParsing Expression With Xtext
Parsing Expression With Xtext
 
Java Performance MythBusters
Java Performance MythBustersJava Performance MythBusters
Java Performance MythBusters
 
Xtext's new Formatter API
Xtext's new Formatter APIXtext's new Formatter API
Xtext's new Formatter API
 
What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0What's Cooking in Xtext 2.0
What's Cooking in Xtext 2.0
 

Similaire à Java DSLs with Xtext

Pitfalls In Aspect Mining
Pitfalls In Aspect MiningPitfalls In Aspect Mining
Pitfalls In Aspect Miningkim.mens
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à DartSOAT
 
High performance JPA with Oracle Coherence
High performance JPA with Oracle CoherenceHigh performance JPA with Oracle Coherence
High performance JPA with Oracle CoherenceMarkus Eisele
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBOren Eini
 
Combatendo code smells em Java
Combatendo code smells em Java Combatendo code smells em Java
Combatendo code smells em Java Emmanuel Neri
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в JavaDEVTYPE
 

Similaire à Java DSLs with Xtext (6)

Pitfalls In Aspect Mining
Pitfalls In Aspect MiningPitfalls In Aspect Mining
Pitfalls In Aspect Mining
 
Introduction à Dart
Introduction à DartIntroduction à Dart
Introduction à Dart
 
High performance JPA with Oracle Coherence
High performance JPA with Oracle CoherenceHigh performance JPA with Oracle Coherence
High performance JPA with Oracle Coherence
 
Implementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDBImplementing CQRS and Event Sourcing with RavenDB
Implementing CQRS and Event Sourcing with RavenDB
 
Combatendo code smells em Java
Combatendo code smells em Java Combatendo code smells em Java
Combatendo code smells em Java
 
3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java3. Объекты, классы и пакеты в Java
3. Объекты, классы и пакеты в Java
 

Plus de Dr. Jan Köhnlein

The Eclipse Layout Kernel sirius con 2017
The Eclipse Layout Kernel   sirius con 2017The Eclipse Layout Kernel   sirius con 2017
The Eclipse Layout Kernel sirius con 2017Dr. Jan Köhnlein
 
A New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEsA New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEsDr. Jan Köhnlein
 
Graphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagramGraphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagramDr. Jan Köhnlein
 
Diagram Editors - The FXed Generation
Diagram Editors - The FXed GenerationDiagram Editors - The FXed Generation
Diagram Editors - The FXed GenerationDr. Jan Köhnlein
 
Eclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered SpeciesEclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered SpeciesDr. Jan Köhnlein
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editingDr. Jan Köhnlein
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editingDr. Jan Köhnlein
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editingDr. Jan Köhnlein
 
Android tutorial - Xtext slides
Android tutorial - Xtext slidesAndroid tutorial - Xtext slides
Android tutorial - Xtext slidesDr. Jan Köhnlein
 
Combining Text and Graphics in Eclipse-based Modeling Tools
Combining Text and Graphics in Eclipse-based Modeling ToolsCombining Text and Graphics in Eclipse-based Modeling Tools
Combining Text and Graphics in Eclipse-based Modeling ToolsDr. Jan Köhnlein
 
Combining Graphical and Textual
Combining Graphical and TextualCombining Graphical and Textual
Combining Graphical and TextualDr. Jan Köhnlein
 
Domain Specific Languages With Eclipse Modeling
Domain Specific Languages With Eclipse ModelingDomain Specific Languages With Eclipse Modeling
Domain Specific Languages With Eclipse ModelingDr. Jan Köhnlein
 

Plus de Dr. Jan Köhnlein (20)

The Eclipse Layout Kernel sirius con 2017
The Eclipse Layout Kernel   sirius con 2017The Eclipse Layout Kernel   sirius con 2017
The Eclipse Layout Kernel sirius con 2017
 
A New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEsA New Approach Towards Web-based IDEs
A New Approach Towards Web-based IDEs
 
Responsiveness
ResponsivenessResponsiveness
Responsiveness
 
Getting rid of backtracking
Getting rid of backtrackingGetting rid of backtracking
Getting rid of backtracking
 
Graphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagramGraphical Views For Xtext With FXDiagram
Graphical Views For Xtext With FXDiagram
 
XRobots
XRobotsXRobots
XRobots
 
Diagrams, Xtext and UX
Diagrams, Xtext and UXDiagrams, Xtext and UX
Diagrams, Xtext and UX
 
Diagram Editors - The FXed Generation
Diagram Editors - The FXed GenerationDiagram Editors - The FXed Generation
Diagram Editors - The FXed Generation
 
Code Generation With Xtend
Code Generation With XtendCode Generation With Xtend
Code Generation With Xtend
 
The Xtext Grammar Language
The Xtext Grammar LanguageThe Xtext Grammar Language
The Xtext Grammar Language
 
Eclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered SpeciesEclipse Diagram Editors - An Endangered Species
Eclipse Diagram Editors - An Endangered Species
 
DSLs for Java Developers
DSLs for Java DevelopersDSLs for Java Developers
DSLs for Java Developers
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
A fresh look at graphical editing
A fresh look at graphical editingA fresh look at graphical editing
A fresh look at graphical editing
 
Android tutorial - Xtext slides
Android tutorial - Xtext slidesAndroid tutorial - Xtext slides
Android tutorial - Xtext slides
 
Eclipse meets e4
Eclipse meets e4Eclipse meets e4
Eclipse meets e4
 
Combining Text and Graphics in Eclipse-based Modeling Tools
Combining Text and Graphics in Eclipse-based Modeling ToolsCombining Text and Graphics in Eclipse-based Modeling Tools
Combining Text and Graphics in Eclipse-based Modeling Tools
 
Combining Graphical and Textual
Combining Graphical and TextualCombining Graphical and Textual
Combining Graphical and Textual
 
Domain Specific Languages With Eclipse Modeling
Domain Specific Languages With Eclipse ModelingDomain Specific Languages With Eclipse Modeling
Domain Specific Languages With Eclipse Modeling
 

Dernier

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
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 FresherRemote DBA Services
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Dernier (20)

Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
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
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Java DSLs with Xtext

  • 1. Java DSLs with Xtext Jan Koehnlein Mittwoch, 27. März 13
  • 4. public class Customer implements Serializable { private String name; private Address address; private List<Item> purchase; public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } } Mittwoch, 27. März 13
  • 5. @Entity public class Customer implements Serializable { @Id private String name; private Address address; private List<Item> purchase; public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="ADDR", nullable=false) public Address getAddress() return address; } public void setAddress(Address address) { this.address = address; } @ManyToMany public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } } Mittwoch, 27. März 13
  • 7. DSL Java entity Customer { @Entity name: String public class Customer implements Serializable { @Id address: Address private String name; purchase: Item* private Address address; private List<Item> purchase; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Column(name="ADDR", nullable=false) Code public Address getAddress() { } return address; public void setAddress(Address address) { Generation this.address = address; } @ManyToMany public List<Item> getPurchase() { return purchase; } public void setPurchase(List<Item> items) { this.purchase = purchase; } } Mittwoch, 27. März 13
  • 8. ? Methods Logic Arithmetics Behavior Mittwoch, 27. März 13
  • 9. entity Customer { name: String address: Address purchase: Item* double sales() { double result = 0.0; for(Item item: purchase) result += item.getPrice(); return result; } } Mittwoch, 27. März 13
  • 10. Expressions Complex Syntax Typesystem Compiler / Interpreter Mittwoch, 27. März 13
  • 11. Integration Patterns Manually written code Generated code Mittwoch, 27. März 13
  • 12. Reusable powerful expression library language Java‘s Typesystem Access to Java-elements Compile to Java Code Mittwoch, 27. März 13
  • 13. DSLs for Java Mittwoch, 27. März 13
  • 14. grammar inheritance Grammar (Parser, Lexer) Linker Type System JvmModel MyLanguage Interpreter / Advanced Editor Eclipse Integration Debugger JvmModelInferrer Mittwoch, 27. März 13
  • 15. Model Inference Class Customer entity Customer { name: String Field name address: Address purchasedItems: Item* Method getName double sales() { purchasedItems returnType String .map[price] .reduce[a,b|a+b] } Method setName } parameter name type String Mittwoch, 27. März 13
  • 16. Model Inference entity Customer { name: String address: Address purchasedItems: Item* double sales() { Method sales purchasedItems .map[price] returnType double .reduce[a,b|a+b] } body Expression } Mittwoch, 27. März 13
  • 17. class ScriptingJvmModelInferrer extends AbstractModelInferrer { @Inject extension JvmTypesBuilder def dispatch void infer(Script script, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) { acceptor.accept(script.toClass('MyClass')) .initializeLater [ // the class gets one main method members += script.toMethod( 'main', script.newTypeRef(Void::TYPE)) [ parameters += script.toParameter("args", script.newTypeRef(typeof(String)) .addArrayTypeDimension) static = true varArgs = true // Associate the script as the body of the main method body = script ] ] } } Mittwoch, 27. März 13
  • 18. The 7 Languages Scripting Language DSL for MongoDB Http Routing Language Templates Language DSL for Guice Build Language Tortoise Mittwoch, 27. März 13
  • 19. Find more at www.eclipse.org/Xtext/7languages.html Mittwoch, 27. März 13