com::cosylab::acs::laser::dao::ACSAlarmCacheImpl Class Reference

Inheritance diagram for com::cosylab::acs::laser::dao::ACSAlarmCacheImpl:
Inheritance graph
[legend]
Collaboration diagram for com::cosylab::acs::laser::dao::ACSAlarmCacheImpl:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACSAlarmCacheImpl (AlarmDAO alarmDAO, AlarmCacheListener alarmCacheListener)
void initializeAlarmCache (Map alarms, Map activeLists)
Alarm getCopy (String identifier) throws AlarmCacheException
Alarm getReference (String identifier) throws AlarmCacheException
void replace (Alarm alarm) throws AlarmCacheException
void put (Alarm alarm) throws AlarmCacheException
void invalidate (String identifier) throws AlarmCacheException
CategoryActiveList getActiveListReference (Integer identifier) throws AlarmCacheException
void close ()
void removeActiveList (Integer identifier) throws AlarmCacheException

Private Member Functions

void sendMsgToListener (Alarm actual, Alarm old)
void dumpAlarmsCache (boolean verbose)
CategoryActiveList getCategoryList (Integer categoryId)
void updateCategoryActiveLists (Alarm alarm)

Private Attributes

HashMap< String, Alarmalarms = new HashMap<String,Alarm>()
AlarmDAO dao
AlarmCacheListener listener
HashMap< Integer,
CategoryActiveList
activeLists = new HashMap<Integer,CategoryActiveList>()

Constructor & Destructor Documentation

com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::ACSAlarmCacheImpl ( AlarmDAO  alarmDAO,
AlarmCacheListener  alarmCacheListener 
) [inline]

The constructor

Parameters:
alarmDAO The object to access the database
alarmCacheListener The listener

References alarms, dao, and listener.


Member Function Documentation

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::close (  )  [inline]

Close and deallocate the resources.

Implements cern::laser::business::cache::AlarmCache.

References alarms.

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::dumpAlarmsCache ( boolean  verbose  )  [inline, private]

Print a copy of the alarms in the cache in the standard output. This method is added for debugging

Parameters:
verbose If true the details of each alarm found in the cache is also displayed

References alarms.

CategoryActiveList com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::getActiveListReference ( Integer  identifier  )  throws AlarmCacheException [inline]

Returns a reference to the active list for a category.

Parameters:
identifier the active list private identifier
Returns:
the reference to the active list object.
Exceptions:
Exception if the operation can not be performed

Implements cern::laser::business::cache::AlarmCache.

References activeLists.

Referenced by updateCategoryActiveLists().

CategoryActiveList com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::getCategoryList ( Integer  categoryId  )  [inline, private]

Return the CategoryActiveList for the specified categoryId. If the CategoryActiveList does not exist than a new one is created and inserted in the activeList and then returned to the caller

Parameters:
categoryId The categoryId identifying the CategoryActiveList
Returns:
The CategoryActiveList for the specified categoryId

References activeLists.

Alarm com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::getCopy ( String  identifier  )  throws AlarmCacheException [inline]

Returns a clone of the cached alarm.

Parameters:
identifier the alarm private identifier
Returns:
the cloned alarm object.
Exceptions:
Exception if the operation can not be performed

Implements cern::laser::business::cache::AlarmCache.

References getReference().

Alarm com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::getReference ( String  identifier  )  throws AlarmCacheException [inline]

Returns a reference to the cached alarm.

Parameters:
identifier the alarm private identifier
Returns:
the reference to the alarm object
Exceptions:
AlarmCacheException if the operation cannot be performed

Implements cern::laser::business::cache::AlarmCache.

References alarms, dao, and cern::laser::business::dao::AlarmDAO::findAlarm().

Referenced by getCopy().

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::initializeAlarmCache ( Map  alarms,
Map  activeLists 
) [inline]

Initializes the alarm cache. Can only be called once.

