14
JACQUARD2005, KNVB HOTEL Zeist 3 en 4 februari 2005 Composing Configurable Java Components Tijs van der Storm, CWI, Project Deliver

Composing Configurable Java Components

  • Upload
    derry

  • View
    32

  • Download
    1

Embed Size (px)

DESCRIPTION

Composing Configurable Java Components. Tijs van der Storm, CWI, Project Deliver. Introduction. Project Deliver: Intelligent Knowledge Management for Software Delivery Focus on release and delivery for product lines This talk: Composing Configurable Java Components - PowerPoint PPT Presentation

Citation preview

Page 1: Composing Configurable Java Components

JACQUARD2005, KNVB HOTEL Zeist 3 en 4 februari 2005

Composing Configurable Java Components

Tijs van der Storm, CWI, Project Deliver

Page 2: Composing Configurable Java Components

Tijs van der Storm - CWI

Introduction

Project Deliver:• Intelligent Knowledge Management for Software Delivery

Focus on release and delivery for product linesThis talk:• Composing Configurable Java Components

How to apply product line technology in a setting where components themselves are configurable?

Page 3: Composing Configurable Java Components

Tijs van der Storm - CWI

Two configurable componentsTrees with two implementations (array and list) and optional traversal

tree

list

array

TreeFactory

«Interface»

TreeFactory

TreeFactory

«aspect»

TreeVisitor

visitors

«aspect»

TreeVisitor

«aspect»

TreeVisitor

Page 4: Composing Configurable Java Components

Tijs van der Storm - CWI

Implementing variation

Programming language imposes restrictions on variation mechanismsUse Java properties to select TreeFactory implementation• Runtime configuration at program start-up.

Use Aspect-Oriented Programming (AOP) to add Visitor design pattern• Trees should implement Visitable interface• AOP is used to add this interface

Page 5: Composing Configurable Java Components

Tijs van der Storm - CWI

Binding Factory implementation

Property used to resolve concrete factoryExample:

treefactory=list.TreeFactory

Dynamic loading and reflection are used to instantiate the factoryConsequences:• Property must be set according to requirements

Page 6: Composing Configurable Java Components

Tijs van der Storm - CWI

Enabling optional Tree traversal

AOP is used to weave in Visitor design patternpublic aspect TreeVisitor {

declare parents: Tree extends Visitable;

public void Tree.accept(Visitor v) {

v.visit(this);

}

}

Consequences:• Build process must call AspectJ• There is a dependency on the Visitors component

Page 7: Composing Configurable Java Components

Tijs van der Storm - CWI

Towards automatic delivery of compositions

Tree component has 4 variants:• array with traversal, array without traversal• list with traversal, list without traversal

How to implement this component family?• How do we set the factory property?• Do we call AspectJ by hand?

Moreover: propagation of variability• What if Visitor component is configurable as well?• How to verify inter-component configuration?

Our approach: component description language• Variability: feature descriptions• Binding: (conditional) binding actions

Page 8: Composing Configurable Java Components

Tijs van der Storm - CWI

Description of variability Tree

Implementation

list array

traversal

Tree: all(Implementation, traversal?)

Implementation: one-of(list, array)

Feature diagrams:

Feature descriptions:

Page 9: Composing Configurable Java Components

Tijs van der Storm - CWI

Description of binding and composition

(Conditional) binding actionsAtomic features function as guards:if (array) { treefactory = array.TreeFactory; }

if (list) { treefactory = list.TreeFactory; }

if (traversal) {

require(visitors);

weave(TreeVisitor);

if (list) { weave(list.TreeVisitor); }

if (array) { weave(array.TreeVisitor); }

}

}

dependency property assignment

aspect weaving

Page 10: Composing Configurable Java Components

Tijs van der Storm - CWI

Component description language (CDL)

Feature descriptions + binding actions = CDLCDL can be formally analyzedFeature descriptions checked for consistencyBinding checked against feature descriptions

Correct configuration guaranteed!

Page 11: Composing Configurable Java Components

Tijs van der Storm - CWI

Benefits

Configurable components are more reusableLocality of variability improves maintenanceConsistency of configuration guaranteedCompositions are automatically derived

Page 12: Composing Configurable Java Components

Tijs van der Storm - CWI

Summary

Configurable Java ComponentsComposition becomes complex:• Configuration correctness• Binding of features

CDL for automation:• Feature descriptions• Binding actions

Page 13: Composing Configurable Java Components

Tijs van der Storm - CWI

End

Deliver project: http://www.cwi.nl/projects/deliverTechnical report availableMore info: http://www.cwi.nl/~storm

Thank you!

Page 14: Composing Configurable Java Components

Tijs van der Storm - CWI

Loading the concrete factory

String cls = System.getProperty(“treefactory");ClassLoader cl = ClassLoader.getSystemClassLoader();TreeFactory tf =

(TreeFactory)cl.loadClass(cls).newInstance();