public String[] names() { if (names==null) names = ClassDescriptor.loadParameterNames(method); return names; } }
private static String[] loadConstructorParamNames(Class<?> clazz) { return new ClassDescriptor(clazz).loadConstructorParamNames(); }
@Override public List<Function> getFunctions(Class clazz) { // Historically ClassDescriptor used to own this non-trivial logic of computing // valid functions for the class, so we'll keep it there. return new ClassDescriptor(clazz).methods; } };
findMethods(clazz,clazz,methods,new HashSet<Class>());
private static String loadSoleArgumentKey(StepDescriptor d) { try { String[] names = new ClassDescriptor(d.clazz).loadConstructorParamNames(); return names.length == 1 ? names[0] : null; } catch (NoStaplerConstructorException e) { return null; } }
@Override public List<Function> getFunctions(Class clazz) { // Historically ClassDescriptor used to own this non-trivial logic of computing // valid functions for the class, so we'll keep it there. return new ClassDescriptor(clazz).methods; } };
findMethods(clazz,clazz,methods,new HashSet<Class>());
@Override public Set<Attribute<T,?>> describe() { final Set<Attribute<T,?>> attributes = super.describe(); final Constructor constructor = getDataBoundConstructor(target); if (constructor != null) { final Parameter[] parameters = constructor.getParameters(); final String[] names = ClassDescriptor.loadParameterNames(constructor); for (int i = 0; i < parameters.length; i++) { final Parameter p = parameters[i]; final Attribute a = createAttribute(names[i], TypePair.of(p)); if (a == null) continue; attributes.add(a); } } return attributes; }
private static String[] loadConstructorParamNames(Class<?> clazz) { return new ClassDescriptor(clazz).loadConstructorParamNames(); }
@Override public List<Function> getFunctions(RubyModule clazz) { // implemented as a fallback to Java through reified class, but maybe there's a better way to do this return new ClassDescriptor(toJavaClass(clazz)).methods; }
findMethods(i, Types.getBaseClass(logical,i), result, visited); findMethods(sc,Types.getBaseClass(logical,sc),result,visited);
private T tryConstructor(Constructor<T> constructor, Mapping config, ConfigurationContext context) throws ConfiguratorException { final Parameter[] parameters = constructor.getParameters(); final String[] names = ClassDescriptor.loadParameterNames(constructor); Object[] args = new Object[names.length];
/*package*/ MetaClass(WebApp webApp, Class clazz) { this.clazz = clazz; this.webApp = webApp; this.baseClass = webApp.getMetaClass(clazz.getSuperclass()); this.classLoader = MetaClassLoader.get(clazz.getClassLoader()); buildDispatchers( new ClassDescriptor(clazz,null/*support wrappers*/)); }
findMethods(i, Types.getBaseClass(logical,i), result, visited); findMethods(sc,Types.getBaseClass(logical,sc),result,visited);
final String[] names = ClassDescriptor.loadParameterNames(constructor); final Attribute[] attributes = new Attribute[parameters.length]; final Object[] args = new Object[parameters.length];
public <T> T bindParameters(Class<T> type, String prefix, int index) { String[] names = new ClassDescriptor(type).loadConstructorParamNames(); // the actual arguments to invoke the constructor with. Object[] args = new Object[names.length]; // constructor Constructor<T> c = findConstructor(type, names.length); Class[] types = c.getParameterTypes(); // convert parameters for( int i=0; i<names.length; i++ ) { String[] values = getParameterValues(prefix + names[i]); String param; if(values!=null) param = values[index]; else param = null; Converter converter = Stapler.lookupConverter(types[i]); if (converter==null) throw new IllegalArgumentException("Unable to convert to "+types[i]); args[i] = converter.convert(types[i],param); } return invokeConstructor(c, args); }
public Function load(Class from) { // MethdFunction for invoking a static method as a static method FunctionList methods = new ClassDescriptor(from).methods.name("fromStapler"); switch (methods.size()) { case 0: return RETURN_NULL; default: throw new IllegalArgumentException("Too many 'fromStapler' methods on "+from); case 1: Method m = ((MethodFunction)methods.get(0)).m; return new MethodFunction(m) { @Override public Class[] getParameterTypes() { return m.getParameterTypes(); } @Override public Type[] getGenericParameterTypes() { return m.getGenericParameterTypes(); } @Override public Annotation[][] getParameterAnnotations() { return m.getParameterAnnotations(); } @Override public Object invoke(StaplerRequest req, StaplerResponse rsp, Object o, Object... args) throws IllegalAccessException, InvocationTargetException { return m.invoke(null,args); } }; } } });
public String[] names() { if (names==null) names = ClassDescriptor.loadParameterNames(method); return names; } }