- @Override
- public CallbackHandler addingService(ServiceReference<CallbackHandler> reference) {
- NodeKeyRing nodeKeyring = new NodeKeyRing(homeRepository);
- CallbackHandler callbackHandler = bc.getService(reference);
- nodeKeyring.setDefaultCallbackHandler(callbackHandler);
- bc.registerService(LangUtils.names(CryptoKeyring.class, ManagedService.class), nodeKeyring,
- LangUtils.dico(Constants.SERVICE_PID, NodeConstants.NODE_KEYRING_PID));
- return callbackHandler;
- }
+ // Publish home with the highest service ranking
+ Hashtable<String, Object> regProps = new Hashtable<>();
+ regProps.put(NodeConstants.CN, NodeConstants.EGO_REPOSITORY);
+ regProps.put(Constants.SERVICE_RANKING, Integer.MAX_VALUE);
+ Repository egoRepository = new EgoRepository(deployedRepository, false);
+ bc.registerService(Repository.class, egoRepository, regProps);
+
+ // Keyring only if Argeo extensions are available
+ if (argeoDataModelExtensionsAvailable) {
+ new ServiceTracker<CallbackHandler, CallbackHandler>(bc, CallbackHandler.class, null) {
+
+ @Override
+ public CallbackHandler addingService(ServiceReference<CallbackHandler> reference) {
+ NodeKeyRing nodeKeyring = new NodeKeyRing(egoRepository);
+ CallbackHandler callbackHandler = bc.getService(reference);
+ nodeKeyring.setDefaultCallbackHandler(callbackHandler);
+ bc.registerService(LangUtils.names(Keyring.class, CryptoKeyring.class, ManagedService.class),
+ nodeKeyring, LangUtils.dico(Constants.SERVICE_PID, NodeConstants.NODE_KEYRING_PID));
+ return callbackHandler;
+ }