A self-organizing architecture for pervasive ecosystems