use of org.apache.stanbol.ontologymanager.core.session.TimestampedSessionIDGenerator in project stanbol by apache.
the class SessionManagerImpl method activate.
/**
* Called within both OSGi and non-OSGi environments.
*
* @param configuration
* @throws IOException
*/
protected void activate(Dictionary<String, Object> configuration) throws IOException {
long before = System.currentTimeMillis();
me = this;
// Parse configuration
id = (String) configuration.get(SessionManager.ID);
if (id == null)
id = _ID_DEFAULT;
String s = null;
try {
setDefaultNamespace(offline.getDefaultOntologyNetworkNamespace());
} catch (Exception e) {
log.warn("Invalid namespace {}. Setting to default value {}", offline.getDefaultOntologyNetworkNamespace(), _ONTOLOGY_NETWORK_NS_DEFAULT);
setDefaultNamespace(IRI.create(_ONTOLOGY_NETWORK_NS_DEFAULT));
}
try {
s = (String) configuration.get(SessionManager.MAX_ACTIVE_SESSIONS);
maxSessions = Integer.parseInt(s);
} catch (Exception e) {
log.warn("Invalid session limit {}. Setting to default value {}", configuration.get(SessionManager.MAX_ACTIVE_SESSIONS), _MAX_ACTIVE_SESSIONS_DEFAULT);
maxSessions = _MAX_ACTIVE_SESSIONS_DEFAULT;
}
if (id == null || id.isEmpty()) {
log.warn("The Ontology Network Manager configuration does not define a ID for the Ontology Network Manager");
}
idgen = new TimestampedSessionIDGenerator();
Object connectivityPolicy = configuration.get(SessionManager.CONNECTIVITY_POLICY);
if (connectivityPolicy == null) {
this.connectivityPolicyString = _CONNECTIVITY_POLICY_DEFAULT;
} else {
this.connectivityPolicyString = connectivityPolicy.toString();
}
// Add listeners
if (ontologyProvider instanceof SessionListener)
this.addSessionListener((SessionListener) ontologyProvider);
this.addSessionListener(ontologyProvider.getOntologyNetworkDescriptor());
if (scopeRegistry != null)
scopeRegistry.addScopeRegistrationListener(this);
// Rebuild sessions
rebuildSessions();
log.debug(SessionManager.class + " activated. Time : {} ms.", System.currentTimeMillis() - before);
}
Aggregations