Cumulus4j API
(1.1.0)

org.cumulus4j.store.crypto.keymanager.messagebroker.pmf
Class MessageBrokerPMF

java.lang.Object
  extended by org.cumulus4j.store.crypto.keymanager.messagebroker.AbstractMessageBroker
      extended by org.cumulus4j.store.crypto.keymanager.messagebroker.pmf.MessageBrokerPMF
All Implemented Interfaces:
MessageBroker

public class MessageBrokerPMF
extends AbstractMessageBroker

PersistenceManagerFactory-backed implementation of MessageBroker.

All messages are transferred via a shared database. Which database to be used can be configured by system properties.

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

Field Summary
static String SYSTEM_PROPERTY_CLEANUP_TIMER_ENABLED
           System property to control whether the timer for cleaning up old PendingRequests should be enabled.
static String SYSTEM_PROPERTY_CLEANUP_TIMER_PERIOD
           System property to control when the timer for cleaning up old PendingRequests is called.
static String SYSTEM_PROPERTY_PERSISTENCE_PROPERTIES_PREFIX
          Prefix for system properties used to configure the PersistenceManagerFactory.
 
Fields inherited from interface org.cumulus4j.store.crypto.keymanager.messagebroker.MessageBroker
SYSTEM_PROPERTY_POLL_REQUEST_TIMEOUT, SYSTEM_PROPERTY_QUERY_TIMEOUT
 
Constructor Summary
MessageBrokerPMF()
          Create an instance of MessageBrokerPMF.
 
Method Summary
protected  Request _pollRequest(String cryptoSessionIDPrefix)
          Delegate of the AbstractMessageBroker.pollRequest(String) method.
protected  void _pushResponse(Response response)
          Delegate of the AbstractMessageBroker.pushResponse(Response) method.
protected  Response _query(Class<? extends Response> responseClass, Request request)
          Delegate of the AbstractMessageBroker.query(Class, Request) method.
protected  PersistenceManager createTransactionalPersistenceManager()
           
protected  boolean getCleanupTimerEnabled()
           Get the enabled status of the timer used to cleanup.
protected  long getCleanupTimerPeriod()
           
 
Methods inherited from class org.cumulus4j.store.crypto.keymanager.messagebroker.AbstractMessageBroker
getPollRequestTimeout, getQueryTimeout, pollRequest, pushResponse, query
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SYSTEM_PROPERTY_PERSISTENCE_PROPERTIES_PREFIX

public static final String SYSTEM_PROPERTY_PERSISTENCE_PROPERTIES_PREFIX
Prefix for system properties used to configure the PersistenceManagerFactory.

Every system property that begins with "cumulus4j.MessageBrokerPMF.persistenceProperties." is passed (after truncating this prefix, of course) to the JDOHelper.getPersistenceManagerFactory(Map).

For example, to set the property "javax.jdo.option.ConnectionURL", you have to define the system property "cumulus4j.MessageBrokerPMF.persistenceProperties.javax.jdo.option.ConnectionURL".

A set of defaults is loaded from a resource file, hence you do not need to configure everything, but without setting some basic coordinates (e.g. the JDBC URL), it is unlikely that your database server can be contacted. Of course, you could add an appropriate host record to your "/etc/hosts" and create a database with the name from our defaults on this host, but very likely you want to override these default coordinates:

These defaults might be changed with a future version.

See Also:
Constant Field Values

SYSTEM_PROPERTY_CLEANUP_TIMER_PERIOD

public static final String SYSTEM_PROPERTY_CLEANUP_TIMER_PERIOD

System property to control when the timer for cleaning up old PendingRequests is called. The value configured here is a period, i.e. the timer will be triggered every X ms (roughly).

If this system property is not present (or not a valid number), the default is 3600000 (1 hour), which means the timer will wake up once every hour and call removeExpiredPendingRequests(boolean) with force = true.

All PendingRequests with a lastStatusChangeTimestamp being older than the queryTimeout (plus a safety margin of currently this period) are deleted.

See Also:
SYSTEM_PROPERTY_CLEANUP_TIMER_ENABLED, Constant Field Values

SYSTEM_PROPERTY_CLEANUP_TIMER_ENABLED

public static final String SYSTEM_PROPERTY_CLEANUP_TIMER_ENABLED

System property to control whether the timer for cleaning up old PendingRequests should be enabled. The value configured here is a boolean value, i.e. it can be "true" or "false".

If it is disabled, the "normal" threads will do the clean-up-work periodically, when they run through _query(Class, Request) or _pollRequest(String).

See Also:
SYSTEM_PROPERTY_CLEANUP_TIMER_PERIOD, Constant Field Values
Constructor Detail

MessageBrokerPMF

public MessageBrokerPMF()
Create an instance of MessageBrokerPMF. You should not call this constructor directly, but instead use MessageBrokerRegistry.getActiveMessageBroker() to obtain the currently active MessageBroker.

Method Detail

getCleanupTimerPeriod

protected long getCleanupTimerPeriod()

getCleanupTimerEnabled

protected boolean getCleanupTimerEnabled()

Get the enabled status of the timer used to cleanup.

This value can be configured using the system property "cumulus4j.MessageBrokerPMF.cleanupTimer.enabled".

Returns:
the enabled status.
See Also:
SYSTEM_PROPERTY_CLEANUP_TIMER_PERIOD, SYSTEM_PROPERTY_CLEANUP_TIMER_ENABLED

createTransactionalPersistenceManager

protected PersistenceManager createTransactionalPersistenceManager()

_query

protected Response _query(Class<? extends Response> responseClass,
                          Request request)
                   throws TimeoutException,
                          ErrorResponseException
Description copied from class: AbstractMessageBroker
Delegate of the AbstractMessageBroker.query(Class, Request) method. Subclasses should implement this method instead of query(...).

Specified by:
_query in class AbstractMessageBroker
Parameters:
responseClass - the type of the expected response; can be null, if you expect to receive null (i.e. you pass a "void" request).
request - the request to be sent to the key-manager.
Returns:
the response from the key-manager. Will be null, if the key-manager replied with a NullResponse.
Throws:
TimeoutException - if the request was not replied within the query-timeout.
ErrorResponseException - if the key-manager (either running embedded on the remote client or in a separate key-server) sent an ErrorResponse.

_pollRequest

protected Request _pollRequest(String cryptoSessionIDPrefix)
Description copied from class: AbstractMessageBroker
Delegate of the AbstractMessageBroker.pollRequest(String) method. Subclasses should implement this method instead of pollRequest(...).

Specified by:
_pollRequest in class AbstractMessageBroker
Parameters:
cryptoSessionIDPrefix - usually, every key-manager uses the same prefix for all crypto-sessions. Thus, this prefix is used to efficiently route requests to the right key-manager.
Returns:
the next request waiting for processing and fitting to the given cryptoSessionIDPrefix or null, if no such request pops up in the to-do-queue within the timeout.

_pushResponse

protected void _pushResponse(Response response)
Description copied from class: AbstractMessageBroker
Delegate of the AbstractMessageBroker.pushResponse(Response) method. Subclasses should implement this method instead of pushResponse(...).

Specified by:
_pushResponse in class AbstractMessageBroker
Parameters:
response - the response answering a previous Request enqueued by AbstractMessageBroker.query(Class, Request).

Cumulus4j API
(1.1.0)

Copyright © 2013 NightLabs Consulting GmbH. All Rights Reserved.