CommandInfo (Java EE 5 SDK)

Java

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


javax.activation Class CommandInfo

java.lang.Object
  extended by javax.activation.CommandInfo

public class CommandInfo
extends Object

The CommandInfo class is used by CommandMap implementations to describe the results of command requests. It provides the requestor with both the verb requested, as well as an instance of the bean. There is also a method that will return the name of the class that implements the command but it is not guaranteed to return a valid value. The reason for this is to allow CommandMap implmentations that subclass CommandInfo to provide special behavior. For example a CommandMap could dynamically generate JavaBeans. In this case, it might not be possible to create an object with all the correct state information solely from the class name.


构造器摘要
CommandInfo(String verb, String className)
          The Constructor for CommandInfo.
 
方法摘要
 String getCommandClass()
          Return the command's class name.
 String getCommandName()
          Return the command verb.
 Object getCommandObject(DataHandler dh, ClassLoader loader)
          Return the instantiated JavaBean component.
 
类方法继承 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造器详细信息

CommandInfo

public CommandInfo(String verb,
                   String className)
The Constructor for CommandInfo.

参数:
verb - The command verb this CommandInfo decribes.
className - The command's fully qualified class name.

方法详细信息

getCommandName

public String getCommandName()
Return the command verb.

返回:
the command verb.

getCommandClass

public String getCommandClass()
Return the command's class name. This method MAY return null in cases where a CommandMap subclassed CommandInfo for its own purposes. In other words, it might not be possible to create the correct state in the command by merely knowing its class name. DO NOT DEPEND ON THIS METHOD RETURNING A VALID VALUE!

返回:
The class name of the command, or null

getCommandObject

public Object getCommandObject(DataHandler dh,
                               ClassLoader loader)
                        throws IOException,
                               ClassNotFoundException
Return the instantiated JavaBean component.

Begin by instantiating the component with Beans.instantiate().

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.
返回:
The bean
抛出异常:
IOException
ClassNotFoundException
另请参见:
Beans.instantiate(java.lang.ClassLoader, java.lang.String), CommandObject

Java EE 5 SDK

深圳电信培训中心.徐海蛟老师.


提交错误或意见

版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。深圳电信培训中心.徐海蛟老师教学参考.