コード例 #1
0
  /**
   * A convenience method that takes a CommandInfo object and instantiates the corresponding
   * command, usually a JavaBean component.
   *
   * <p>This method calls the CommandInfo's <code>getCommandObject</code> method with the <code>
   * ClassLoader</code> used to load the <code>javax.activation.DataHandler</code> class itself.
   *
   * @param cmdinfo the CommandInfo corresponding to a command
   * @return the instantiated command object
   */
  public Object getBean(CommandInfo cmdinfo) {
    Object bean = null;

    try {
      // make the bean
      ClassLoader cld = null;
      // First try the "application's" class loader.
      cld = SecuritySupport.getContextClassLoader();
      if (cld == null) cld = this.getClass().getClassLoader();
      bean = cmdinfo.getCommandObject(this, cld);
    } catch (IOException e) {
    } catch (ClassNotFoundException e) {
    }

    return bean;
  }