Skip to content

Instantly share code, notes, and snippets.

@chumpa
Created November 30, 2021 13:01
Show Gist options
  • Save chumpa/031ce7ad099640abcb316eb5d5bb954c to your computer and use it in GitHub Desktop.
Save chumpa/031ce7ad099640abcb316eb5d5bb954c to your computer and use it in GitHub Desktop.
CPI groovy binding
import com.sap.gateway.ip.core.customdev.util.Message as CpiMsg
this.a = 1
b = 2
binding.c = "3"
CpiMsg read_bindings(CpiMsg msg) {
String log = """this.a == ${this.a}
this.b == ${this.b}
this = ${this}
this.class = ${this.class}
this.binding = ${this.binding}
this.binding.variables = ${this.binding.variables}
"""
msg.setBody(log)
return msg
}
/**
result is:
this.a == 1
this.b == 2
this = script1__Script@33811256
this.class = class script1__Script
this.binding = org.codehaus.groovy.jsr223.GroovyScriptEngineImpl$1@63f60130
this.binding.variables = [a:1, b:2, c:3, log:com.sap.it.script.logging.impl.ScriptLogger@6f60454d, logger:com.sap.it.script.logging.impl.ScriptLogger@31c7e745, javax.script.filename://src/main/resources/script/script1.groovy, messageLogFactory:com.sap.it.op.agent.mpl.factory.impl.MessageLogFactoryImpl@47f7a917]
*/
@chumpa
Copy link
Author

chumpa commented Nov 30, 2021

this = script1__Script@33811256 меняется при редеплое или очистке кук.
Что умеют делать binding.log и binding.logger и почему они разные, непонятно.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment