Contemporary pervasive and cyber-physical application domains make more and more appealing the vision of applications built as a dynamic and opportunistic assembly of autonomous and independent resources. The openness and variability of their operating environments require however the adoption of suitable architectural paradigms for the construction and maintenance of such applications, to make them able to fulfill their goals. In particular, the increasing concern for sustainability issues is making particularly relevant the goal of reducing the application energy footprint. In this context, we contribute by proposing a decentralized architecture to build and maintain a fully functional assembly of distributed services, able to optimize its energy consumption in an open and variable execution environment, paying also attention to issues concerning the delivered quality of service. We also suggest suitable indexes to measure from different perspectives the energy efficiency of the resulting assembly, and present the results of extensive simulation experiments to assess the effectiveness of our approach.