link
Avalon
Planet - Facilities
Home PlanetProductsCentral
Reflector - Components
API and SPI

The Reflector facility is broken into a API and a SPI. The API defines the ReflectorService which other components can query easily lookup instances in the system. The SPI defines the ReflectorProvider, where TypeHandler register themself for handling of 'special-cases'.

Implementation

The implementation is also broken apart along the API and SPI axis. The impl project contains the ReflectorImpl which implements both the ReflectorService as well as the ReflectorProvider. The same project also contains a small component that registers the composition model, as a root object in the Reflector. The ReflectionHandler is an implementation of the HttpHandler for the Http Facility, which handles the incoming HTTP requests, which are delegated to the ReflectorImpl, and then formatted into HTML.

The typehandlers project contains all the handlers for different types. ObjectTypeHandler is the default handler which will be used for all objects not implementing any of the other types. MapTypeHandler for java.util.Map instances, and the equivalent for the CollectionTypeHandler and the DictionaryTypeHandler. The ArrayTypeHandler handles arrays of objects and finally the ComponentModelTypeHandler deals with some special handling of ComponentModel instances, i.e. enabling reaching the implementation instance.

Services
Class Purpose
org.apache.metro.facilities.reflector.ReflectorService The ReflectorService defines a text formatted instrospection method. Any object instance which are coded according to the JavaBeans pattern, can be looked up over the various methods in this service. The names can be cascaded with dot separation, and the service will traverse the instances to locate the object requested.
org.apache.metro.facilities.reflector.spi.ReflectorProvider TypeHandlers needs to register themself at this service. Each Typehandler is responsible to locate this provider and register which interface/class they are designed to process.
org.apache.metro.facilities.reflector.spi.TypeHandler The reflector architecture allows additional special-case handling of any interface/class. Currently, object of classes implementing multiple registered types at the ReflectorProvider are defined as 'not supported' by the specification. Implementations are free to provide resolutions for such cases.
Component Definitions
Name Class Purpose
reflector org.apache.metro.facilities.reflector.impl.ReflectorImpl The default reflector implementation. You will need this component as it implements both the ReflectorService as well as the ReflectorProvider.
reflector-http-handler org.apache.metro.facilities.reflector.impl.ReflectionHandler The ReflectionHandler is a component that will register itself to a HttpContext of the Http Facility and serve incoming requests. Requests are decoded, delegated to the ReflectionService and the result returned is formatted into simple HTML.
model-registrator org.apache.metro.facilities.reflector.impl.ModelRegistrator This small and simple component looks up the composition model and adds the root model container as a root object to the ReflectorService, via the addRootObject method.
type-handler-array org.apache.metro.facilities.reflector.typehandlers.ArrayTypeHandler A TypeHandler that handles java object arrays.
type-handler-collection org.apache.metro.facilities.reflector.typehandlers.CollectionTypeHandler A TypeHandler that handles java.util.Collection implementations.
type-handler-componentmodel org.apache.metro.facilities.reflector.typehandlers.ComponentModelTypeHandler A TypeHandler that handles instances implementing org.apache.avalon.composition.model.CompositionModel.
type-handler-dictionary org.apache.metro.facilities.reflector.typehandlers.DictionaryTypeHandler A TypeHandler that handles java.util.Dictionary subclasses. Warning! The java.util.Hashtable is both a Dictionary subclass as well as implementing the Map interface. You should NOT use this TypeHandler unless you have other classes that extends the java.util.Dictionary class.
type-handler-map org.apache.metro.facilities.reflector.typehandlers.MapTypeHandler A TypeHandler that handles instances of classes tha implements java.util.Map.
type-handler-object org.apache.metro.facilities.reflector.typehandlers.ObjectTypeHandler A TypeHandler that handles instances of all other java classes.