src/main/java/au/id/djc/jena/util/SingleModelOperator.java (904B) - raw
1 package au.id.djc.jena.util; 2 3 import com.hp.hpl.jena.rdf.model.Model; 4 import org.springframework.beans.factory.InitializingBean; 5 import org.springframework.util.Assert; 6 7 /** 8 * {@link ModelOperations} implementation which always operates on a single 9 * shared in-memory {@link Model} instance. 10 */ 11 public class SingleModelOperator implements ModelOperations, InitializingBean { 12 13 private Model model; 14 15 public SingleModelOperator() { 16 } 17 18 public SingleModelOperator(Model model) { 19 this.model = model; 20 } 21 22 public void setModel(Model model) { 23 this.model = model; 24 } 25 26 @Override 27 public void afterPropertiesSet() throws Exception { 28 Assert.notNull(model, "The 'model' property must not be null"); 29 } 30 31 @Override 32 public <T> T withModel(ModelExecutionCallback<T> callback) { 33 return callback.execute(model); 34 } 35 36 }