DPML
DPML Metro Component Parts
HomeUtilitiesStationMetro
Component Parts

The Metro runtime provides support for:

Declaration of the stuctural presumptions of a component is achieved though a Parts interface exposed as a constructor parameter. A Parts interface is recognized using either the default inner class pattern, or via the assertion of part-semanitcs using the parts annotation. The following code fragment demonstrates a component that declares its internal structure via an internal Parts inner interface and the usage of that interface as a constructor parameter.

public class Container
{
    public interface Parts
    {
        Widget getWidget();
        Gizmo[] getGizmos();
    }
    
    public Container( final Parts parts )
    {
        Widget widget = parts.getWidget();
        Gizmo[] gizmos = parts.getGizmos();
        
        ...
        
    }
    
    ...
}
Parts Interface Semantics

Semantics of the parts interface focus on the supply of internal components to an enclosing component using either of the following patterns:

  • Access to a sub-component by key where the the return type is a single value and the key is determined in accordance with JavaBean naming conventions. The method may declare at most one parameter where the parameter type is a class corresponding to the desited return type.
  • access to a set of sub-components based on the type of an array return type of the method

On instantiation Metro will supply a implementation of the parts interface wherin subsidiary parts will by default only be instantiated on demand. Furthermore, it is the responsibility of the enclosing component to main the appropriate hard, soft or weak refernce to the sub-component.

On termination of the enclosing component, all sub-component will be be subject to implicit termination.