A Declarative Framework for Adaptable Applications in Heterogeneous Environments