I have the following class with a static method, which takes an argument of type Class<? extends FunctionProvider>
and generates a FunctionDescriptor.
public class NoInputFunctionDescriptorFactory {
public static FunctionDescriptor getFunctionDescriptorForClass(Class<? extends FunctionProvider> clazz) {
FunctionDescriptor functionDescriptor = DescriptorFactory.getFactory().createFunctionDescriptor();
functionDescriptor.setType("class");
functionDescriptor.setName(clazz.getSimpleName());
Map conditionArgs = functionDescriptor.getArgs();
conditionArgs.put("class.name", clazz.getName());
return functionDescriptor;
}
}
I call this class from a helper method which takes two arguments of type String
, the factory class name (e.g. com.example.NoInputFunctionDescriptorFactory
) and the class name of a class, extending FunctionProvider
(e.g. com.example.CreateIssuesPostFunction
). These arguments are read from a yaml model, therefore they are of type String
.
private FunctionDescriptor createFunctionDescriptorFactory(String factoryClassNameString, String functionProviderClassNameString) {
try {
Class<? extends FunctionProvider> functionProviderClass = (Class<? extends FunctionProvider>) Class.forName(functionProviderClassNameString);
Class<?> factoryClass = Class.forName(factoryClassNameString);
Method method = factoryClass.getMethod("getFunctionDescriptorForClass", FunctionProvider.class);
return (FunctionDescriptor) method.invoke(null, functionProviderClass);
} catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
return null;
}
}
When I call the createFunctionDescriptorFactory()
method I always end up having a NoSuchMethodException
:
java.lang.NoSuchMethodException: com.example.NoInputFunctionDescriptorFactory.getFunctionDescriptorForClass(com.opensymphony.workflow.FunctionProvider)
May someone explain me where I'm wrong?
Aucun commentaire:
Enregistrer un commentaire