Search This Blog

Showing posts with label groovy. Show all posts
Showing posts with label groovy. Show all posts

Sunday, April 26, 2020

SAP commerce (Hybris): Groovy Script to know all methods and property of bean runtime


Recently we needed to troubleshoot few production issues, we need to know all methods and property runtime our of java and beans. 

Following groovy script was helpfull to know the details and write code accordingly (This script can be executed from SAP Commerce HAC ( admin console)

import java.lang.reflect.Method;
import java.lang.reflect.Field;

//System.out.println(spring.javax.xml.ws.service.endpoint.address)

for(Method m : spring.getClass().getMethods()) {
   System.out.println(m)
}

for(Field m : spring.getClass().getFields()) {
   System.out.println(m)
}

Object js = spring.getBean("beanname");

for(Method m : js.getClass().getMethods()) {
   System.out.println(m)
}



for(Field m : js.getClass().getFields()) {
   System.out.println(m)
}

Cheers,
Kapil




Popular Posts