+ }
+ }
+
+ private static void registerRemoteInit(String uri) {
+ try {
+ BundleContext bundleContext = KernelUtils.getBundleContext();
+ Repository repository = createRemoteRepository(new URI(uri));
+ Hashtable<String, Object> properties = new Hashtable<>();
+ properties.put(NodeConstants.CN, NodeConstants.NODE_INIT);
+ properties.put(LdapAttrs.labeledURI.name(), uri);
+ properties.put(Constants.SERVICE_RANKING, -1000);
+ bundleContext.registerService(Repository.class, repository, properties);
+ } catch (RepositoryException e) {
+ throw new JcrException(e);
+ } catch (URISyntaxException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+ private static Repository createRemoteRepository(URI uri) throws RepositoryException {
+ RepositoryFactory repositoryFactory = new ClientDavexRepositoryFactory();
+ Map<String, String> params = new HashMap<String, String>();
+ params.put(ClientDavexRepositoryFactory.JACKRABBIT_DAVEX_URI, uri.toString());
+ // TODO make it configurable
+ params.put(ClientDavexRepositoryFactory.JACKRABBIT_REMOTE_DEFAULT_WORKSPACE, NodeConstants.SYS_WORKSPACE);
+ return repositoryFactory.getRepository(params);