@ThreadSafe
public class ContractManager
extends java.lang.Object
ContractEntry
s in a ContractRegistry
, retrieve ContractEntry
s, instantiate ContractMachine
s from their ids, and also validate contracts
(i.e. check if the contract is registered with the correct signature).Constructor and Description |
---|
ContractManager(ContractRegistry registry,
ContractLoader loader,
ClientKeyValidator clientKeyValidator) |
ContractManager(ContractRegistry registry,
ContractLoader loader,
ClientKeyValidator clientKeyValidator,
com.google.common.cache.Cache<ContractEntry.Key,java.lang.Object> recentlyValidated) |
Modifier and Type | Method and Description |
---|---|
ContractEntry |
get(ContractEntry.Key key)
Returns a
ContractEntry . |
ContractMachine |
getInstance(ContractEntry entry)
Instantiates a
ContractMachine from the specified contract entry. |
void |
register(ContractEntry entry)
Stores a
ContractEntry in a ContractRegistry . |
java.util.List<ContractEntry> |
scan(java.lang.String entityId,
int keyVersion)
Returns a list of all the
ContractEntry s of a specific version registered by a
specified entity id. |
@Inject public ContractManager(ContractRegistry registry, ContractLoader loader, ClientKeyValidator clientKeyValidator)
public ContractManager(ContractRegistry registry, ContractLoader loader, ClientKeyValidator clientKeyValidator, com.google.common.cache.Cache<ContractEntry.Key,java.lang.Object> recentlyValidated)
public void register(ContractEntry entry)
ContractEntry
in a ContractRegistry
. It will first check if the ContractEntry
is stored in the ContractRegistry
, and if so, throw a DatabaseException
and fail. Otherwise, it will store it in the ContractRegistry
.entry
- a ContractEntry
public ContractEntry get(ContractEntry.Key key)
ContractEntry
. It will retrieve it from the ContractRegistry
.key
- the key of the ContractEntry
to retrieveContractEntry
public java.util.List<ContractEntry> scan(java.lang.String entityId, int keyVersion)
ContractEntry
s of a specific version registered by a
specified entity id.entityId
- an entity ID.keyVersion
- the version of a key (certificate or HMAC secret key)ContractEntry
spublic ContractMachine getInstance(ContractEntry entry)
ContractMachine
from the specified contract entry.entry
- the entry of the ContractMachine
to retrieveContractMachine