sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sseif...@apache.org
Subject svn commit: r1777318 - /sling/site/trunk/content/documentation/development/osgi-mock.mdtext
Date Wed, 04 Jan 2017 14:04:18 GMT
Author: sseifert
Date: Wed Jan  4 14:04:18 2017
New Revision: 1777318

URL: http://svn.apache.org/viewvc?rev=1777318&view=rev
Log:
add example for setting config via ConfigAdmin

Modified:
    sling/site/trunk/content/documentation/development/osgi-mock.mdtext

Modified: sling/site/trunk/content/documentation/development/osgi-mock.mdtext
URL: http://svn.apache.org/viewvc/sling/site/trunk/content/documentation/development/osgi-mock.mdtext?rev=1777318&r1=1777317&r2=1777318&view=diff
==============================================================================
--- sling/site/trunk/content/documentation/development/osgi-mock.mdtext (original)
+++ sling/site/trunk/content/documentation/development/osgi-mock.mdtext Wed Jan  4 14:04:18
2017
@@ -145,6 +145,21 @@ missing if your clean and build the proj
 project again with maven and can run the tests - or use a Maven IDE Integration like m2eclipse.
 
 
+### Provide your own configuration via ConfigAdmin
+
+If you want to provide your own configuration to an OSGi service that you do not register
and activate itself in the mock context you can provide your own custom OSGi configuration
via the mock implementation of the `ConfigAdmin` service.
+
+Example:
+
+    #!java
+
+    ConfigurationAdmin configAdmin = context.getService(ConfigurationAdmin.class);
+    Configuration myServiceConfig = configAdmin.getConfiguration(MY_SERVICE_PID);
+    Dictionary<String, Object> props = new Hashtable<String, Object>();
+    props.put("prop1", "value1");
+    myServiceConfig.update(props);
+
+
 ### Context Plugins
 
 OSGi Mocks supports "Context Plugins" that hook into the lifecycle of each test run and can
prepare test setup before or after the other setUp actions, and execute test tear down code
before or after the other tearDown action.



Mime
View raw message