Home > Candidate Patterns > Code On Demand

Code On Demand


How can service consumers be extended or customized at runtime without being upgraded?


Existing service consumers may not be capable of taking advantage of new features when a service contract changes. Also, when using a reusable contract, service consumers may be implemented too generally to sufficiently reflect the individual service's requirements and capabilities. When service consumers cannot be upgraded, services may be prevented from effectively evolving.


Include implementation logic within service capability response messages, and execute this logic within the service consumer.


Service consumers are equipped with a virtual machine for running the logic supplied by the service at runtime. The consumer downloads this logic by invoking service capabilities, and executes it locally.

The virtual machine must itself provide capabilities sufficient to implement useful logic. This includes support for consumer-side processing, the ability to invoke new or specialized service capabilities, and may also include features such as supporting local storage of data and/or supporting user interaction.


Processing effort is further decentralized. Execution occurs in service consumers rather than in services, increasing scalability.

Custom capability invocation is less able to be understood by common network intermediaries than between the service provider and service consumer. Firewalls and caches alike may be unable to perform their usual function.

Executing service logic can significantly increase the area of attack within service consumers for security vulnerabilities.


Inventory, Composition, Service


Under Review


Raj Balasubramanian, Benjamin Carlyle, Cesare Pautasso

Service consumers are extended with additional deferred service logic. Embedding a common virtual machine within service consumers allows their functionality to be extended at runtime. Services can off-load state and processing to consumers, instruct consumers at runtime on how to interact with an extended service contract, and also provide interactions with the underlying hardware and with human users.

Related Patterns in This Catalog

Lightweight Endpoint, Partial State Deferral, Reusable Contract

Related Service-Oriented Computing Goals

Increased Organizational Agility, Reduced IT Burden