GDSL Awesomeness – Setting a global context

25 / Sep / 2012 by Kushal Likhi 0 comments


Sometimes we need to set the context for the GDSL contributor to all the possible files and scripts in the project scope.
This is a rare case scenario, but could be handy on some implementations.


This can be done by two techniques:

  1. Ignoring all filters passed to the “context” method.
  2. Setting the “ctype” parameter to “java.lang.Object” class.


It is illustrated as follows:
//To set the global context
def globalContext = context() // No need to provide any filters.

//Alternate method
def globalContext = context(ctype: "java.lang.Object") // Contribute to Object class



Read Further in the “GDSL AWESOMENESS” Series

  1. GDSL Awesomeness – Introduction to GDSL in IntelliJ Idea
  2. GDSL Awesomeness – Understanding Context And Contributors in Detail
  3. GDSL Awesomeness – Defining dynamic property in a class
  4. GDSL Awesomeness – Defining dynamic method in a class
  5. GDSL Awesomeness – Adding Hinting for missingMethod implementation
  6. GDSL Awesomeness – Setting a global context
  7. GDSL Awesomeness – Delegating Closure Calls
  8. GDSL Awesomeness – Defining methods in a closure passed to method of particular name
  9. GDSL Awesomeness – Defining Properties in a closure passed to method of particular name
  10. GDSL Awesomeness – Contributing to classes which match a path/name pattern
  11. GDSL Awesomeness – contributing methods with current class return types or parameters
  12. GDSL Awesomeness – AutoComplete Script for grails-Mail-Plugin “sendMail” closure
  13. GDSL Awesomeness – Getting Code of a method or Field in GDSL Script
  14. GDSL Awesomeness – Advanced Example showing domain properties implementation


Hope it helps

Kushal Likhi


Leave a Reply

Your email address will not be published. Required fields are marked *