Exemple #1
0
 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;
   }
 }
Exemple #2
0
 private Object popBeanOffStack() {
   // pop the bean off the stack
   if ((parentNode != root) && (beansStack.size() > 0)) {
     currentBean = (Bean) beansStack.pop();
     return currentBean.getBeanObject();
   }
   return null;
 }
Exemple #3
0
 private Object pushBeanOnStack(String classPackage, String clazz) {
   try {
     Bean bean = new Bean(classPackage, clazz, classLoaderStrategy, topLevelBean);
     parentNode = currentNode;
     currentBean = (Bean) beansStack.push(bean);
     return bean.getBeanObject();
   } catch (Exception e) {
     // bean could not be created
     System.err.println("bean could not be created: " + classPackage + "." + clazz);
     return null;
   }
 }