Search in sources :

Example 1 with PersistenceContext

use of org.openkilda.persistence.context.PersistenceContext in project open-kilda by telstra.

the class GraphSupplier method get.

@Override
public OrientGraph get() {
    PersistenceContext context = PersistenceContextManager.INSTANCE.getContextCreateIfMissing();
    OrientDbContextExtension contextExtension = implementation.getContextExtension(context);
    DelegatingFramedGraph<OrientGraph> wrapper = contextExtension.getGraphCreateIfMissing();
    if (wrapper == null) {
        throw new PersistenceException("Failed to obtain a framed graph");
    }
    return wrapper.getBaseGraph();
}
Also used : OrientGraph(org.apache.tinkerpop.gremlin.orientdb.OrientGraph) OrientDbContextExtension(org.openkilda.persistence.orientdb.OrientDbContextExtension) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) PersistenceContext(org.openkilda.persistence.context.PersistenceContext)

Example 2 with PersistenceContext

use of org.openkilda.persistence.context.PersistenceContext in project open-kilda by telstra.

the class HibernateTransactionAdapter method getSessionFactory.

private SessionFactory getSessionFactory() {
    PersistenceContext context = PersistenceContextManager.INSTANCE.getContextCreateIfMissing();
    HibernateContextExtension contextExtension = getImplementation().getContextExtension(context);
    return contextExtension.getSessionFactoryCreateIfMissing();
}
Also used : PersistenceContext(org.openkilda.persistence.context.PersistenceContext)

Example 3 with PersistenceContext

use of org.openkilda.persistence.context.PersistenceContext in project open-kilda by telstra.

the class TransactionManager method clearContext.

private void clearContext() {
    log.debug("Remove global transaction tracking in {}", Thread.currentThread().getName());
    PersistenceContext context = PersistenceContextManager.INSTANCE.getContextCreateIfMissing();
    context.clearTransaction();
}
Also used : PersistenceContext(org.openkilda.persistence.context.PersistenceContext)

Example 4 with PersistenceContext

use of org.openkilda.persistence.context.PersistenceContext in project open-kilda by telstra.

the class FermaGenericRepository method framedGraph.

protected FramedGraph framedGraph() {
    PersistenceContext context = PersistenceContextManager.INSTANCE.getContextCreateIfMissing();
    FermaContextExtension contextExtension = implementation.getContextExtension(context);
    DelegatingFramedGraph<?> graph = contextExtension.getGraphCreateIfMissing();
    if (graph == null) {
        throw new PersistenceException("Failed to obtain a framed graph");
    }
    return graph;
}
Also used : FermaContextExtension(org.openkilda.persistence.ferma.FermaContextExtension) PersistenceException(org.openkilda.persistence.exceptions.PersistenceException) PersistenceContext(org.openkilda.persistence.context.PersistenceContext)

Example 5 with PersistenceContext

use of org.openkilda.persistence.context.PersistenceContext in project open-kilda by telstra.

the class DatabaseSupportImpl method getGraph.

private FramedGraph getGraph() {
    PersistenceContext context = PersistenceContextManager.INSTANCE.getContextCreateIfMissing();
    OrientDbContextExtension contextExtension = orientPersistenceImplementation.getContextExtension(context);
    return contextExtension.getGraphCreateIfMissing();
}
Also used : OrientDbContextExtension(org.openkilda.persistence.orientdb.OrientDbContextExtension) PersistenceContext(org.openkilda.persistence.context.PersistenceContext)

Aggregations

PersistenceContext (org.openkilda.persistence.context.PersistenceContext)5 PersistenceException (org.openkilda.persistence.exceptions.PersistenceException)2 OrientDbContextExtension (org.openkilda.persistence.orientdb.OrientDbContextExtension)2 OrientGraph (org.apache.tinkerpop.gremlin.orientdb.OrientGraph)1 FermaContextExtension (org.openkilda.persistence.ferma.FermaContextExtension)1