A Framework for Rule-Based Dynamic Adaptation