1 package org.argeo.jackrabbit.client;
2
3 import java.util.Map;
4
5 import javax.jcr.RepositoryException;
6
7 import org.apache.jackrabbit.spi.RepositoryService;
8 import org.apache.jackrabbit.spi.commons.ItemInfoCacheImpl;
9 import org.apache.jackrabbit.spi2davex.BatchReadConfig;
10 import org.apache.jackrabbit.spi2davex.Spi2davexRepositoryServiceFactory;
11
12
13
14
15
16 public class ClientDavexRepositoryServiceFactory extends Spi2davexRepositoryServiceFactory {
17 @Override
18 public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException {
19
20 String uri;
21 if (parameters == null) {
22 uri = System.getProperty(PARAM_REPOSITORY_URI);
23 } else {
24 Object repoUri = parameters.get(PARAM_REPOSITORY_URI);
25 uri = (repoUri == null) ? null : repoUri.toString();
26 }
27 if (uri == null) {
28 uri = DEFAULT_REPOSITORY_URI;
29 }
30
31
32 BatchReadConfig brc = null;
33 int itemInfoCacheSize = ItemInfoCacheImpl.DEFAULT_CACHE_SIZE;
34 int maximumHttpConnections = 0;
35
36
37
38
39 String workspaceNameDefault = null;
40
41 if (parameters != null) {
42
43 Object param = parameters.get(PARAM_BATCHREAD_CONFIG);
44 if (param != null && param instanceof BatchReadConfig) {
45 brc = (BatchReadConfig) param;
46 }
47
48
49 param = parameters.get(PARAM_ITEMINFO_CACHE_SIZE);
50 if (param != null) {
51 try {
52 itemInfoCacheSize = Integer.parseInt(param.toString());
53 } catch (NumberFormatException e) {
54
55 }
56 }
57
58
59 param = parameters.get(PARAM_MAX_CONNECTIONS);
60 if (param != null) {
61 try {
62 maximumHttpConnections = Integer.parseInt(param.toString());
63 } catch (NumberFormatException e) {
64
65 }
66 }
67
68 param = parameters.get(PARAM_WORKSPACE_NAME_DEFAULT);
69 if (param != null) {
70 workspaceNameDefault = param.toString();
71 }
72 }
73
74 if (maximumHttpConnections > 0) {
75 return new ClientDavexRepositoryService(uri, workspaceNameDefault, brc, itemInfoCacheSize,
76 maximumHttpConnections);
77 } else {
78 return new ClientDavexRepositoryService(uri, workspaceNameDefault, brc, itemInfoCacheSize);
79 }
80 }
81
82 }