Search in sources :

Example 1 with SessionImpl

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.impl.SessionImpl in project stanbol by apache.

the class SessionManagerImpl method destroySession.

@Override
public synchronized void destroySession(String sessionID) {
    try {
        Session ses = sessionsByID.get(sessionID);
        if (ses == null)
            log.warn("Tried to destroy nonexisting session {} . Could it have been previously destroyed?", sessionID);
        else {
            ses.close();
            if (ses instanceof SessionImpl)
                ((SessionImpl) ses).state = State.ZOMBIE;
            // Make session no longer referenceable
            removeSession(ses);
            fireSessionDestroyed(ses);
        }
    } catch (NonReferenceableSessionException e) {
        log.warn("Tried to kick a dead horse on session \"{}\" which was already in a zombie state.", sessionID);
    }
}
Also used : NonReferenceableSessionException(org.apache.stanbol.ontologymanager.servicesapi.session.NonReferenceableSessionException) SessionImpl(org.apache.stanbol.ontologymanager.multiplexer.clerezza.impl.SessionImpl) Session(org.apache.stanbol.ontologymanager.servicesapi.session.Session)

Example 2 with SessionImpl

use of org.apache.stanbol.ontologymanager.multiplexer.clerezza.impl.SessionImpl in project stanbol by apache.

the class SessionManagerImpl method createSession.

@Override
public synchronized Session createSession(String sessionID) throws DuplicateSessionIDException, SessionLimitException {
    /*
         * Throw the duplicate ID exception first, in case developers decide to reuse the existing session
         * before creating a new one.
         */
    if (sessionsByID.containsKey(sessionID))
        throw new DuplicateSessionIDException(sessionID);
    checkSessionLimit();
    IRI ns = IRI.create(getDefaultNamespace() + getID() + "/");
    Session session = new SessionImpl(sessionID, ns, ontologyProvider);
    // Have the ontology provider listen to ontology events
    if (ontologyProvider instanceof OntologyCollectorListener)
        session.addOntologyCollectorListener((OntologyCollectorListener) ontologyProvider);
    if (ontologyProvider instanceof SessionListener)
        session.addSessionListener((SessionListener) ontologyProvider);
    Multiplexer multiplexer = ontologyProvider.getOntologyNetworkDescriptor();
    session.addOntologyCollectorListener(multiplexer);
    session.addSessionListener(multiplexer);
    ConnectivityPolicy policy;
    try {
        policy = ConnectivityPolicy.valueOf(connectivityPolicyString);
    } catch (IllegalArgumentException e) {
        log.warn("The value {}", connectivityPolicyString);
        log.warn(" -- configured as default ConnectivityPolicy does not match any value of the Enumeration!");
        log.warn(" -- Setting the default policy as defined by the {}.", ConnectivityPolicy.class);
        policy = ConnectivityPolicy.valueOf(_CONNECTIVITY_POLICY_DEFAULT);
    }
    session.setConnectivityPolicy(policy);
    addSession(session);
    fireSessionCreated(session);
    return session;
}
Also used : IRI(org.semanticweb.owlapi.model.IRI) ConnectivityPolicy(org.apache.stanbol.ontologymanager.servicesapi.ontology.OWLExportable.ConnectivityPolicy) OntologyCollectorListener(org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollectorListener) Multiplexer(org.apache.stanbol.ontologymanager.servicesapi.ontology.Multiplexer) SessionImpl(org.apache.stanbol.ontologymanager.multiplexer.clerezza.impl.SessionImpl) SessionListener(org.apache.stanbol.ontologymanager.servicesapi.session.SessionListener) DuplicateSessionIDException(org.apache.stanbol.ontologymanager.servicesapi.session.DuplicateSessionIDException) Session(org.apache.stanbol.ontologymanager.servicesapi.session.Session)

Aggregations

SessionImpl (org.apache.stanbol.ontologymanager.multiplexer.clerezza.impl.SessionImpl)2 Session (org.apache.stanbol.ontologymanager.servicesapi.session.Session)2 OntologyCollectorListener (org.apache.stanbol.ontologymanager.servicesapi.collector.OntologyCollectorListener)1 Multiplexer (org.apache.stanbol.ontologymanager.servicesapi.ontology.Multiplexer)1 ConnectivityPolicy (org.apache.stanbol.ontologymanager.servicesapi.ontology.OWLExportable.ConnectivityPolicy)1 DuplicateSessionIDException (org.apache.stanbol.ontologymanager.servicesapi.session.DuplicateSessionIDException)1 NonReferenceableSessionException (org.apache.stanbol.ontologymanager.servicesapi.session.NonReferenceableSessionException)1 SessionListener (org.apache.stanbol.ontologymanager.servicesapi.session.SessionListener)1 IRI (org.semanticweb.owlapi.model.IRI)1