RemoteCommandHandler

public final class RemoteCommandHandler

RemoteCommandHandler is a handler class for invoking the RemoteCommand bean. It invokes the bean by using the command name and parameters specified by the caller. The given command must be registered beforehand on both side with a set of command properties in Java properties format:

Key Value
url The connection URL (see EjbConnection)
username The username for the connection
password The password for the connection
class The class name/object to be excuted
method The method of the class to be excuted
parameters The parameter types, separated by comma, of the method to be excuted

If it fails to invoke the bean, it will invoke the target class locally.

Author:Hugo Y. K. Lam

See also: RemoteCommandBean, EjbConnection

Methods

execute

public static Object execute(String cmdName, Object[] parameters)

Executes a registered command with the given parameters.

Parameters:
  • cmdName – the command name.
  • parameters – parameters for the target method invocation.
Throws:
  • RemoteException – if there is a remote exception occurred.
  • InstanceException – if the instance of the target class cannot be created or the method could not be invoked.
  • InvocationTargetException – if the invoked method has thrown an exception.
  • NullPointerException – if the command is not registered.
Returns:

the object returned by the invoked method.

executeLocal

static Object executeLocal(String cmdName, Object[] parameters)

Executes a registered command locally with the given parameters.

Parameters:
  • cmdName – the command name.
  • parameters – parameters for the target method invocation.
Throws:
  • InstanceException – if the instance of the target class cannot be created or the method could not be invoked.
  • InvocationTargetException – if the invoked method has thrown an exception.
  • NullPointerException – if the command is not registered.
Returns:

the object returned by the invoked method.

getCommand

public static Properties getCommand(String name)

Gets the command properties by its name.

Parameters:
  • name – the command name.
Throws:
Returns:

the command properties.

getCommandNames

public static Enumeration getCommandNames()

Gets the names of the regsitered commands.

Returns:the names of the regsitered commands.

register

public static void register(String cmdName, Properties command)

Register a command to this handler.

Parameters:
  • cmdName – the command name.
  • command – the command properties.

unregister

public static void unregister(String cmdName)

Unregister a command from this handler.

Parameters:
  • cmdName – the command name.