01: /*
02: * Copyright Aduna (http://www.aduna-software.com/) (c) 2008.
03: *
04: * Licensed under the Aduna BSD-style license.
05: */
06: package org.openrdf.sail.rdbms.config;
07:
08: import org.openrdf.sail.SailException;
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.rdbms.RdbmsStore;
13:
14: /**
15: * Creates a {@link RdbmsStore} from a {@link RdbmsStoreConfig}.
16: *
17: * @author James Leigh
18: *
19: */
20: public class RdbmsStoreFactory implements SailFactory {
21: public static final String SAIL_TYPE = "openrdf:RdbmsStore";
22:
23: public String getSailType() {
24: return SAIL_TYPE;
25: }
26:
27: public RdbmsStoreConfig getConfig() {
28: return new RdbmsStoreConfig();
29: }
30:
31: public RdbmsStore getSail(SailImplConfig config)
32: throws SailConfigException {
33: if (!SAIL_TYPE.equals(config.getType())) {
34: throw new SailConfigException("Invalid Sail type: "
35: + config.getType());
36: }
37:
38: RdbmsStoreConfig rdbms = (RdbmsStoreConfig) config;
39: String jdbcDriver = rdbms.getJdbcDriver();
40: String url = rdbms.getUrl();
41: String user = rdbms.getUser();
42: String password = rdbms.getPassword();
43: String layout = rdbms.getLayout();
44: String indexed = rdbms.getIndexed();
45: RdbmsStore store = new RdbmsStore(jdbcDriver, url, user,
46: password);
47: if ("layout2".equals(layout)) {
48: store.setMaxNumberOfTripleTables(1);
49: } else {
50: assert "layout3".equals(layout) : layout;
51: }
52: if (indexed != null) {
53: try {
54: store.setIndexed(Boolean.valueOf(indexed));
55: } catch (SailException e) {
56: // this shouldn't happen
57: throw new AssertionError(e);
58: }
59: }
60: return store;
61: }
62:
63: }
|