use of com.haulmont.cuba.core.app.scheduled.MethodParameterInfo in project cuba by cuba-platform.
the class AbstractBeansMetadata method getAvailableMethods.
protected List<MethodInfo> getAvailableMethods(String beanName) {
List<MethodInfo> methods = new ArrayList<>();
try {
AutowireCapableBeanFactory beanFactory = AppContext.getApplicationContext().getAutowireCapableBeanFactory();
if (beanFactory instanceof CubaDefaultListableBeanFactory) {
BeanDefinition beanDefinition = ((CubaDefaultListableBeanFactory) beanFactory).getBeanDefinition(beanName);
if (beanDefinition.isAbstract())
return methods;
}
Object bean = AppBeans.get(beanName);
@SuppressWarnings("unchecked") List<Class> classes = ClassUtils.getAllInterfaces(bean.getClass());
for (Class aClass : classes) {
if (aClass.getName().startsWith("org.springframework."))
continue;
Class<?> targetClass = bean instanceof TargetClassAware ? ((TargetClassAware) bean).getTargetClass() : bean.getClass();
for (Method method : aClass.getMethods()) {
if (isMethodAvailable(method)) {
Method targetClassMethod = targetClass.getMethod(method.getName(), method.getParameterTypes());
List<MethodParameterInfo> methodParameters = getMethodParameters(targetClassMethod);
MethodInfo methodInfo = new MethodInfo(method.getName(), methodParameters);
addMethod(methods, methodInfo);
}
}
if (methods.isEmpty()) {
for (Method method : bean.getClass().getMethods()) {
if (!method.getDeclaringClass().equals(Object.class) && isMethodAvailable(method)) {
List<MethodParameterInfo> methodParameters = getMethodParameters(method);
MethodInfo methodInfo = new MethodInfo(method.getName(), methodParameters);
addMethod(methods, methodInfo);
}
}
}
}
} catch (Throwable t) {
log.debug(t.getMessage());
}
return methods;
}
use of com.haulmont.cuba.core.app.scheduled.MethodParameterInfo in project cuba by cuba-platform.
the class ScheduledTask method updateMethodParameters.
public void updateMethodParameters(List<MethodParameterInfo> params) {
Document doc = DocumentHelper.createDocument();
Element paramsEl = doc.addElement("params");
for (MethodParameterInfo param : params) {
Element paramEl = paramsEl.addElement("param");
paramEl.addAttribute("type", param.getType().getName());
paramEl.addAttribute("name", param.getName());
paramEl.setText(param.getValue() != null ? param.getValue().toString() : "");
}
setMethodParamsXml(Dom4j.writeDocument(doc, true));
}
use of com.haulmont.cuba.core.app.scheduled.MethodParameterInfo in project cuba by cuba-platform.
the class ScheduledTask method getMethodParametersString.
@MetaProperty
public String getMethodParametersString() {
StringBuilder sb = new StringBuilder();
int count = 0;
List<MethodParameterInfo> parameters = getMethodParameters();
for (MethodParameterInfo param : parameters) {
sb.append(param.getType().getSimpleName()).append(" ").append(param.getName()).append(" = ").append(param.getValue());
if (++count != parameters.size())
sb.append(", ");
}
return sb.toString();
}
Aggregations