org.elkoserver.server.workshop.bank
Class BankWorker

java.lang.Object
  extended by org.elkoserver.server.workshop.WorkerObject
      extended by org.elkoserver.server.workshop.bank.BankWorker
All Implemented Interfaces:
DispatchTarget, Encodable, Referenceable

public class BankWorker
extends WorkerObject

Workshop worker object for the bank service.


Constructor Summary
BankWorker(OptString serviceName, String bankRef)
          JSON-driven constructor.
 
Method Summary
 void activate()
          Activate the bank service.
 void cancelkey(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String cancel)
          Message handler for the 'cancelkey' request: invalidate an existing key.
 void deleteaccount(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String account)
          Message handler for the 'deleteaccount' request: destroy an account.
 void dupkey(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, OptString optExpires)
          Message handler for the 'dupkey' request: make a separately cancellable copy of an existing key.
 void encumber(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String src, int amount, String expiresStr)
          Message handler for the 'encumber' request: reserve money in an account for a future transaction.
 void freezeaccount(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String account)
          Message handler for the 'freezeaccount' request: block an account from participating in transactions.
 void issuerootkey(WorkshopActor from, OptString xid, OptString rep, OptString memo)
          Message handler for the 'issuerootkey' request: obtain the bank's root key for the first time.
 void makeaccounts(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String[] currs, String owner)
          Message handler for the 'makeaccounts' request: create new accounts.
 void makecurrency(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String curr)
          Message handler for the 'makecurrency' request: create a new currency.
 void makekey(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String auth, String[] currs, OptString optExpires)
          Message handler for the 'makekey' request: create a new key.
 void mint(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String dst, int amount)
          Message handler for the 'mint' request: create money and deposit it in an account.
 void queryaccounts(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String[] accounts, OptBoolean encs)
          Message handler for the 'queryaccounts' request: obtain information about one or more accounts.
 void querycurrencies(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo)
          Message handler for the 'querycurrencies' request: obtain information about existing currencies.
 void queryenc(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String encRef)
          Message handler for the 'queryenc' request: obtain information about an encumbrance.
 void releaseenc(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String encRef)
          Message handler for the 'releaseenc' request: release an encumbrance on an account, making the funds once again available to the account owner.
 void unfreezeaccount(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String account)
          Message handler for the 'unfreezeaccount' request: remove the blockage on a previously frozen account.
 void unmint(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String src, int amount)
          Message handler for the 'unmint' request: remove money from an account and then destroy it.
 void unmintenc(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String encRef)
          Message handler for the 'unmint' request: redeem an encumbrance by destroying the encumbered funds
 void xfer(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String src, String dst, int amount)
          Message handler for the 'xfer' request: transfer money from one account to another.
 void xferenc(WorkshopActor from, String key, OptString xid, OptString rep, OptString memo, String dst, String encRef)
          Message handler for the 'xferenc' request: redeem an encumbrance by transferring the encumbered funds to some other account
 
Methods inherited from class org.elkoserver.server.workshop.WorkerObject
encode, ref, workshop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BankWorker

@JSONMethod(value={"service","bank"})
public BankWorker(OptString serviceName,
                                  String bankRef)
JSON-driven constructor.

Parameters:
serviceName - The name by which this worker object will be addressed. If omitted, it defaults to "bank".
bankRef - Reference string for the persistent bank object that this worker object provides the interface to.
Method Detail

activate

public void activate()
Activate the bank service.

Overrides:
activate in class WorkerObject

issuerootkey

@JSONMethod(value={"xid","rep","memo"})
public void issuerootkey(WorkshopActor from,
                                         OptString xid,
                                         OptString rep,
                                         OptString memo)
                  throws MessageHandlerException
Message handler for the 'issuerootkey' request: obtain the bank's root key for the first time.

Parameters:
from - The sender of the request.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
Throws:
MessageHandlerException

xfer

@JSONMethod(value={"key","xid","rep","memo","src","dst","amount"})
public void xfer(WorkshopActor from,
                                 String key,
                                 OptString xid,
                                 OptString rep,
                                 OptString memo,
                                 String src,
                                 String dst,
                                 int amount)
          throws MessageHandlerException
