This class sets up a sample container with the default implementations
implemented by module main.
For the test container we are using PicoContainer because it is well suited
to quick sanity checks like test cases. For a real industrial strength
solution please use something like Spring or JBoss containers (both of which
can be used in a client application and can be configured via XML).
The following are avaiable:
- TypeFactory - TypeFactoryImpl
- AttributeFactory - TypeFactoryImpl
With this as a base instances of the following builders can be requested,
they will arrive ready to go with no additional setup.
- TypeBuilder - TypeBuilderImpl
- ComplexAttributeBuilder - ComplexAttributeBuilderImpl
Here is a sample use:
TestContainer container = new TestContainer();
ComplexAttributeBuilder builder = TestContainer
.getComponentInstanceOfType(ComplexAttributeBuilder.class);
build.setType(roadFeatureType); // aka a FeatureType
Feature road1, road2;
road1 = builder.add("name", "hwy 31a").add("geom", hwy1).build("Road.31a");
road2 = builder.add("name", "hwy 32").add("geom", hwy2).build("Road.32");
For a discussion of the pros/cons using a container please review the
developers documentation. Or try writing any geotools program using the
"traditional" FactoryFinder approach.
author: Jody Garnett, Refractions Research Inc. |