edu.cuny.cat.registry
Class SimpleRegistry

java.lang.Object
  extended by edu.cuny.cat.registry.SimpleRegistry
All Implemented Interfaces:
AuctionEventListener, Registry

public class SimpleRegistry
extends java.lang.Object
implements Registry

Implements Registry by logging game information simply into internal data structures, in contrast to some external permanent storage.

Version:
$Revision: 1.72 $
Author:
Jinzhong Niu

Field Summary
protected  java.util.Map<java.lang.String,Specialist> activeSpecialists
           
protected  GameClock clock
           
protected  GameController controller
           
protected  java.util.Map<java.lang.String,Specialist> expectedSpecialists
           
protected  java.util.Map<java.lang.String,Specialist> failedSpecialists
           
protected  java.util.Map<java.lang.String,Trader> failedTraders
           
protected  java.util.Map<java.lang.String,Shout> shouts
           
protected  java.util.Map<java.lang.String,java.util.Set<java.lang.String>> subscriptions
           
protected  java.util.Map<java.lang.String,Transaction> transactions
           
protected  java.util.Map<java.lang.String,Specialist> workingSpecialists
           
protected  java.util.Map<java.lang.String,Trader> workingTraders
           
 
Constructor Summary
SimpleRegistry()
           
 
Method Summary
 void addExpectedSpecialist(Specialist specialist)
           
protected  void addFailedClient(AccountHolder client)
           
 boolean containsSpecialist(java.lang.String specialistId)
           
 boolean containsTrader(java.lang.String traderId)
           
 boolean containsWorkingSpecialist(java.lang.String specialistId)
           
 boolean containsWorkingTrader(java.lang.String traderId)
           
 void eventOccurred(AuctionEvent event)
           
 Specialist getActiveSpecialist(java.lang.String specialistId)
           
 Specialist[] getActiveSpecialists()
           
 java.lang.String getBrokerId(java.lang.String traderId)
           
 java.lang.String getClientStatInfo()
           
 Specialist getExpectedSpecialist(java.lang.String id)
           
 AccountHolder getFailedClient(java.lang.String id)
           
 int getNumOfActiveSpecialists()
           
 int getNumOfClients()
           
 int getNumOfSpecialists()
           
 int getNumOfTraders()
           
 int getNumOfWorkingClients()
           
 int getNumOfWorkingSpecialists()
           
 int getNumOfWorkingTraders()
           
 Shout getShout(java.lang.String shoutId)
           
 Shout[] getShouts()
           
 Specialist getSpecialist(java.lang.String specialistId)
           
 java.lang.String[] getSpecialistIds()
           
 Specialist[] getSpecialists()
           
 java.lang.String[] getSubscriberIds(java.lang.String specialistId)
           
 Trader getTrader(java.lang.String traderId)
           
 java.lang.String[] getTraderIds()
           
 Trader[] getTraders()
           
 Transaction getTransaction(java.lang.String transactionId)
           
 Transaction[] getTransactions()
           
 Specialist getWorkingSpecialist(java.lang.String specialistId)
           
 java.lang.String[] getWorkingSpecialistIds()
           
 Specialist[] getWorkingSpecialists()
           
 Trader getWorkingTrader(java.lang.String traderId)
           
 java.lang.String[] getWorkingTraderIds()
           
 Trader[] getWorkingTraders()
           
protected  void processClientStatusUpdated(ClientStateUpdatedEvent event)
           
protected  void processDayClosed(DayClosedEvent event)
           
protected  void processDayOpened(DayOpenedEvent event)
           
protected  void processDayOpening(DayOpeningEvent event)
           
protected  void processFeesAnnounced(FeesAnnouncedEvent event)
           
protected  void processFundTransfer(FundTransferEvent event)
           
protected  void processGameOver(GameOverEvent event)
           
protected  void processGameStarted(GameStartedEvent event)
           
protected  void processGameStarting(GameStartingEvent event)
           
protected  void processPrivateValueAssigned(PrivateValueAssignedEvent event)
           
protected  void processRegistration(RegistrationEvent event)
           
protected  void processRoundClosed(RoundClosedEvent event)
           
protected  void processRoundClosing(RoundClosingEvent event)
           
protected  void processRoundOpened(RoundOpenedEvent event)
           
protected  void processShoutPlaced(ShoutPlacedEvent event)
          TODO: shout related event processing changes shout directly, which however may have negative effects on processing in game reports etc.
protected  void processShoutReceived(ShoutReceivedEvent event)
           
