01: /*
02: * LICENSE INFORMATION
03: * Copyright 2005-2007 by FZI (http://www.fzi.de).
04: * Licensed under a BSD license (http://www.opensource.org/licenses/bsd-license.php)
05: * <OWNER> = Max Völkel
06: * <ORGANIZATION> = FZI Forschungszentrum Informatik Karlsruhe, Karlsruhe, Germany
07: * <YEAR> = 2007
08: *
09: * Project information at http://semweb4j.org/rdf2go
10: */
11: package org.ontoware.rdf2go.model.impl;
12:
13: import org.ontoware.rdf2go.exception.ModelRuntimeException;
14: import org.ontoware.rdf2go.model.DiffReader;
15: import org.ontoware.rdf2go.model.Model;
16: import org.ontoware.rdf2go.model.Statement;
17: import org.slf4j.Logger;
18: import org.slf4j.LoggerFactory;
19:
20: /**
21: * adapter that maps the rdf2go model functions to a smaller subset of methods
22: *
23: * @author mvo
24: *
25: */
26: public abstract class AbstractLockingModel extends AbstractModel
27: implements Model {
28:
29: @SuppressWarnings("unused")
30: private static Logger log = LoggerFactory
31: .getLogger(AbstractLockingModel.class);
32:
33: /**
34: * Using lock() and unlock()
35: */
36: @Override
37: public synchronized void update(DiffReader diff)
38: throws ModelRuntimeException {
39: assertModel();
40: lock();
41: for (Statement r : diff.getRemoved()) {
42: removeStatement(r);
43: }
44:
45: for (Statement a : diff.getAdded()) {
46: addStatement(a);
47: }
48: unlock();
49: }
50: }
|