Easy Groovy DSL
Easy Groovy DSL is the domain specific language based for Easy Extension Framework that is used to configure spring beans in SAP Commerce Cloud application contexts.
Availability of bound variables in EasyBeans.groovy
Following variable bindings are available for EasyBeans.groovy
spring: This binds the spring application context, it corresponds to
de.hybris.platform.core.Registry.coreApplicationContext
or tospring.parent
in hacspringWeb: This is a map of spring web contexts. There's no such a binding variable in hac, but you can add to
Script.metaClass
just execute on hac (once per jvm start):Script.metaClass.springWeb = loadBeansService.springWebContexts
extension: Object of type
com.sap.cx.boosters.easy.core.data.EasyExtension
that refers to the current Easy Extensionlogger: The logger variable defined for the easy extension. This corresponds to
org.slf4j.LoggerFactory.getLogger("easy.${extension.id}")
Application context beans: A spring application context aware binding is used to execute
EasyBeans.groovy
so bean names are resolved automatically this is very similar how script execution works on hac.
Defining a spring bean using Easy Groovy DSL
The spring beans using the Easy Groovy DSL is defined in EasyBeans.groovy
file of an Easy Extension. The spring beans can either be defined for the Core application context or for the web application context.
Easy Core Beans
The Easy Core Beans are the spring beans those are registered to the Core Spring Application Context. The definition of Easy Core Beans corresponds to com.sap.cx.boosters.easy.core.spring.beans.reader.impl.DSLEasyBeanDefinitionReaders#easyCoreBeans(groovy.lang.Closure)
. A static import is added in compiler options when EasyBeans.groovy
is compiled. At this stage there's limited support for autocompletion inside this closure. It just delegates to org.springframework.beans.factory.support.DefaultListableBeanFactory
Defining a core bean in EasyBeans.groovy
To define the spring beans in core application context use the following easyCorebeans
block inside EasyBeans.groovy
class.
Extending from an existing parent bean
To define the spring beans in core application context that extends from an existing bean, use the ref
function as shown below.
Easy Web Beans
The Easy Web Beans are the spring beans those are registered to the specific Spring Web Application Context. The definition of Easy Web Beans corresponds to com.sap.cx.boosters.easy.core.spring.beans.reader.impl.DSLEasyBeanDefinitionReaders#easyWebBeans(String, groovy.lang.Closure)
. A static import is added in compiler options when EasyBeans.groovy
is compiled. At this stage there's limited support for autocompletion inside this closure. It just delegates to org.springframework.beans.factory.support.DefaultListableBeanFactory
Defining a web bean in EasyBeans.groovy
To define the spring beans in core application context use the following easyCorebeans
block inside EasyBeans.groovy
class.