Current solutions for hybrid grid/cloud computing have been developed to hide from heterogeneity, dynamicity, and distributed nature of resources. These solutions are, however, insufficient to support distributed applications with non-trivial communication patterns among processes or that are structured so as to reflect the organization of resources they are deployed onto. In this paper, we present a generic, adaptable, and extensible component-based middleware that seamlessly enables a transition of non-trivial applications from traditional grids to hybrid grid-cloud platforms. This middleware goes beyond the resolution of well-known technical challenges for multi-domain computing, as it offers mechanisms to exploit the hierarchical, heterogeneous, and dynamic natures of platforms. We validate its capabilities and versatility through two use cases: an Internet-wide federation of Distributed Service Buses and a runtime supporting DD high-performance computing in heterogeneous computing environments using programming that is similar to message-passing interface. Performance results show the efficiency and usefulness of our middleware and so contribute to promote research efforts geared toward flexible, on-demand information technology solutions. Copyright The intention of these experiments is to compare three different scenarios with the same application: the first using MPICH, the second using GridMPI, and the third using a gridified implementation using the DiscoGrid API/runtime. All the three scenarios make use of the DiscoGrid partitioner to handle resource heterogeneity, but only the gridified version takes profit of the multi-level partitioning.These experiments were conducted in the Grid5000 testbed, on eight different clusters spread all around France (in Sophia Antipolis, Lyon, Toulouse, and Rennes), composed of machines of different processor architectures (Intel Xeon EM64T 3GHz, AMD Opterons 248 and 285) and memory from 2 to 8 GB by node. Cluster nodes are connected by gigabit ethernet switches, except two