+ Object instance,
+ Dictionary<String, Object> properties) {
+ ServiceRegistration registration = registerGlobalServiceWReg(clazz, instance, properties);
+ if (registration == null) {
+ logger.error("Failed to register {} for instance {}", clazz, instance);
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * Register a Service in the OSGi service registry and return the ServiceRegistration
+ *
+ * @param clazz The target class
+ * @param containerName The container name
+ * @param instance of the object exporting the service, be careful
+ * the object must implement/extend clazz else the registration
+ * will fail unless a ServiceFactory is passed as parameter
+ * @param properties The properties to be attached to the service
+ * registration
+ * @return the ServiceRegistration if registration happened, null otherwise
+ */
+ public static ServiceRegistration registerServiceWReg(Class<?> clazz, String containerName,
+ Object instance, Dictionary<String, Object> properties) {
+ if (properties == null) {
+ properties = (Dictionary<String, Object>) new Hashtable<String, Object>();
+ }
+ properties.put("containerName", containerName);
+ return registerGlobalServiceWReg(clazz, instance, properties);
+ }
+
+ /**
+ * Register a Global Service in the OSGi service registry
+ *
+ * @param clazz The target class
+ * @param instance of the object exporting the service, be careful
+ * the object must implement/extend clazz else the registration
+ * will fail unless a ServiceFactory is passed as parameter
+ * @param properties The properties to be attached to the service
+ * registration
+ * @return the ServiceRegistration if registration happened, null otherwise
+ */
+ public static ServiceRegistration registerGlobalServiceWReg(Class<?> clazz,
+ Object instance,
+ Dictionary<String, Object> properties) {