This section explains how a module can be integrated and consume dependencies, for example, with
          other modules. A GateIn
          module consists of the declaration of a JavaScript self-executing function and its declaration in the
          gatein-resources.xml
          descriptor of the web application. This descriptor defines the module and its dependencies. At runtime, GateIn
          will build a graph of resources and their dependencies. When a client needs a particular module, it will
          invoke
          a JS function that calls
          RequireJS
          to resolve dependencies.
        
For instance, if you have a
          foo
          module that uses the jQuery dependency:
        
(function ($) {
  // Do something with jQuery
})(jQuery)
The module is declared as a
          self-executing function
          in the
          foo.js
          file. This file is then declared in the
          gatein-resources.xml
          file:
        
...
<module>
<name>foo</name>
<script>
<path>/foo.js</path>
</script>
<depends>
<module>jquery</module>
<as>jQuery</as>
</depends>
</module>
...
The self-executing function declares:
Parameter for the function:
              $
            
Arguments of the function invocation:
              jQuery
            
The self-executing function argument must match the dependencies:
The function does not need to match with the XML dependencies order.
The function can use a parameter subset: a dependency can be declared in XML but not consumed as an argument.
Parameters must be aliased in dependencies with the <as> tag XML.
The argument of the self-executing function is a JavaScript constructor which aims to pass arguments to the function, let the function name the arguments as they want, and override the current scope of execution. For example, jQuery uses it:
(function(window, undefined) { .... })(window);
Resources are related to the concept of dependency relationship that specifies how scripts are related to
          others and how the modular system should work. In this example, the foo module needs
          to use jQuery, it means that they are in relationship: the foo module depends on jQuery.
          When the module is loaded, the jQuery
          module must be available to the module.