org.apache.directory.mitosis.operation
Class Operation

java.lang.Object
  extended by org.apache.directory.mitosis.operation.Operation
All Implemented Interfaces:
java.io.Externalizable, java.io.Serializable
Direct Known Subclasses:
AddEntryOperation, AttributeOperation, CompositeOperation

public class Operation
extends java.lang.Object
implements java.io.Externalizable

Represents an operation performed on one or more entries in replicated Partition. Each Operation has its own CSN which identifies itself.

An Operation is usually created by calling factory methods in OperationFactory, which produces a CompositeOperation of smaller multiple operations. For example, OperationFactory.newDelete(LdapDN) returns a CompositeOperation which consists of two ReplaceAttributeOperations; one updates Constants.ENTRY_CSN attribute and the other updates Constants.ENTRY_DELETED. Refer to OperationFactory to find out what LDAP/JNDI operation is translated into what Operation instance.

Author:
Apache Directory Project
See Also:
Serialized Form

Field Summary
protected  CSN csn
          The entry CSN
protected  OperationType operationType
          The operation type
protected  Registries registries
          A reference on the server registries
 
Constructor Summary
protected Operation(Registries registries, OperationType operationType, CSN csn)
          Creates a new instance of Operation, for the entry which csn is given as a parameter.
 
Method Summary
static Operation deserialize(Registries registries, java.io.ObjectInput in)
          Deserialize an operation.
 void execute(PartitionNexus nexus, ReplicationStore store, CoreSession coreSession)
          Replicates this operation on the specified nexus.
protected  void execute0(PartitionNexus nexus, ReplicationStore store, CoreSession coreSession)
          Not supported.
 CSN getCSN()
           
 void readExternal(java.io.ObjectInput in)
          Read the CSN from an input stream
static void serialize(Operation operation, java.io.ObjectOutput out)
          Serialize an operation.
 java.lang.String toString()
           
 void writeExternal(java.io.ObjectOutput out)
          Write the CSN to an output stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

csn

protected CSN csn
The entry CSN


operationType

protected OperationType operationType
The operation type


registries

protected Registries registries
A reference on the server registries

Constructor Detail

Operation

protected Operation(Registries registries,
                    OperationType operationType,
                    CSN csn)
Creates a new instance of Operation, for the entry which csn is given as a parameter.

Parameters:
registries - the server registries
operationType - the operation type
csn - The entry's csn.
Method Detail

getCSN

public CSN getCSN()
Returns:
Returns CSN for this operation.

execute

public final void execute(PartitionNexus nexus,
                          ReplicationStore store,
                          CoreSession coreSession)
                   throws java.lang.Exception
Replicates this operation on the specified nexus.

Parameters:
nexus - the partition nexus
store - the replication store
coreSession - the current session
Throws:
java.lang.Exception

execute0

protected void execute0(PartitionNexus nexus,
                        ReplicationStore store,
                        CoreSession coreSession)
                 throws java.lang.Exception
Not supported. We should neve call this method directly.

Parameters:
nexus - the partition nexus
store - the replication store
coreSession - the current session
Throws:
java.lang.Exception

deserialize

public static Operation deserialize(Registries registries,
                                    java.io.ObjectInput in)
                             throws java.lang.ClassNotFoundException,
                                    java.io.IOException
Deserialize an operation. This is a recursive method, as we may have composite operations.

Parameters:
registries - The server registries
in - the stream wrom which we will read an operation
Returns:
an operation
Throws:
java.lang.ClassNotFoundException
java.io.IOException

serialize

public static void serialize(Operation operation,
                             java.io.ObjectOutput out)
                      throws java.lang.ClassNotFoundException,
                             java.io.IOException
Serialize an operation. This is a recursive method, as an operation can be composite.

Parameters:
operation - the operation to serialize
out - the stream into which the resulting serialized operation will be stored
Throws:
java.lang.ClassNotFoundException
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.lang.ClassNotFoundException,
                         java.io.IOException
Read the CSN from an input stream

Specified by:
readExternal in interface java.io.Externalizable
Parameters:
in - the input stream
Throws:
java.lang.ClassNotFoundException - if the read object is not a CSN
java.io.IOException - if we can't read from the input stream

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Write the CSN to an output stream

Specified by:
writeExternal in interface java.io.Externalizable
Parameters:
out - the output stream in which the CSN is written
Throws:
java.io.IOException - if we can't write to the stream

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
See Also:
Object.toString()


Copyright © 2003-2009 Apache Software Foundation. All Rights Reserved.