DPML
DPML Metro Controller
HomeUtilitiesStationMetroDepotTransit
Controllers

Throught the Metro runtime there is general concept of separation of model and controller. At the very top-level is the main net.dpml.metro.runtime.CompositionController class which handles component establishment.

A reference to the default controller is resolved using the net.dpml.component.Controller interface:

Controller controller = Controller.STANDARD;

While the operations exposed by a controller are rather limited, the semantics concerning delegation are somewhat deeper and worthy of a brief discussion.

The Controller interface defines operations enabling:

Operations dealing with network-accessible parts potentially involve a process of delegation by the default controller to a controller asserted by the part datatype. This delegation process will result in the potential establishment of a different controller supporting a foreign component implementation (or more specifically a controller with an alternative or legacy implementation strategy).The default controller will locate a URI from a part, load the foreign controller (if required) in an isolated classloader, and delegate part loading to that controller.

Operations dealing with the construction of a component from a model are focussed around the requirements for management acess to the component model. The Controller interface allows the construction of a component model and subsequent creation of a Component using a supplied model. This separation allows for potentially different versions of managed models and components to co-exist in the same runtime environment.

Example

The following snipet of code demonstrates the creation of a component using a part uri.

Controller controller = Controller.STANDARD;
URI uri = new URI( "artifact:part:acme/acme-widget#1.1" );
Component component = controller.createComponent( uri );
Provider provider = component.getProvider();
Widget widget = (Widget) provider.getValue( true );
        
Techical Notes

All controllers must implement the net.dpml.component package API. Through reference this implies support for the net.dpml.state package and a soft dependency on the protocol handlers defined within the net.dpml.transit resource management layer. Implementation of alternative controllers is not covered here - however, examination of the net.dpml.metro.runtime package is the recommended starting point. Developers dealing with legacy applications and in particular the encapsulation of lagacy products as first-class components should consider the potential benefits of a dedicated controller implementation.