Websphere commerce controller command and task commands are registered in command registry framework.
Interfacename
MyControllerCmd --> extends --> com.ibm.commerce.commands.ControllerCommand
Implementation class:
MyControllerCmdImpl --> extends --> com.ibm.commerce.commands.ControllerCommandImpl
and
MyControllerCmdImpl implements MyControllerCmd
CommandFactory is a bean used for instantiating commands in websphere commerce.
Ex:
MyControllerCmd myCmd = null;
myCmd = (MyControllerCmd) CommandFactory.CreateCommand(com.ibm.commerce.myCommands.MyControllerCmd, getStoreId());
myCmd.setComandContext(getCommandContext());
myCmd.setRequestProperties(this.requestProperties);
myCmd.execute();
Where this.requestProperties is a TypedProperty object has all the request properties set.
There are 2 ways of defining implementation class for the inteface in websphere commerce:
1) defaultCommandClassName -The implementation class for the interface is defined in the interface by defaultCommandClassname
Ex:
public interface MyControllerCmd extends ControllerCommand {
public Static final String defaultCommandClassName = com.ibm.commerce.myCommands.MyControllerCmdImpl;
}
2) CMDREG entry- Command Registry
This table has following columns:
STORE_ID- 0 if the same implementation command is used for all the stores.
INTERFACENAME- Name of the interface
CLASSNAME - implementation class name
DESCRIPTION - short description about the command
PROPERTIES - properties that are to be passed to command
CMDREG is preferred when different implementation classes are used for different stores. i.e the logic implementation changes based on the storeID
If suppose there is different entry in defaultCommandClassName and CMDREG table for the implementation class then Command Registry takes the precedence.
Simillarly for the taskcommands
Interfacename
myTaskCommand extends --> com.ibm.commerce.commands.TaskCommand
Implementation class:
myTaskCommandImpl extends --> com.ibm.commerce.commands.TaskCommandImpl
and
myTaskCommandImpl implements myTaskCommand
Imp Points:
Differences between controller command and task command:
Interfacename
MyControllerCmd --> extends --> com.ibm.commerce.commands.ControllerCommand
Implementation class:
MyControllerCmdImpl --> extends --> com.ibm.commerce.commands.ControllerCommandImpl
and
MyControllerCmdImpl implements MyControllerCmd
CommandFactory is a bean used for instantiating commands in websphere commerce.
Ex:
MyControllerCmd myCmd = null;
myCmd = (MyControllerCmd) CommandFactory.CreateCommand(com.ibm.commerce.myCommands.MyControllerCmd, getStoreId());
myCmd.setComandContext(getCommandContext());
myCmd.setRequestProperties(this.requestProperties);
myCmd.execute();
Where this.requestProperties is a TypedProperty object has all the request properties set.
There are 2 ways of defining implementation class for the inteface in websphere commerce:
1) defaultCommandClassName -The implementation class for the interface is defined in the interface by defaultCommandClassname
Ex:
public interface MyControllerCmd extends ControllerCommand {
public Static final String defaultCommandClassName = com.ibm.commerce.myCommands.MyControllerCmdImpl;
}
2) CMDREG entry- Command Registry
This table has following columns:
STORE_ID- 0 if the same implementation command is used for all the stores.
INTERFACENAME- Name of the interface
CLASSNAME - implementation class name
DESCRIPTION - short description about the command
PROPERTIES - properties that are to be passed to command
CMDREG is preferred when different implementation classes are used for different stores. i.e the logic implementation changes based on the storeID
If suppose there is different entry in defaultCommandClassName and CMDREG table for the implementation class then Command Registry takes the precedence.
Simillarly for the taskcommands
Interfacename
myTaskCommand extends --> com.ibm.commerce.commands.TaskCommand
Implementation class:
myTaskCommandImpl extends --> com.ibm.commerce.commands.TaskCommandImpl
and
myTaskCommandImpl implements myTaskCommand
Imp Points:
- A controller command and task command both can be called from a controller command.
- A task command can call a taskcommand and even controller command.
- Both task command and controller command can have entry in CMDREG table.
Differences between controller command and task command:
Controller Command
|
Task Command
|
This is the entry point for fulfilling any request
|
This contains a part f business logic to be executed
|
This has struts entry
|
This cannot have an entry in struts file
|
Access Control policy (ACP) is enabled by default
|
ACP is not enabled
|
It has a viewname entry for redirecting the flow to the
viewname after successful execution
|
It does not have viewname, the control is returned back to
the called command.
|
Can be called from JSP
|
Cannot be called from JSP
|
No comments:
Post a Comment