protected  void processShoutRejected(ShoutRejectedEvent event)
           
protected  void processSimulationOver(SimulationOverEvent event)
           
protected  void processSimulationStarted(SimulationStartedEvent event)
           
protected  void processSpecialistCheckIn(SpecialistCheckInEvent event)
           
protected  void processSubscription(SubscriptionEvent event)
           
protected  void processTraderCheckIn(TraderCheckInEvent event)
           
protected  void processTransactionExecuted(TransactionExecutedEvent event)
           
protected  void restoreFailedClient(AccountHolder client)
           
 void start()
           
 void stop()
           
 java.lang.String toString()
           
protected  void transferFund(AccountHolder payer, AccountHolder payee, java.lang.String type, double amount, int quantity)
           
protected  void welcomeExpectedSpecialist(Specialist specialist)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

workingTraders

protected java.util.Map<java.lang.String,Trader> workingTraders

workingSpecialists

protected java.util.Map<java.lang.String,Specialist> workingSpecialists

failedTraders

protected java.util.Map<java.lang.String,Trader> failedTraders

failedSpecialists

protected java.util.Map<java.lang.String,Specialist> failedSpecialists

expectedSpecialists

protected java.util.Map<java.lang.String,Specialist> expectedSpecialists

activeSpecialists

protected java.util.Map<java.lang.String,Specialist> activeSpecialists

shouts

protected java.util.Map<java.lang.String,Shout> shouts

transactions

protected java.util.Map<java.lang.String,Transaction> transactions

subscriptions

protected java.util.Map<java.lang.String,java.util.Set<java.lang.String>> subscriptions

controller

protected GameController controller

clock

protected GameClock clock
Constructor Detail

SimpleRegistry

public SimpleRegistry()
Method Detail

addExpectedSpecialist

public void addExpectedSpecialist(Specialist specialist)
Specified by:
addExpectedSpecialist in interface Registry

welcomeExpectedSpecialist

protected void welcomeExpectedSpecialist(Specialist specialist)

addFailedClient

protected void addFailedClient(AccountHolder client)

restoreFailedClient

protected void restoreFailedClient(AccountHolder client)

transferFund

protected void transferFund(AccountHolder payer,
                            AccountHolder payee,
                            java.lang.String type,
                            double amount,
                            int quantity)
Parameters:
payer - the party to pay money for buying goods or service
payee - the party to receive money for selling goods or service
type - the type of the monetary transaction
amount - the amount to be paid for one unit of goods or service
quantity - units of goods or times of service

eventOccurred

public void eventOccurred(AuctionEvent event)
Specified by:
eventOccurred in interface AuctionEventListener

processFundTransfer

protected void processFundTransfer(FundTransferEvent event)

processRoundClosing

protected void processRoundClosing(RoundClosingEvent event)

processRoundClosed

protected void processRoundClosed(RoundClosedEvent event)

processDayClosed

protected void processDayClosed(DayClosedEvent event)

processRoundOpened

protected void processRoundOpened(RoundOpenedEvent event)

processDayOpening

protected void processDayOpening(DayOpeningEvent event)

processDayOpened

protected void processDayOpened(DayOpenedEvent event)

processGameOver

protected void processGameOver(GameOverEvent event)

processGameStarting

protected void processGameStarting(GameStartingEvent event)

processGameStarted

protected void processGameStarted(GameStartedEvent event)

processPrivateValueAssigned

protected void processPrivateValueAssigned(PrivateValueAssignedEvent event)

processSubscription

protected void processSubscription(SubscriptionEvent event)

processTraderCheckIn

protected void processTraderCheckIn(TraderCheckInEvent event)

processSpecialistCheckIn

protected void processSpecialistCheckIn(SpecialistCheckInEvent event)

processShoutPlaced

protected void processShoutPlaced(ShoutPlacedEvent event)
TODO: shout related event processing changes shout directly, which however may have negative effects on processing in game reports etc. as Kai pointed out


processShoutRejected

protected void processShoutRejected(ShoutRejectedEvent event)

processShoutReceived

protected void processShoutReceived(ShoutReceivedEvent event)

processTransactionExecuted

protected void processTransactionExecuted(TransactionExecutedEvent event)

processFeesAnnounced

protected void processFeesAnnounced(FeesAnnouncedEvent event)

processRegistration

protected void processRegistration(RegistrationEvent event)

processSimulationStarted

protected void processSimulationStarted(SimulationStartedEvent event)

processSimulationOver

protected void processSimulationOver(SimulationOverEvent event)

