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.repository.http.config;
07:
08: import org.openrdf.repository.Repository;
09: import org.openrdf.repository.config.RepositoryConfigException;
10: import org.openrdf.repository.config.RepositoryFactory;
11: import org.openrdf.repository.config.RepositoryImplConfig;
12: import org.openrdf.repository.http.HTTPRepository;
13:
14: /**
15: * A {@link RepositoryFactory} that creates {@link HTTPRepository}s based on
16: * RDF configuration data.
17: *
18: * @author Arjohn Kampman
19: */
20: public class HTTPRepositoryFactory implements RepositoryFactory {
21:
22: /**
23: * The type of repositories that are created by this factory.
24: *
25: * @see RepositoryFactory#getRepositoryType()
26: */
27: public static final String REPOSITORY_TYPE = "openrdf:HTTPRepository";
28:
29: /**
30: * Returns the repository's type: <tt>openrdf:HTTPRepository</tt>.
31: */
32: public String getRepositoryType() {
33: return REPOSITORY_TYPE;
34: }
35:
36: public RepositoryImplConfig getConfig() {
37: return new HTTPRepositoryConfig();
38: }
39:
40: public Repository getRepository(RepositoryImplConfig config)
41: throws RepositoryConfigException {
42: HTTPRepository result = null;
43:
44: if (config instanceof HTTPRepositoryConfig) {
45: HTTPRepositoryConfig httpConfig = (HTTPRepositoryConfig) config;
46: result = new HTTPRepository(httpConfig.getURL());
47: // result.setUsernameAndPassword(httpConfig.getUsername(), httpConfig.getPassword());
48: } else {
49: throw new RepositoryConfigException(
50: "Invalid configuration class: " + config.getClass());
51: }
52: return result;
53: }
54: }
|