* @param type type of command (whether internal or user defined)
* @param cacheName cache name at which this command is directed
* @return an instance of {@link CacheRpcCommand}
*/
public CacheRpcCommand fromStream(byte id, Object[] parameters, byte type, String cacheName) {
CacheRpcCommand command;
if (type == 0) {
switch (id) {
case LockControlCommand.COMMAND_ID:
command = new LockControlCommand(cacheName);
break;
case PrepareCommand.COMMAND_ID:
command = new PrepareCommand(cacheName);
break;
case VersionedPrepareCommand.COMMAND_ID:
command = new VersionedPrepareCommand(cacheName);
break;
case TotalOrderNonVersionedPrepareCommand.COMMAND_ID:
command = new TotalOrderNonVersionedPrepareCommand(cacheName);
break;
case TotalOrderVersionedPrepareCommand.COMMAND_ID:
command = new TotalOrderVersionedPrepareCommand(cacheName);
break;
case CommitCommand.COMMAND_ID:
command = new CommitCommand(cacheName);
break;
case VersionedCommitCommand.COMMAND_ID:
command = new VersionedCommitCommand(cacheName);
break;
case TotalOrderCommitCommand.COMMAND_ID:
command = new TotalOrderCommitCommand(cacheName);
break;
case TotalOrderVersionedCommitCommand.COMMAND_ID:
command = new TotalOrderVersionedCommitCommand(cacheName);
break;
case RollbackCommand.COMMAND_ID:
command = new RollbackCommand(cacheName);
break;
case TotalOrderRollbackCommand.COMMAND_ID:
command = new TotalOrderRollbackCommand(cacheName);
break;
case MultipleRpcCommand.COMMAND_ID:
command = new MultipleRpcCommand(cacheName);
break;
case SingleRpcCommand.COMMAND_ID:
command = new SingleRpcCommand(cacheName);
break;
case ClusteredGetCommand.COMMAND_ID:
command = new ClusteredGetCommand(cacheName);
break;
case StateRequestCommand.COMMAND_ID:
command = new StateRequestCommand(cacheName);
break;
case StateResponseCommand.COMMAND_ID:
command = new StateResponseCommand(cacheName);
break;
case RemoveCacheCommand.COMMAND_ID:
command = new RemoveCacheCommand(cacheName, cacheManager, registry,
registry.getNamedComponentRegistry(cacheName).getComponent(PersistenceManager.class));
break;
case TxCompletionNotificationCommand.COMMAND_ID:
command = new TxCompletionNotificationCommand(cacheName);
break;
case GetInDoubtTransactionsCommand.COMMAND_ID:
command = new GetInDoubtTransactionsCommand(cacheName);
break;
case MapCombineCommand.COMMAND_ID:
command = new MapCombineCommand(cacheName);
break;
case ReduceCommand.COMMAND_ID:
command = new ReduceCommand(cacheName);
break;
case DistributedExecuteCommand.COMMAND_ID:
command = new DistributedExecuteCommand(cacheName);
break;
case GetInDoubtTxInfoCommand.COMMAND_ID:
command = new GetInDoubtTxInfoCommand(cacheName);
break;
case CompleteTransactionCommand.COMMAND_ID:
command = new CompleteTransactionCommand(cacheName);
break;
case CreateCacheCommand.COMMAND_ID:
command = new CreateCacheCommand(cacheName);
break;
case XSiteAdminCommand.COMMAND_ID:
command = new XSiteAdminCommand(cacheName);
break;
case CancelCommand.COMMAND_ID:
command = new CancelCommand(cacheName);
break;
case XSiteStateTransferControlCommand.COMMAND_ID:
command = new XSiteStateTransferControlCommand(cacheName);
break;
case XSiteStatePushCommand.COMMAND_ID:
command = new XSiteStatePushCommand(cacheName);
break;
case SingleXSiteRpcCommand.COMMAND_ID:
command = new SingleXSiteRpcCommand(cacheName);
break;
case EntryRequestCommand.COMMAND_ID:
command = new EntryRequestCommand(cacheName);
break;
case EntryResponseCommand.COMMAND_ID:
command = new EntryResponseCommand(cacheName);
break;
case PartitionStateControlCommand.COMMAND_ID:
command = new PartitionStateControlCommand(cacheName);
break;
default:
throw new CacheException("Unknown command id " + id + "!");
}
} else {
ExtendedModuleCommandFactory mcf = (ExtendedModuleCommandFactory) commandFactories.get(id);
if (mcf != null)
return mcf.fromStream(id, parameters, cacheName);
else
throw new CacheException("Unknown command id " + id + "!");
}
command.setParameters(id, parameters);
return command;
}