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: 14 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 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: 5
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) 2011 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 java.util.logging.Level;
18: import java.util.logging.Logger;
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 = Logger.getLogger(AbstractSession.class.getName());
29:
30:         public AbstractSession() {
31:                 super();
32:         }
33:
34:         public UnitOfWork acquireUnitOfWork() {
35:                 UnitOfWork uow = new UnitOfWorkImpl(this);
36:•                if (LOG.isLoggable(Level.CONFIG)) {
37:                         LOG.config("UnitOfWork acquired.");
38:                 }
39:                 return uow;
40:         }
41:
42:         /**
43:          * This method just releases the live object cache. Subclasses are free to
44:          * make additional cleanup.
45:          */
46:         public void release() {
47:                 releaseObjectCache();
48:         }
49:
50:         /**
51:          * Release the current liveObjectCache. This method is called whenever any
52:          * attribute of a cached objects changes during a transaction because then
53:          * our cache is no more actual.
54:          */
55:         public void releaseObjectCache() {
56:                 getLiveObjectCache().evictAll();
57:         }
58:
59:         /**
60:          * Get the current live object cache. </p>
61:          *
62:          * This manager represents the second level cache.
63:          *
64:          * @return Second level cache
65:          */
66:         public abstract CacheManager getLiveObjectCache();
67:
68:         /**
69:          * Acquires connection to the underlying ontology storage. </p>
70:          *
71:          * @return Connection
72:          */
73:         protected abstract ConnectionWrapper acquireConnection();
74:
75:         /**
76:          * Register the specified entity as managed in the specified
77:          * {@code UnitOfWork}. </p>
78:          *
79:          * Registering loaded entities with their owning {@code UnitOfWork} is
80:          * highly recommended, since it speeds up persistence context lookup when
81:          * entity attributes are modified.
82:          *
83:          * @param entity
84:          * The entity to register
85:          * @param uow
86:          * Persistence context of the specified entity
87:          */
88:         abstract void registerEntityWithPersistenceContext(Object entity, UnitOfWorkImpl uow);
89:
90:         /**
91:          * Detaches the specified entity from its persistence context.
92:          *
93:          * @param entity
94:          * The entity to deregister
95:          * @param uow
96:          * Persistence context to which the entity belonged
97:          */
98:         abstract void deregisterEntityFromPersistenceContext(Object entity, UnitOfWork uow);
99: }