Search in sources :

Example 1 with TimestampedSessionIDGenerator

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);
}
Also used : TimestampedSessionIDGenerator(org.apache.stanbol.ontologymanager.core.session.TimestampedSessionIDGenerator) SessionManager(org.apache.stanbol.ontologymanager.servicesapi.session.SessionManager) SessionListener(org.apache.stanbol.ontologymanager.servicesapi.session.SessionListener) NonReferenceableSessionException(org.apache.stanbol.ontologymanager.servicesapi.session.NonReferenceableSessionException) MissingOntologyException(org.apache.stanbol.ontologymanager.servicesapi.collector.MissingOntologyException) SessionLimitException(org.apache.stanbol.ontologymanager.servicesapi.session.SessionLimitException) OWLOntologyStorageException(org.semanticweb.owlapi.model.OWLOntologyStorageException) IOException(java.io.IOException) DuplicateSessionIDException(org.apache.stanbol.ontologymanager.servicesapi.session.DuplicateSessionIDException)

Aggregations

IOException (java.io.IOException)1 TimestampedSessionIDGenerator (org.apache.stanbol.ontologymanager.core.session.TimestampedSessionIDGenerator)1 MissingOntologyException (org.apache.stanbol.ontologymanager.servicesapi.collector.MissingOntologyException)1 DuplicateSessionIDException (org.apache.stanbol.ontologymanager.servicesapi.session.DuplicateSessionIDException)1 NonReferenceableSessionException (org.apache.stanbol.ontologymanager.servicesapi.session.NonReferenceableSessionException)1 SessionLimitException (org.apache.stanbol.ontologymanager.servicesapi.session.SessionLimitException)1 SessionListener (org.apache.stanbol.ontologymanager.servicesapi.session.SessionListener)1 SessionManager (org.apache.stanbol.ontologymanager.servicesapi.session.SessionManager)1 OWLOntologyStorageException (org.semanticweb.owlapi.model.OWLOntologyStorageException)1