Skip to content

Package: AbstractSession

AbstractSession

nameinstructionbranchcomplexitylinemethod
AbstractSession()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
acquireUnitOfWork()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
release()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
releaseObjectCache()
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (C) 2016 Czech Technical University in Prague
3: *
4: * This program is free software: you can redistribute it and/or modify it under
5: * the terms of the GNU General Public License as published by the Free Software
6: * Foundation, either version 3 of the License, or (at your option) any
7: * later version.
8: *
9: * This program is distributed in the hope that it will be useful, but WITHOUT
10: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
12: * details. You should have received a copy of the GNU General Public License
13: * along with this program. If not, see <http://www.gnu.org/licenses/>.
14: */
15: package cz.cvut.kbss.jopa.sessions;
16:
17: import org.slf4j.Logger;
18: import org.slf4j.LoggerFactory;
19:
20: /**
21: * This is the implementation of the basic Session operations. Other more
22: * specific methods are to be implemented in descendants.
23: *
24: * @author kidney
25: *
26: */
27: public abstract class AbstractSession implements Session, MetamodelProvider {
28: protected static final Logger LOG = LoggerFactory.getLogger(AbstractSession.class);
29:
30: public AbstractSession() {
31: super();
32: }
33:
34: public UnitOfWork acquireUnitOfWork() {
35: UnitOfWork uow = new UnitOfWorkImpl(this);
36: LOG.trace("UnitOfWork acquired.");
37: return uow;
38: }
39:
40: /**
41: * This method just releases the live object cache. Subclasses are free to
42: * make additional cleanup.
43: */
44: public void release() {
45: releaseObjectCache();
46: }
47:
48: /**
49: * Release the current liveObjectCache. This method is called whenever any
50: * attribute of a cached objects changes during a transaction because then
51: * our cache is no more actual.
52: */
53: public void releaseObjectCache() {
54: getLiveObjectCache().evictAll();
55: }
56:
57: /**
58: * Get the current live object cache. </p>
59: *
60: * This manager represents the second level cache.
61: *
62: * @return Second level cache
63: */
64: public abstract CacheManager getLiveObjectCache();
65:
66: /**
67: * Acquires connection to the underlying ontology storage. </p>
68: *
69: * @return Connection
70: */
71: protected abstract ConnectionWrapper acquireConnection();
72:
73: /**
74: * Register the specified entity as managed in the specified
75: * {@code UnitOfWork}. </p>
76: *
77: * Registering loaded entities with their owning {@code UnitOfWork} is
78: * highly recommended, since it speeds up persistence context lookup when
79: * entity attributes are modified.
80: *
81: * @param entity
82: * The entity to register
83: * @param uow
84: * Persistence context of the specified entity
85: */
86: abstract void registerEntityWithPersistenceContext(Object entity, UnitOfWorkImpl uow);
87:
88: /**
89: * Detaches the specified entity from its persistence context.
90: *
91: * @param entity
92: * The entity to deregister
93: * @param uow
94: * Persistence context to which the entity belonged
95: */
96: abstract void deregisterEntityFromPersistenceContext(Object entity, UnitOfWork uow);
97: }