Message handler for the 'xfer' request: transfer money from one account to another.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
src - Ref of transfer source account.
dst - Ref of transfer destination account.
amount - Quantity of money to transfer.
Throws:
MessageHandlerException

mint

@JSONMethod(value={"key","xid","rep","memo","dst","amount"})
public void mint(WorkshopActor from,
                                 String key,
                                 OptString xid,
                                 OptString rep,
                                 OptString memo,
                                 String dst,
                                 int amount)
          throws MessageHandlerException
Message handler for the 'mint' request: create money and deposit it in an account.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
dst - Ref of destination account for new money.
amount - Quantity of money to create.
Throws:
MessageHandlerException

unmint

@JSONMethod(value={"key","xid","rep","memo","src","amount"})
public void unmint(WorkshopActor from,
                                   String key,
                                   OptString xid,
                                   OptString rep,
                                   OptString memo,
                                   String src,
                                   int amount)
            throws MessageHandlerException
Message handler for the 'unmint' request: remove money from an account and then destroy it.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
src - Ref of the account from which the money should be taken.
amount - Quantity of money to destroy.
Throws:
MessageHandlerException

encumber

@JSONMethod(value={"key","xid","rep","memo","src","amount","expires"})
public void encumber(WorkshopActor from,
                                     String key,
                                     OptString xid,
                                     OptString rep,
                                     OptString memo,
                                     String src,
                                     int amount,
                                     String expiresStr)
              throws MessageHandlerException
Message handler for the 'encumber' request: reserve money in an account for a future transaction.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
src - Ref of account whose funds are to be encumbered.
amount - Quantity of money to encumber.
expiresStr - Date after which the encumbrance will be released.
Throws:
MessageHandlerException

releaseenc

@JSONMethod(value={"key","xid","rep","memo","enc"})
public void releaseenc(WorkshopActor from,
                                       String key,
                                       OptString xid,
                                       OptString rep,
                                       OptString memo,
                                       String encRef)
                throws MessageHandlerException
Message handler for the 'releaseenc' request: release an encumbrance on an account, making the funds once again available to the account owner.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
encRef - Ref of the encumbrance to release.
Throws:
MessageHandlerException

xferenc

@JSONMethod(value={"key","xid","rep","memo","dst","enc"})
public void xferenc(WorkshopActor from,
                                    String key,
                                    OptString xid,
                                    OptString rep,
                                    OptString memo,
                                    String dst,
                                    String encRef)
             throws MessageHandlerException
Message handler for the 'xferenc' request: redeem an encumbrance by transferring the encumbered funds to some other account

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
dst - Ref of transfer destination account.
encRef - Ref of the encumbrance that will be the source of funds.
Throws:
MessageHandlerException

unmintenc

@JSONMethod(value={"key","xid","rep","memo","enc"})
public void unmintenc(WorkshopActor from,
                                      String key,
                                      OptString xid,
                                      OptString rep,
                                      OptString memo,
                                      String encRef)
               throws MessageHandlerException
Message handler for the 'unmint' request: redeem an encumbrance by destroying the encumbered funds

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
encRef - Ref of the encumbrance that will be the source of funds.
Throws:
MessageHandlerException

queryenc

@JSONMethod(value={"key","xid","rep","memo","enc"})
public void queryenc(WorkshopActor from,
                                     String key,
                                     OptString xid,
                                     OptString rep,
                                     OptString memo,
                                     String encRef)
              throws MessageHandlerException
Message handler for the 'queryenc' request: obtain information about an encumbrance.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
encRef - Ref of the encumbrance that is of interest.
Throws:
MessageHandlerException

makeaccounts

@JSONMethod(value={"key","xid","rep","memo","currs","owner"})
public void makeaccounts(WorkshopActor from,
                                         String key,
                                         OptString xid,
                                         OptString rep,
                                         OptString memo,
                                         String[] currs,
                                         String owner)
                  throws MessageHandlerException
Message handler for the 'makeaccounts' request: create new accounts. This will create one new account for each currency specified.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
currs - Currencies in which the new accounts will be denominated.
owner - Ref of the user who is to be the owner of the new account.
Throws:
MessageHandlerException

deleteaccount

