Cumulus4j API
(1.1.1)

org.cumulus4j.keymanager.channel
Class KeyManagerChannelManager

java.lang.Object
  extended by org.cumulus4j.keymanager.channel.KeyManagerChannelManager

public class KeyManagerChannelManager
extends Object

Manager for the communication channel between key manager and application server.

The so-called "key manager channel" is - as shown in the document Deployment scenarios - an HTTP(S) connection from the key-manager to the application server with an inverse request-response-cycle. This means, the application server sends a Request, the key manager handles it and then sends a Response back.

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

Constructor Summary
KeyManagerChannelManager(SessionManager sessionManager, String appServerBaseURL)
          Instantiate a KeyManagerChannelManager.
 
Method Summary
 String getAppServerBaseURL()
          Get the base-URL before the "/KeyManagerChannel" - e.g.
 int getDesiredThreadCount()
          Get the quantity of KeyManagerChannelListenerThreads that should be running for this KeyManagerChannelManager.
 String getKeyManagerChannelURL()
          Get the complete URL to the KeyManagerChannel.
protected
<R extends Request>
RequestHandler<R>
getRequestHandler(R request)
          Get the appropriate handler for the given request.
 SessionManager getSessionManager()
          Get the SessionManager that was passed in the constructor.
 void setDesiredThreadCount(int desiredThreadCount)
           Set the quantity of KeyManagerChannelListenerThreads that should be running for this KeyManagerChannelManager.
protected  boolean unregisterThreadIfMoreThanDesiredThreadCount(KeyManagerChannelListenerThread thread)
           Unregister the given thread, if there are currently more threads running than desired.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

KeyManagerChannelManager

public KeyManagerChannelManager(SessionManager sessionManager,
                                String appServerBaseURL)
Instantiate a KeyManagerChannelManager.

Parameters:
sessionManager - the SessionManager which
appServerBaseURL - the base-URL before the "/KeyManagerChannel" - e.g. if the REST URL of the KeyManagerChannel-service is "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp/KeyManagerChannel", then this must be "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp".
Method Detail

getSessionManager

public SessionManager getSessionManager()
Get the SessionManager that was passed in the constructor.

Returns:
the SessionManager.

getAppServerBaseURL

public String getAppServerBaseURL()
Get the base-URL before the "/KeyManagerChannel" - e.g. if the REST URL of the KeyManagerChannel-service is "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp/KeyManagerChannel", then this must be "https://serverUsingCumulus4j.mydomain.org/org.cumulus4j.keymanager.back.webapp".

Returns:
the base-URL before the "/KeyManagerChannel".

getKeyManagerChannelURL

public String getKeyManagerChannelURL()
Get the complete URL to the KeyManagerChannel.

Returns:
the complete URL to the KeyManagerChannel.

setDesiredThreadCount

public void setDesiredThreadCount(int desiredThreadCount)

Set the quantity of KeyManagerChannelListenerThreads that should be running for this KeyManagerChannelManager.

If the given desiredThreadCount is greater than the number of currently running threads, new threads are created. If the desiredThreadCount is less than the number of currently running threads, some of the threads will terminate themselves until the number of currently running threads matches the desired quantity.

Parameters:
desiredThreadCount - the new quantity of KeyManagerChannelListenerThreads which should be active for this KeyManagerChannelManager.
See Also:
getDesiredThreadCount()

getDesiredThreadCount

public int getDesiredThreadCount()
Get the quantity of KeyManagerChannelListenerThreads that should be running for this KeyManagerChannelManager.

Returns:
the quantity of KeyManagerChannelListenerThreads that should be active for this KeyManagerChannelManager.
See Also:
setDesiredThreadCount(int)

unregisterThreadIfMoreThanDesiredThreadCount

protected boolean unregisterThreadIfMoreThanDesiredThreadCount(KeyManagerChannelListenerThread thread)

Unregister the given thread, if there are currently more threads running than desired.

This method is called by a KeyManagerChannelListenerThread in its run-loop to determine, if the thread should terminate itself (see setDesiredThreadCount(int)). If the method returns true, the thread will exit its run() method.

Parameters:
thread - the thread.
Returns:
true if the thread was unregistered and thus must exit its run() method; false if the thread was not unregistered and should thus continue.

getRequestHandler

protected <R extends Request> RequestHandler<R> getRequestHandler(R request)
                                                       throws InstantiationException,
                                                              IllegalAccessException
Get the appropriate handler for the given request.

Type Parameters:
R - the type of the request.
Parameters:
request - the request.
Returns:
the RequestHandler for the request.
Throws:
InstantiationException - if Class.newInstance() failed to create the handler instance.
IllegalAccessException - if Class.newInstance() failed to create the handler instance.

Cumulus4j API
(1.1.1)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.