use of cern.laser.console.impl.UserHandlerImpl in project ACS by ACS-Community.
the class CategoryClient method connect.
/**
* Connects to the passed categories of the alarm system
*
* @param listener The lister to notify of the alarms received from the categories
* @param categories The categories to connect to
* @throws AcsJCannotGetComponentEx In case the AlarmService is not available
* @throws AlarmClientException In case of failure connecting the client
*/
public void connect(AlarmSelectionListener listener, Category[] categories) throws AlarmClientException, AcsJCannotGetComponentEx {
if (listener == null) {
throw new IllegalArgumentException("The listener can't be null");
}
if (closed) {
throw new IllegalStateException("SourceClient is closed!");
}
try {
CernAlarmServiceUtils alarmUtils = new CernAlarmServiceUtils(orb, logger);
alarm = alarmUtils.getCernAlarmService();
} catch (Throwable t) {
AcsJCannotGetComponentEx ex = new AcsJCannotGetComponentEx(t);
ex.setReason("Alarm service unavailable");
throw ex;
}
try {
userHandler = new UserHandlerImpl(orb, logger);
logger.log(AcsLogLevel.DEBUG, "UserHandler succesfully built");
testUser = userHandler.getUser("test", orb, logger);
logger.log(AcsLogLevel.DEBUG, "User generated");
defaultConf = testUser.getDefaultConfiguration();
logger.log(AcsLogLevel.DEBUG, "Getting the selection handler");
jms_selectionHandler = AlarmSelectionHandler.get(orb, logger);
addCategories(defaultConf, categories);
// Get the active alarms (they are received by the listener)
java.util.Map<String, Alarm> alreadyActive = jms_selectionHandler.select(defaultConf.getSelection(), listener);
if (alreadyActive != null && alreadyActive.size() > 0) {
Set<String> keys = alreadyActive.keySet();
for (String key : keys) {
listener.onAlarm(alreadyActive.get(key));
}
}
} catch (Throwable t) {
throw new AlarmClientException("Exception connecting the category client", t);
}
}
Aggregations