@JSONMethod(value={"key","xid","rep","memo","account"})
public void deleteaccount(WorkshopActor from,
                                          String key,
                                          OptString xid,
                                          OptString rep,
                                          OptString memo,
                                          String account)
                   throws MessageHandlerException
Message handler for the 'deleteaccount' request: destroy an account.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
account - Ref of the account that is to be deleted.
Throws:
MessageHandlerException

queryaccounts

@JSONMethod(value={"key","xid","rep","memo","accounts","encs"})
public void queryaccounts(WorkshopActor from,
                                          String key,
                                          OptString xid,
                                          OptString rep,
                                          OptString memo,
                                          String[] accounts,
                                          OptBoolean encs)
                   throws MessageHandlerException
Message handler for the 'queryaccounts' request: obtain information about one or more accounts.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
accounts - Refs of the accounts of interest
encs - Flag that is true if reply should include encumbrance info.
Throws:
MessageHandlerException

freezeaccount

@JSONMethod(value={"key","xid","rep","memo","account"})
public void freezeaccount(WorkshopActor from,
                                          String key,
                                          OptString xid,
                                          OptString rep,
                                          OptString memo,
                                          String account)
                   throws MessageHandlerException
Message handler for the 'freezeaccount' request: block an account from participating in transactions.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
account - Ref of the account to be frozen.
Throws:
MessageHandlerException

unfreezeaccount

@JSONMethod(value={"key","xid","rep","memo","account"})
public void unfreezeaccount(WorkshopActor from,
                                            String key,
                                            OptString xid,
                                            OptString rep,
                                            OptString memo,
                                            String account)
                     throws MessageHandlerException
Message handler for the 'unfreezeaccount' request: remove the blockage on a previously frozen account.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optional reference to client object to reply to.
memo - Transaction annotation, for logging.
account - Ref of the account to be unfrozen.
Throws:
MessageHandlerException

makecurrency

@JSONMethod(value={"key","xid","rep","memo","curr"})
public void makecurrency(WorkshopActor from,
                                         String key,
                                         OptString xid,
                                         OptString rep,
                                         OptString memo,
                                         String curr)
                  throws MessageHandlerException
Message handler for the 'makecurrency' request: create a new currency.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
curr - Name for the new currency.
Throws:
MessageHandlerException

querycurrencies

@JSONMethod(value={"key","xid","rep","memo"})
public void querycurrencies(WorkshopActor from,
                                            String key,
                                            OptString xid,
                                            OptString rep,
                                            OptString memo)
                     throws MessageHandlerException
Message handler for the 'querycurrencies' request: obtain information about existing currencies.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
Throws:
MessageHandlerException

makekey

@JSONMethod(value={"key","xid","rep","memo","auth","currs","expires"})
public void makekey(WorkshopActor from,
                                    String key,
                                    OptString xid,
                                    OptString rep,
                                    OptString memo,
                                    String auth,
                                    String[] currs,
                                    OptString optExpires)
             throws MessageHandlerException
Message handler for the 'makekey' request: create a new key.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
auth - The desired authority of the new key.
currs - Optional currencies scoping the new key.
optExpires - Date after which the new key will become invalid.
Throws:
MessageHandlerException

cancelkey

@JSONMethod(value={"key","xid","rep","memo","cancel"})
public void cancelkey(WorkshopActor from,
                                      String key,
                                      OptString xid,
                                      OptString rep,
                                      OptString memo,
                                      String cancel)
               throws MessageHandlerException
Message handler for the 'cancelkey' request: invalidate an existing key.

Parameters:
from - The sender of the request.
key - Key from authorizing access.
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
cancel - Ref of the key to be cancelled.
Throws:
MessageHandlerException

dupkey

@JSONMethod(value={"key","xid","rep","memo","expires"})
public void dupkey(WorkshopActor from,
                                   String key,
                                   OptString xid,
                                   OptString rep,
                                   OptString memo,
                                   OptString optExpires)
            throws MessageHandlerException
Message handler for the 'dupkey' request: make a separately cancellable copy of an existing key.

Parameters:
from - The sender of the request.
key - Key from authorizing access (which will be copied).
xid - Optional client-side response tag.
rep - Optioanl reference to client object to reply to.
memo - Transaction annotation, for logging.
optExpires - Date after which the new key will become invalid.
Throws:
MessageHandlerException