SOMA.network.connection
Class Command

java.lang.Object
  extended bySOMA.network.connection.Command
All Implemented Interfaces:
java.lang.Runnable, java.io.Serializable
Direct Known Subclasses:
AddChildInformationCommand, AgentTransportCommand, ClassRequestCommand, ConnectionCommand, DomainRefreshCommand, DomainRefreshCommand.Request, DomainRegisterCommand, GetCurrentPolicyCommand, GetGenericMetadataServiceCommand, GetNormalMetadataServiceCommand, GetPathCommand, GetProfileServiceInformationCommand, MobilePlaceConnectionCommand, MobilePlaceConnectionCommand.UpdateHomePositionCommand, MobilePlaceDisconnectionCommand, PlaceRefreshCommand, PlaceRefreshCommand.Request, PlaceRegisterCommand, PutDomainCommand, PutPlaceCommand, QuickCommand, RegisteredChildInformationCommand, RegisterPathCommand, RegisterProfileContainerInfoCommand, RemoveDomainCommand, RemovePlaceCommand, SendClassCommand, SendMessageCommand, SendMessageCommand, SetCurrentPolicyCommand, SetGenericMetadataServiceCommand, SetNormalMetadataServiceCommand, SetThresholdCommand, StopConnectionCommand, StopConnectionCommand.RemoveConnectionCommand, TransportCommand

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

Comando utilizzato per la comunicazione fra place diversi.

I comandi vengono spediti attraverso connessioni. Ricevuto il conmando, il place avvia il metodo start( Connection ReturnConnection, Environment env ).

Il metodo start, effettuate le necessarie inizializzazioni, crea un nuovo thread ed avvia il metodo run(), un metodo astratto che conterra' le operazioni svolte dal comando.

Per implementare un nuovo comando e' quindi sufficiente sottoclassare questa classe astratta e definire il metodo run().

Author:
Livio Profiri
See Also:
QuickCommand, Serialized Form

Field Summary
protected  Environment env
          Riferimento all'Environment del place.
protected  Connection ReturnConnection
          Connessione su cui spedire un eventuale comando di risposta.
 
Constructor Summary
Command()
           
 
Method Summary
 void Return(Command ReturnCommand)
          Spedisce un comando di risposta.
abstract  void run()
          Contiene la computazione che il comando deve svolgere.
 void start(Connection ReturnConnection, Environment env)
          Esegue il comando.
 boolean startOnError()
          Se restituisce true il comando viene eseguito anche in caso di errore.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ReturnConnection

protected transient Connection ReturnConnection
Connessione su cui spedire un eventuale comando di risposta.

See Also:
Return( Command ReturnCommand )

env

protected transient Environment env
Riferimento all'Environment del place.
E' necessario per poter accedere agli oggetti su cui il comando deve operare.

Constructor Detail

Command

public Command()
Method Detail

Return

public void Return(Command ReturnCommand)
Spedisce un comando di risposta.
Attenzione: si tratta di uno shortcut che non lancia eccezioni. Per gestire le eccezioni utilizzare:
ReturnConnection.send( ReturnCommand );


start

public void start(Connection ReturnConnection,
                  Environment env)

Esegue il comando.

Parameters:
ReturnConnection - inizializza ReturnConnection.
env - inizializza env.

Effettuate le inizializzazioni, crea un nuovo thread ed avvia il metodo run(), un metodo astratto che conterra' le operazioni svolte dal comando.

See Also:
QuickCommand

startOnError

public boolean startOnError()

Se restituisce true il comando viene eseguito anche in caso di errore.

Quando un comando viene spedito lungo un cammino multiplo, ad esempio un cammino che unisce place in domini diversi, è possibile che ad uno dei passaggi si verifichi un errore. In questo caso, se startOnError() restituisce true, TransportCommand avvia il comando anche se non è giunto a destinazione.

Nell'implementazione del comando, ridefinire questo metodo se si vuole che l'opzione sia attivata.


run

public abstract void run()
Contiene la computazione che il comando deve svolgere.
Questo metodo astratto va definito nelle implementazioni concrete dei comandi.

Specified by:
run in interface java.lang.Runnable


Copyright © 2004 Luca Foschini