The Carbon Java Framework  

The Carbon Core Component Subsytem

Component Delegation Design Alternatives

Printer Friendly Version

Author: Greg Hinkle (ghinkl at
Version: $Revision: 1.2 $($Author: dvoet $ / $Date: 2003/04/08 14:46:46 $)
Created: January 2002


To supply the Carbon Component Framework with generic delegation we looked at a number of options. To be truely generic the system needed an aggregating object that would handle the inclusion and the delegation to any set of helper objects. In addition, this system needed to be able to deal with helpers that are written after the development of the core system and with features that could not be known at the time of the Core Framework's design.

The generic delegation also had to be able to handle any component to be written by client developers of the framework. This meant it had to be able to assume the identity of that Component Implementation and provide its functionality as well as that of the addition helper or infrastructure feature providers.

In order to accomplish this we considered the following options:

  • Dynamic Proxies
  • Runtime Code Generation
  • Compile Time Code Generation
  • Weakly-typed Message Driven Model
  • Hand Coding

Dynamic Proxies

JDK 1.3 added the new functionality of Dynamic Proxies to the core JDK. This functionality provides for a mechanism to implement, at runtime, any interface in the system, through a generic message implementation. This system provides for the dynamic construction of implementing classes that are based upon generic method handlers called Invocation Handlers. This system provides a simple mechanism to provide generic delegation to a set of Objects that isn't determined by the system until runtime. This allows the configuration and construction of a Dynamic Proxy to control the features added to a client component and how the system interacts with that component.

Benefits Downsides
Strong Typing Requires JDK 1.3
Minimal client effort Possible Performance Impact
Moderate Implementation Difficulty  
Extreme Flexibility  

Runtime Code Generation

There is code available that will generate byte code for classes. This could be used at runtime to generate dynamic classes to handle the required functionality. The problem with this is in the risk having to dynamically load class implementations. This type of work would likely have an impact on the design of the classloader interaction. We are attempting to keep classloader issues to a minimum by not doing anything that is fancy or overcomplicated.

Benefits Downsides
Strong Typing Risky for us
Minimal client effort Difficult To Implement
Performance Possible Classloader Issues

Compile Time Code Generation

We could implement a custom code generation system that would build proxies for each component from a set of metadata provided by the developer.

Benefits Downsides
Strong Typing No Flexibility at Runtime
Minimal client effort Difficult To Implement
Performance Developers Need to Provide Metadata

Weakly-Typed Messaging

Instead of providing strong interfaces to functionality we could have people call methods by passing definition objects that tell us what methods to run.

Benefits Downsides
  Loose Typing
  Reflection Needed

Copyright © 2001-2003, Sapient Corporation