Comments (9)
As explain in https://github.com/domino-osgi/domino/blob/master/UserGuide.adoc#listen-to-configuration-changes, it immediately checks, if a configuration with the given PID is available. If not, the passed function is called with an empty map. If you do not want to do anything when no configuration is available, you can simply ignore the empty map and thus the first synchronous call. As soon as Config Admin provides the required configuration, you will be called again with a non-empty map. This is essentially the same behaviour as with implementing ManagedService
from the OSGi spec.
whenConfigurationActive("myServicePid") {
case Map() => // ignore the empty configuration
case confMap => // do something
}
from domino.
Thank you for that answer. If this is semantically the same as pure OSGi I can live with it and the proposed solution. Note however, that on redeploy of a bundle for which a configuration exists, even the first invocation will not actually be an empty map. Both times it will be the same pre-existing configuration, which makes it a little harder to deal with but not impossible. I got around it by caching the current configuration map and comparing when this gets called. If it's the same, do nothing.
from domino.
Thanks for your insights. What you described is not ideal. I'd like to investigate this issue a bit more and will leave it open for now. Do you have, by any change, a small/simple test project to reproduce it?
from domino.
not something I can share here, but this activator exhibits the behavior:
case class Config(topic:String = "metrics",key:String = "MsgKey" ,msg:String = "Testing 123",count:Int = 10, sleep:Int = 1000)
object Config {
def apply(config:Map[String,Any]):ProducerConfig =
Config(config("topic").toString,config("key").toString,config("msg").toString,
config("count").asInstanceOf[Int],config("sleep").asInstanceOf[Int])
}
class Activator extends DominoActivator {
var currentConfig = Config()
whenBundleActive {
/// we REQUIRE the Messaging service
whenServicePresent[Messaging] { messaging ⇒
def servicePid: String = "sampleModule.producer"
val metaTypes = ObjectClass(
id = servicePid,
name = "Sample Producer",
requiredAttributes = List(
ElementaryAttribute[String](id = "topic", name = "topic", default = Some("topic")),
ElementaryAttribute[String](id = "key", name = "key", default = Some("key")),
ElementaryAttribute[String](id = "msg", name = "message", default = Some("msg")),
ElementaryAttribute[Int](id = "sleep", name = "sleep", default = Some(1000)),
ElementaryAttribute[Int](id = "count", name = "count", default = Some(10))
)
)
whenConfigurationActive(servicePid, Some(new SingleMetaTypeProvider(metaTypes))) { config ⇒
val newConfig = Config(metaTypes.defaultConfig ++ config)
if (newConfig != currentConfig) {
currentConfig = newConfig
log.warn("Sample Producer starting")
... // do something using messaging service
} else log.warn(s"Jitter!!!") // second invocation - happens only on (re)deploy
}
}
}
}
I removed the meat, but the structure is obvious, hope it's helpful.
Thanks,
Frank
from domino.
Thank you. As mentioned, I'd like to keep this open for further investigation.
TODOs:
- Formulate desired behaviour
- Test case to reproduce
- Fix
from domino.
The internal logic of ConfigiurationWatcherCapsule
already checks if the configuration has changed, and only recreates the capsule when a change has happened. It seem, this logic is currently buggy...
from domino.
I could fix the issue.
Problem was the comparison of the old and new configuration was made by using java.util.Dictionary.equals
which isn't a good idea if you want a result based on the dictionaries content.
@fsauer65 Could you please verify, that the issue is fixed by master?
from domino.
I verified and can confirm that this behavior is fixed on master, thank you so much!
from domino.
Great, thank you! I'll prepare a 1.1.1 release.
from domino.
Related Issues (17)
- Bulk API to provide and consume services HOT 9
- Create a Maven project redirect for `org.helgoboss:domino` HOT 4
- Remove Logging trait from DominoActivator HOT 1
- Bundle Activator does not implement BundleActivator (Sample App with SBT) HOT 11
- Add support for service factories (bundle specific service instances) HOT 1
- UnsupportedOperationException on container shutdown HOT 1
- typo in url HOT 1
- Error:scalac: Class javax.servlet.ServletException not found - continuing with a stub. HOT 2
- Are there any rules for Capsule ordering of start ? HOT 1
- Provide releases for Scala 2.12
- More logging
- Move project to it's own GitHub organization HOT 1
- Add more documentation to README HOT 1
- Buildsystem should target multiple Scala versions HOT 1
- Enable use of Apache Maven 3.3.3 in Travis CI setup HOT 1
- Request deploy access to groupId "com.github.domino-osgi" at Maven Central HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from domino.