Implements cern::laser::business::cache::AlarmCache.

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::invalidate ( String  identifier  )  throws AlarmCacheException [inline]

Invalidate the cached object. Subsequent accesses to that object will cause the object to be loaded again from the ejb.

Parameters:
identifier the alarm private identifier
Exceptions:
Exception if the operation can not be performed

Implements cern::laser::business::cache::AlarmCache.

References alarms.

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::put ( Alarm  alarm  )  throws AlarmCacheException [inline]

Puts an object in the cache. If that object was already in the cache it is replaced. This method combines the methods replace, and release alarm the new alarm object Exception if the operation can not be performed

Implements cern::laser::business::cache::AlarmCache.

References alarms, sendMsgToListener(), and updateCategoryActiveLists().

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::removeActiveList ( Integer  identifier  )  throws AlarmCacheException [inline]

Remove the active list associated with the given category id.

Parameters:
identifier the id of the active list to destroy (=category id)
Exceptions:
Exception if the operation cannot be performed

Implements cern::laser::business::cache::AlarmCache.

References activeLists.

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::replace ( Alarm  alarm  )  throws AlarmCacheException [inline]

Returns a reference to the alarm specified. The object is locked from modification by other cache users.

Parameters:
identifier the id for the alarm
Returns:
a reference to the alarm
Exceptions:
AlarmCacheException if the operation cannot be performed Releases the lock held on an alarm.
Parameters:
identifier the id for the alarm
Exceptions:
AlarmCacheException if the operation cannot be performed. Puts alarm in the cache. This method must be called after as the alarm need to be locked. alarm object to put in cache AlarmCacheException if the operation cannot be performed. However, the lock is released.

Implements cern::laser::business::cache::AlarmCache.

References alarms, sendMsgToListener(), and updateCategoryActiveLists().

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::sendMsgToListener ( Alarm  actual,
Alarm  old 
) [inline, private]

Send the message to the listener

NOTE: If the previous alarm does not exist (for example if the alarm is new) then we send as old alarm the actual alarm If we send a null then cern.laser.business.pojo.AlarmPublisher:publish returns an exception while executing Status previous_alarm_status=previous.getStatus();

This policy seems reasonable but could have an impact somewhere

Parameters:
actual The actual alarm
old The previous alarm

References listener, and cern::laser::business::cache::AlarmCacheListener::onAlarmChange().

Referenced by put(), and replace().

void com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::updateCategoryActiveLists ( Alarm  alarm  )  [inline, private]

Update the CategoryActiveList for the alarm: all the CategoryActiveLists of the categories of the alarm will be updated. The alarmId is inserted or removed in the CategoryActiveList depending of the status of the alarm

Parameters:
alarm The alarm whose id must be inserted or removed for the CategoryActiveLists of its categories

References cern::laser::business::data::CategoryActiveList::addAlarm(), cern::laser::business::data::Status::getActive(), getActiveListReference(), cern::laser::business::data::Alarm::getAlarmId(), cern::laser::business::data::Alarm::getCategories(), cern::laser::business::data::Alarm::getStatus(), and cern::laser::business::data::CategoryActiveList::removeAlarm().

Referenced by put(), and replace().


Member Data Documentation

The HashMap with the active alarms per each category The map contains a CategoryActiveList per each category (the key is the Integer identifying the category)

Policy: the CategoryActiveList for a category is created and inserted in the map when a new alarm arrives (remember that an alarm has a Set of Categories) So it basically happens in the put and replace methods (based on the status of the alarm itself)

Referenced by getActiveListReference(), getCategoryList(), and removeActiveList().

HashMap<String,Alarm> com::cosylab::acs::laser::dao::ACSAlarmCacheImpl::alarms = new HashMap<String,Alarm>() [private]

Referenced by ACSAlarmCacheImpl(), and getReference().


The documentation for this class was generated from the following file:

Generated by  doxygen 1.6.2