]> git.argeo.org Git - lgpl/argeo-commons.git/blob - ClientDavexRepositoryServiceFactory.java
2af0835ea222888582e91b84ea0bd3ba27d999aa
[lgpl/argeo-commons.git] / ClientDavexRepositoryServiceFactory.java
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 * Wrapper for {@link Spi2davexRepositoryServiceFactory} in order to create a
14 * {@link ClientDavexRepositoryService}.
15 */
16 public class ClientDavexRepositoryServiceFactory extends Spi2davexRepositoryServiceFactory {
17 @Override
18 public RepositoryService createRepositoryService(Map<?, ?> parameters) throws RepositoryException {
19 // retrieve the repository uri
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 // load other optional configuration parameters
32 BatchReadConfig brc = null;
33 int itemInfoCacheSize = ItemInfoCacheImpl.DEFAULT_CACHE_SIZE;
34 int maximumHttpConnections = 0;
35
36 // since JCR-4120 the default workspace name is no longer set to 'default'
37 // note: if running with JCR Server < 1.5 a default workspace name must
38 // therefore be configured
39 String workspaceNameDefault = null;
40
41 if (parameters != null) {
42 // batchRead config
43 Object param = parameters.get(PARAM_BATCHREAD_CONFIG);
44 if (param != null && param instanceof BatchReadConfig) {
45 brc = (BatchReadConfig) param;
46 }
47
48 // itemCache size config
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 // ignore, use default
55 }
56 }
57
58 // max connections config
59 param = parameters.get(PARAM_MAX_CONNECTIONS);
60 if (param != null) {
61 try {
62 maximumHttpConnections = Integer.parseInt(param.toString());
63 } catch (NumberFormatException e) {
64 // using default
65 }
66 }
67
68 param = parameters.get(PARAM_WORKSPACE_NAME_DEFAULT);
69 if (param != null) {
70 workspaceNameDefault = param.toString();
71 }
72 }
73
74 // FIXME adapt to changes in Jackrabbit
75 // if (maximumHttpConnections > 0) {
76 // return new ClientDavexRepositoryService(uri, workspaceNameDefault, brc, itemInfoCacheSize,
77 // maximumHttpConnections);
78 // } else {
79 // return new ClientDavexRepositoryService(uri, workspaceNameDefault, brc, itemInfoCacheSize);
80 // }
81 return null;
82 }
83
84 }