public class CommandInfo
extends java.lang.Object
Constructor and Description |
---|
CommandInfo(java.lang.String verb,
java.lang.String className)
The Constructor for CommandInfo.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getCommandClass()
Return the command's class name.
|
java.lang.String |
getCommandName()
Return the command verb.
|
java.lang.Object |
getCommandObject(DataHandler dh,
java.lang.ClassLoader loader)
Return the instantiated JavaBean component.
|
public CommandInfo(java.lang.String verb, java.lang.String className)
verb
- The command verb this CommandInfo decribes.className
- The command's fully qualified class name.public java.lang.String getCommandName()
public java.lang.String getCommandClass()
public java.lang.Object getCommandObject(DataHandler dh, java.lang.ClassLoader loader) throws java.io.IOException, java.lang.ClassNotFoundException
If the current runtime environment supports
Beans.instantiate
,
use it to instantiate the JavaBeans component. Otherwise, use
Class.forName
.
The component class needs to be public. On Java SE 9 and newer, if the component class is in a named module, it needs to be in an exported package.
If the bean implements the javax.activation.CommandObject
interface, call its setCommandContext
method.
If the DataHandler parameter is null, then the bean is instantiated with no data. NOTE: this may be useful if for some reason the DataHandler that is passed in throws IOExceptions when this method attempts to access its InputStream. It will allow the caller to retrieve a reference to the bean if it can be instantiated.
If the bean does NOT implement the CommandObject interface, this method will check if it implements the java.io.Externalizable interface. If it does, the bean's readExternal method will be called if an InputStream can be acquired from the DataHandler.
dh
- The DataHandler that describes the data to be
passed to the command.loader
- The ClassLoader to be used to instantiate the bean.java.io.IOException
- for failures reading datajava.lang.ClassNotFoundException
- if command object class can't
be foundBeans.instantiate(java.lang.ClassLoader, java.lang.String)
,
CommandObject