public Bean(String classPackage, String clazz, ClassLoaderStrategy cls, Bean topLevelBean) throws Exception { // Get the no-arg constructor and create the bean try { Class classOfBean = ObjectXml.getClassOfBean((ClassLoader) cls, classPackage + "." + clazz); Constructor ct = null; // check whether this class is an inner class if (classOfBean.getEnclosingClass() != null) { ct = classOfBean.getConstructor(new Class[] {classOfBean.getEnclosingClass()}); beanObject = ct.newInstance(new Object[] {topLevelBean.getBeanObject()}); } else { ct = classOfBean.getConstructor((Class[]) null); beanObject = ct.newInstance((Object[]) null); } // Get an array of property descriptors beanInfo = Introspector.getBeanInfo(classOfBean); PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors(); // load property descriptors into hashtable propDesc = new Properties(); for (int i = 0; i < pds.length; i++) { propDesc.put(pds[i].getName(), pds[i]); } } catch (Exception e) { System.err.println("Exception creating bean: " + e.getMessage()); e.printStackTrace(); throw e; } }
public PropertyDescriptor getPropertyDescriptor(String name) { return (PropertyDescriptor) propDesc.get(getPropertyName(name)); }