Cumulus4j API
(1.2.0)

org.cumulus4j.store.crypto
Class CryptoManagerRegistry

java.lang.Object
  extended by org.cumulus4j.store.crypto.CryptoManagerRegistry

public class CryptoManagerRegistry
extends Object

Registry holding instances of CryptoManager.

There is one JVM-singleton-instance of CryptoManagerRegistry per NucleusContext. Since it is held in a WeakHashMap, a CryptoManagerRegistry will be garbage-collected when the corresponding NucleusContext is "forgotten".

Author:
Marco หงุ่ยตระกูล-Schulze - marco at nightlabs dot de

Method Summary
 CryptoManager getCryptoManager(String cryptoManagerID)
           Get a CryptoManager for the specified cryptoManagerID.
 NucleusContext getNucleusContext()
           Get the NucleusContext for which this CryptoManagerRegistry has been created.
static CryptoManagerRegistry sharedInstance(NucleusContext nucleusContext)
           Get the CryptoManagerRegistry corresponding to a given NucleusContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

sharedInstance

public static CryptoManagerRegistry sharedInstance(NucleusContext nucleusContext)

Get the CryptoManagerRegistry corresponding to a given NucleusContext.

If there is no registry known for the given NucleusContext, yet, it will be created and associated to this context. If this method is later on called again for the same NucleusContext, the same CryptoManagerRegistry will be returned.

This method is thread-safe.

Parameters:
nucleusContext - the NucleusContext for which to get the CryptoManagerRegistry.
Returns:
the CryptoManagerRegistry associated to the given NucleusContext; never null.

getCryptoManager

public CryptoManager getCryptoManager(String cryptoManagerID)
                               throws UnknownCryptoManagerIDException

Get a CryptoManager for the specified cryptoManagerID.

Within the context of one CryptoManagerRegistry instance, this method will always return the same instance of CryptoManager for a certain cryptoManagerID. In other words, there is exactly one CryptoManager instance for each unique combination of NucleusContext and cryptoManagerID.

This method is thread-safe.

Parameters:
cryptoManagerID - the identifier used in the extension-declaration (in the plugin.xml).
Returns:
the CryptoManager for the specified cryptoManagerID; never null.
Throws:
UnknownCryptoManagerIDException - if there is no CryptoManager registered for the given identifier.

getNucleusContext

public NucleusContext getNucleusContext()

Get the NucleusContext for which this CryptoManagerRegistry has been created.

This method returns null, if the NucleusContext has already been garbage-collected (the reference is kept as a WeakReference).

Important: Hold the result of this method only in a stack variable (i.e. scope = method) or a WeakReference! Otherwise you run the risk of a memory leak!!!

Returns:
the NucleusContext or null, if it was already garbage-collected. It is never null as long as the NucleusContext is still valid (i.e. not garbage-collected).

Cumulus4j API
(1.2.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.