processClientStatusUpdated

protected void processClientStatusUpdated(ClientStateUpdatedEvent event)

getWorkingTraderIds

public java.lang.String[] getWorkingTraderIds()
Specified by:
getWorkingTraderIds in interface Registry

getWorkingSpecialistIds

public java.lang.String[] getWorkingSpecialistIds()
Specified by:
getWorkingSpecialistIds in interface Registry

getWorkingSpecialist

public Specialist getWorkingSpecialist(java.lang.String specialistId)
Specified by:
getWorkingSpecialist in interface Registry

getWorkingTrader

public Trader getWorkingTrader(java.lang.String traderId)
Specified by:
getWorkingTrader in interface Registry

getWorkingSpecialists

public Specialist[] getWorkingSpecialists()
Specified by:
getWorkingSpecialists in interface Registry

getActiveSpecialists

public Specialist[] getActiveSpecialists()
Specified by:
getActiveSpecialists in interface Registry
Returns:
a list of specialists that are available for traders to do business with

getActiveSpecialist

public Specialist getActiveSpecialist(java.lang.String specialistId)
Specified by:
getActiveSpecialist in interface Registry

getWorkingTraders

public Trader[] getWorkingTraders()
Specified by:
getWorkingTraders in interface Registry

getFailedClient

public AccountHolder getFailedClient(java.lang.String id)
Specified by:
getFailedClient in interface Registry

getExpectedSpecialist

public Specialist getExpectedSpecialist(java.lang.String id)
Specified by:
getExpectedSpecialist in interface Registry

getShout

public Shout getShout(java.lang.String shoutId)
Specified by:
getShout in interface Registry

getShouts

public Shout[] getShouts()
Specified by:
getShouts in interface Registry

getTransaction

public Transaction getTransaction(java.lang.String transactionId)
Specified by:
getTransaction in interface Registry

getTransactions

public Transaction[] getTransactions()
Specified by:
getTransactions in interface Registry

getBrokerId

public java.lang.String getBrokerId(java.lang.String traderId)
Specified by:
getBrokerId in interface Registry

containsWorkingSpecialist

public boolean containsWorkingSpecialist(java.lang.String specialistId)

containsWorkingTrader

public boolean containsWorkingTrader(java.lang.String traderId)

getSubscriberIds

public java.lang.String[] getSubscriberIds(java.lang.String specialistId)
Specified by:
getSubscriberIds in interface Registry

start

public void start()
Specified by:
start in interface Registry

stop

public void stop()
Specified by:
stop in interface Registry

getNumOfClients

public int getNumOfClients()
Specified by:
getNumOfClients in interface Registry

getNumOfSpecialists

public int getNumOfSpecialists()
Specified by:
getNumOfSpecialists in interface Registry

getNumOfActiveSpecialists

public int getNumOfActiveSpecialists()
Specified by:
getNumOfActiveSpecialists in interface Registry

getNumOfTraders

public int getNumOfTraders()
Specified by:
getNumOfTraders in interface Registry

getTrader

public Trader getTrader(java.lang.String traderId)
Specified by:
getTrader in interface Registry

getTraders

public Trader[] getTraders()
Specified by:
getTraders in interface Registry

getNumOfWorkingTraders

public int getNumOfWorkingTraders()
Specified by:
getNumOfWorkingTraders in interface Registry

getNumOfWorkingSpecialists

public int getNumOfWorkingSpecialists()
Specified by:
getNumOfWorkingSpecialists in interface Registry

getSpecialist

public Specialist getSpecialist(java.lang.String specialistId)
Specified by:
getSpecialist in interface Registry

getSpecialistIds

public java.lang.String[] getSpecialistIds()
Specified by:
getSpecialistIds in interface Registry

getSpecialists

public Specialist[] getSpecialists()
Specified by:
getSpecialists in interface Registry

getTraderIds

public java.lang.String[] getTraderIds()
Specified by:
getTraderIds in interface Registry

containsSpecialist

public boolean containsSpecialist(java.lang.String specialistId)
Specified by:
containsSpecialist in interface Registry

containsTrader

public boolean containsTrader(java.lang.String traderId)
Specified by:
containsTrader in interface Registry

getNumOfWorkingClients

public int getNumOfWorkingClients()
Specified by:
getNumOfWorkingClients in interface Registry

getClientStatInfo

public java.lang.String getClientStatInfo()
Specified by:
getClientStatInfo in interface Registry
Returns:
a String including numbers of clients dead and alive.

toString

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