Helper class for running commands

WebSphere Application Server ships a CommandTarget enterprise bean to enable administrators to run a command in a designated server without providing their own implementation of CommandTarget. The EJBCommandTarget class, along with the EJBCommandTarget bean (CommandServerSessionBean), are located in the EJBCommandTarget.jar file in the lib directory under the WebSphere Application Server installation directory. This is a deployed jar file. You can use this JAR file in a new application or add it into an existing application.

The EJBCommandTarget class serves as a wrapper for a CommandTarget bean. CommandServerSessionBean is the WebSphere Application Server implementation of this CommandTarget bean. A command developer can set this EJBCommandTarget object into the Command. The following is a code example of the EJBCommandTarget bean:
EJBCommandTarget target = new EJBCommandTarget();
MyCommand cmd = new MyCommandImpl(Arguments...);
cmd.setCommandTarget(target);
cmd.execute();

In the code example, the client creates a MyCommand object. It is then executed in the application server. When the execute method is run, the target (EJBCommandTarget) looks up the CommandServerSessionHome from the InitialContext and executes the executeCommand method on the CommandServerSessionBean. The EJBCommandTarget object ensures that there is only one CommandServerSessionBean per object to avoid extra naming lookup.

An EJBCommandTarget object can be created using four different constructors:

The first constructor enables the application to specify the naming server name and the port. The JNDI name of the CommandServerSessionBean can also be specified. The EJBCommandTarget constructs a iiop://MyNamingServerName:PortNumber provider URL and looks up the CommandServerSessionBean with the given JNDI name. If null values are passed in for any of the parameters, WebSphere Application Server defaults for server and port and a default JNDI name of CommandServerSession are used.

The second constructor enables the application to specify its own initial context. The EJBCommandTarget object then uses this initial context to look up the CommandServerSession bean with the specified JNDI name.

The third constructor enables the application to set up the naming server (the provider URL) in property files.

The default constructor uses the default values for the provider URL and default JNDI name for the CommandServerSession bean (CommandServerSession).

You do not need to use the EJBCommandTarget class. You can instead create your own custom target policy that uses the EJBCommandTarget bean (CommandServerSessionBean). The EJBCommandTarget object is a convenience class and attempts to address most usage scenarios.




Related tasks
Using a command
Concept topic Concept topic    

Terms and conditions for information centers | Feedback

Last updatedLast updated: Aug 30, 2013 10:47:11 PM CDT
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=pix&product=was-nd-iseries&topic=ccmd_wasejbcmdtarg
File name: ccmd_wasejbcmdtarg.html