org.space4j
Class Command

java.lang.Object
  extended by org.space4j.Command
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CreateCollectionCmd, CreateMapCmd, CreateObjectCmd, CreateSequenceCmd, DropObjectCmd, DropSequenceCmd, IncrementSeqCmd, PutCmd, RemoveCmd

public abstract class Command
extends java.lang.Object
implements java.io.Serializable

A command representing an update to the Space4J database of objects in RAM. All clients must alter the Space through a Command, so they can be logged and reapplied later.

See Also:
Serialized Form

Constructor Summary
Command()
           
 
Method Summary
abstract  int execute(Space space)
          This method accesses the Space and its objects to do any modifications it wants.
 void executeSQL(java.sql.Connection conn)
          This method will let you replicate your data in a relational database, so you can continue creating your reports and using data data warehousing tools with SQL.
 long getLogNumber()
          This method is important when Space4J is replicated.
 long getReplicaId()
          This method is important when Space4J is replicated.
 void setLogNumber(long lognumber)
          Sets the log number where this command is stored.
 void setReplicaId(long replica_id)
          Sets the number of the replica this commands belongs to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Command

public Command()
Method Detail

execute

public abstract int execute(Space space)
                     throws CommandException
This method accesses the Space and its objects to do any modifications it wants.

Parameters:
space - The Space where the objects are stored.
Returns:
An int with the number of objects altered by this operation.
Throws:
CommandException - If there was an error executing this command.

executeSQL

public void executeSQL(java.sql.Connection conn)
                throws java.sql.SQLException
This method will let you replicate your data in a relational database, so you can continue creating your reports and using data data warehousing tools with SQL. Doing this with Space4J and Commands is possible, but not recommended at all. Note that this method is not abstract, therefore it is not required. It is up to the system to replicate its data in a relational database. Rodolfo de Paula was the first one to raise this issue! Why not have the best of both worlds?

Parameters:
conn - A connection to the database where this command will be executed through SQL.
Throws:
java.sql.SQLException - If there was an error executing the SQL.

getLogNumber

public long getLogNumber()
This method is important when Space4J is replicated. It tells the replicas in what log this command is stored. This will be very important when a replica wants to take a snapshot. It will need to know this number.

Returns:
The number of the log where this command is stored.

setLogNumber

public void setLogNumber(long lognumber)
Sets the log number where this command is stored.

Parameters:
lognumber - The log number where this command is stored.

getReplicaId

public long getReplicaId()
This method is important when Space4J is replicated. It tells from which replica this command came from. This will be very important when a replica has to wait for a command to return from the main replica.

Returns:
The unique id of the replica.

setReplicaId

public void setReplicaId(long replica_id)
Sets the number of the replica this commands belongs to.

Parameters:
replica_id - The unique id of the replica.


Copyright © 2005 Space4J Team. All Rights Reserved.