Building adaptive context-aware service-based smart systems