# The pattern package

This package contains a set of design patterns implemented with the JaxMe JavaSource generator framework. It is provided both for demonstration and actual use. Each pattern is accompanied with a corresponding Ant task that allows to invoke the respective generator from within an Ant build script. The patterns are:

Design pattern(s) | Class | Ant task | Description
--- | --- | --- | ---
Proxy objects Multiple inheritance | {@link org.apache.ws.jaxme.js.pattern.ProxyGenerator} | proxyGenerator | Proxy are instances that delegate most or all method calls to another object. Proxy objects in Java are typically created by the class {@link java.lang.reflect.Proxy}. Compared to this class, the generator has the advantage, that it is much easier to adapt the proxy object to your own needs: In our case you simple subclass the generated Proxy class. Proxy objects can also be used to implement something like multiple inheritance. This is demonstrated in the Unit test {@link org.apache.ws.jaxme.js.junit.MultipleInheritanceTest}, where a subclass of {@link java.util.Observable} is created, that is also an instance of {@link java.util.List} by inheriting from {@link java.util.ArrayList}.
Typesafe enumerations | {@link org.apache.ws.jaxme.js.pattern.TypesafeEnumerationGenerator} | enumGenerator | A typesafe enumeration is a Java class that guarantees that only a specified set of instances can exist. These instances are part of the class and accessible through public, static, final fields.
Proxy chains | {@link org.apache.ws.jaxme.js.pattern.ChainGenerator} | chainGenerator | A proxy chain can be viewed as a set of event handlers implementing a common interface. The interface methods are the events being processed. Each element in the chain can decide to process an event alone (by returning immediately), to delegate the event to the next element in the chain (by calling the interface method in its superclass) or to post process the result of the delegated event.