on 09-22-2016 4:34 PM
Suppose I have an ImpEx file which defines an ImpEx variable ("$variable=value"). How can I access such an ImpEx variable from BeanShell code in the same ImpEx file?
As a simple example, let's assume I have
$cronjob=abc
#% import de.hybris.platform.core.Registry
#% import de.hybris.platform.servicelayer.cronjob.CronJobService
#% CronJobService cronJobService = Registry.getApplicationContext().getBean("cronJobService")
#% cronJobService.performCronJob(cronJobService.getCronJob("xxx"),true)
How can I access the value of "$cronjob" in the BeanShell code (instead of "xxx")?
It replaces all of the macros before running your code so just use $cronjob
e.g.
$cronjob=abcd
#% java.lang.System.out.println("$cronjob");
Prints abcd
to stdout.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah me too.
I was posting an answer showing how to abuse beanshell's setAccessiblity(true)
method and couldn't understand why it wasn't working.
$cronjob=abc
#% setAccessibility(true)
#% cronjob = impex.definitions.get("$cronjob")
#% java.lang.System.out.println(cronjob)
kept printing null, until I realised that is was actually running
#% cronjob = impex.definitions.get("abc")
because the macro had been replaced and the answer became much simpler!
User | Count |
---|---|
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.