68 } 69 70 /** 71 * Return the command's class name. <i>This method MAY return null in 72 * cases where a CommandMap subclassed CommandInfo for its 73 * own purposes.</i> In other words, it might not be possible to 74 * create the correct state in the command by merely knowing 75 * its class name. <b>DO NOT DEPEND ON THIS METHOD RETURNING 76 * A VALID VALUE!</b> 77 * 78 * @return The class name of the command, or <i>null</i> 79 */ 80 public String getCommandClass() { 81 return className; 82 } 83 84 /** 85 * Return the instantiated JavaBean component. 86 * <p> 87 * Begin by instantiating the component with 88 * <code>Beans.instantiate()</code>. 89 * <p> 90 * If the bean implements the <code>javax.activation.CommandObject</code> 91 * interface, call its <code>setCommandContext</code> method. 92 * <p> 93 * If the DataHandler parameter is null, then the bean is 94 * instantiated with no data. NOTE: this may be useful 95 * if for some reason the DataHandler that is passed in 96 * throws IOExceptions when this method attempts to 97 * access its InputStream. It will allow the caller to 98 * retrieve a reference to the bean if it can be 99 * instantiated. 100 * <p> 101 * If the bean does NOT implement the CommandObject interface, 102 * this method will check if it implements the 103 * java.io.Externalizable interface. If it does, the bean's 104 * readExternal method will be called if an InputStream 105 * can be acquired from the DataHandler.<p> 106 * 107 * @param dh The DataHandler that describes the data to be 108 * passed to the command. 109 * @param loader The ClassLoader to be used to instantiate the bean. 110 * @return The bean 111 * @see java.beans.Beans#instantiate 112 * @see javax.activation.CommandObject 113 */ 114 public Object getCommandObject(DataHandler dh, ClassLoader loader) 115 throws IOException, ClassNotFoundException { 116 Object new_bean = null; 117 118 // try to instantiate the bean 119 new_bean = java.beans.Beans.instantiate(loader, className); 120 121 // if we got one and it is a CommandObject 122 if (new_bean != null) { 123 if (new_bean instanceof CommandObject) { 124 ((CommandObject)new_bean).setCommandContext(verb, dh); 125 } else if (new_bean instanceof Externalizable) { | 68 } 69 70 /** 71 * Return the command's class name. <i>This method MAY return null in 72 * cases where a CommandMap subclassed CommandInfo for its 73 * own purposes.</i> In other words, it might not be possible to 74 * create the correct state in the command by merely knowing 75 * its class name. <b>DO NOT DEPEND ON THIS METHOD RETURNING 76 * A VALID VALUE!</b> 77 * 78 * @return The class name of the command, or <i>null</i> 79 */ 80 public String getCommandClass() { 81 return className; 82 } 83 84 /** 85 * Return the instantiated JavaBean component. 86 * <p> 87 * Begin by instantiating the component with 88 * {@code Beans.instantiate()}. 89 * <p> 90 * If the bean implements the {@code javax.activation.CommandObject} 91 * interface, call its {@code setCommandContext} method. 92 * <p> 93 * If the DataHandler parameter is null, then the bean is 94 * instantiated with no data. NOTE: this may be useful 95 * if for some reason the DataHandler that is passed in 96 * throws IOExceptions when this method attempts to 97 * access its InputStream. It will allow the caller to 98 * retrieve a reference to the bean if it can be 99 * instantiated. 100 * <p> 101 * If the bean does NOT implement the CommandObject interface, 102 * this method will check if it implements the 103 * java.io.Externalizable interface. If it does, the bean's 104 * readExternal method will be called if an InputStream 105 * can be acquired from the DataHandler. 106 * 107 * @param dh The DataHandler that describes the data to be 108 * passed to the command. 109 * @param loader The ClassLoader to be used to instantiate the bean. 110 * @return The bean 111 * @see java.beans.Beans#instantiate 112 * @see javax.activation.CommandObject 113 */ 114 public Object getCommandObject(DataHandler dh, ClassLoader loader) 115 throws IOException, ClassNotFoundException { 116 Object new_bean = null; 117 118 // try to instantiate the bean 119 new_bean = java.beans.Beans.instantiate(loader, className); 120 121 // if we got one and it is a CommandObject 122 if (new_bean != null) { 123 if (new_bean instanceof CommandObject) { 124 ((CommandObject)new_bean).setCommandContext(verb, dh); 125 } else if (new_bean instanceof Externalizable) { |