01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.memory.config;
07:
08: import org.openrdf.sail.Sail;
09: import org.openrdf.sail.config.SailConfigException;
10: import org.openrdf.sail.config.SailFactory;
11: import org.openrdf.sail.config.SailImplConfig;
12: import org.openrdf.sail.memory.MemoryStore;
13:
14: /**
15: * A {@link SailFactory} that creates {@link MemoryStore}s based on RDF
16: * configuration data.
17: *
18: * @author Arjohn Kampman
19: */
20: public class MemoryStoreFactory implements SailFactory {
21:
22: /**
23: * The type of repositories that are created by this factory.
24: *
25: * @see SailFactory#getSailType()
26: */
27: public static final String SAIL_TYPE = "openrdf:MemoryStore";
28:
29: /**
30: * Returns the Sail's type: <tt>openrdf:MemoryStore</tt>.
31: */
32: public String getSailType() {
33: return SAIL_TYPE;
34: }
35:
36: public SailImplConfig getConfig() {
37: return new MemoryStoreConfig();
38: }
39:
40: public Sail getSail(SailImplConfig config)
41: throws SailConfigException {
42: if (!SAIL_TYPE.equals(config.getType())) {
43: throw new SailConfigException("Invalid Sail type: "
44: + config.getType());
45: }
46:
47: MemoryStore memoryStore = new MemoryStore();
48:
49: if (config instanceof MemoryStoreConfig) {
50: MemoryStoreConfig memConfig = (MemoryStoreConfig) config;
51:
52: memoryStore.setPersist(memConfig.getPersist());
53: memoryStore.setSyncDelay(memConfig.getSyncDelay());
54: }
55:
56: return memoryStore;
57: }
58: }
|