001: package org.geotools.util;
002:
003: import org.geotools.feature.iso.AttributeFactoryImpl;
004: import org.geotools.feature.iso.FeatureTypes;
005: import org.geotools.feature.iso.TypeBuilder;
006: import org.geotools.feature.iso.simple.ArraySimpleFeatureFactory;
007: import org.geotools.feature.iso.simple.SimpleFeatureBuilder;
008: import org.geotools.feature.iso.simple.SimpleFeatureFactoryImpl;
009: import org.geotools.feature.iso.simple.SimpleFeatureTypes;
010: import org.geotools.feature.iso.simple.SimpleFeatures;
011: import org.geotools.feature.iso.simple.SimpleTypeBuilder;
012: import org.geotools.feature.iso.simple.SimpleTypeFactoryImpl;
013: import org.geotools.feature.iso.type.TypeFactoryImpl;
014: import org.geotools.filter.FilterFactoryImpl;
015: import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
016: import org.picocontainer.defaults.DefaultPicoContainer;
017:
018: import com.vividsolutions.jts.geom.GeometryFactory;
019:
020: /**
021: * This "container" is used by several utility classes to get their game on.
022: * <p>
023: * XXX: Is this class API? or is just here for some utility classes to limp
024: * along?
025: * </p>
026: */
027: public class GTContainer {
028: private static final long serialVersionUID = 9115947621979056700L;
029:
030: /**
031: * This will produce a Container for use with the "default" implementation
032: * of the feature model.
033: * <ul>
034: * <li>TypeFactory
035: * <li>FeatureFactory
036: * <li>(GeometryFactory)
037: * <li>(FilterFactory)
038: * </ul>
039: * We have also included support for the following builders interfaces and
040: * utility classes "out of the box".
041: * <ul>
042: * <li>TypeBuilder
043: * <li>FeatureTypes
044: * <li>FeatureTypes
045: * </ul>
046: *
047: * <p>
048: * TODO: Allow client code to configure
049: *
050: * @return container for "normal" complex content content
051: */
052: public static DefaultPicoContainer normal() {
053: DefaultPicoContainer c = new DefaultPicoContainer();
054:
055: // factories
056: c.registerComponentImplementation(TypeFactoryImpl.class);
057: c.registerComponentImplementation(AttributeFactoryImpl.class);
058: c.registerComponentImplementation(GeometryFactory.class);
059: c.registerComponentImplementation(FilterFactoryImpl.class);
060:
061: // builders (utility classes for creation)
062: c.registerComponent(new ConstructorInjectionComponentAdapter(
063: TypeBuilder.class, TypeBuilder.class));
064:
065: // utilities
066: c.registerComponentImplementation(FeatureTypes.class);
067:
068: return c;
069: }
070:
071: /**
072: * Container used to work with the "simple" implementation of the feature
073: * model.
074: * <ul>
075: * <li>SimpleTypeFactory, also serves as a TypeFactory
076: * <li>SimpleFeatureFactory, also serves as a FeatureFactory
077: * <li>(GeometryFactory)
078: * <li>(FilterFactory)
079: * </ul>
080: * We have also included support for the following builders and utility
081: * classes "out of the box".
082: * <ul>
083: * <li>SimpleTypeBuilder, created each time!
084: * <li>SimpleFeatureBuilder, created each time!
085: * <li>SimpleFeatureTypes
086: * <li>SimpleFeatures
087: * </ul>
088: * TODO: Allow client code to configure
089: *
090: * @return container tweaked for for simple content
091: */
092: public static DefaultPicoContainer simple() {
093: DefaultPicoContainer c = new DefaultPicoContainer();
094:
095: // factories
096: c.registerComponentImplementation(SimpleTypeFactoryImpl.class);
097: c
098: .registerComponentImplementation(SimpleFeatureFactoryImpl.class);
099:
100: c.registerComponentImplementation(GeometryFactory.class);
101: c.registerComponentImplementation(FilterFactoryImpl.class);
102:
103: // builders (utility classes for creation)
104: c.registerComponent(new ConstructorInjectionComponentAdapter(
105: SimpleTypeBuilder.class, SimpleTypeBuilder.class));
106: c
107: .registerComponent(new ConstructorInjectionComponentAdapter(
108: SimpleFeatureBuilder.class,
109: SimpleFeatureBuilder.class));
110:
111: // utilities
112: c.registerComponentImplementation(SimpleFeatureTypes.class);
113: c.registerComponentImplementation(SimpleFeatures.class);
114:
115: return c;
116: }
117:
118: public static DefaultPicoContainer array() {
119: DefaultPicoContainer c = new DefaultPicoContainer();
120:
121: // factories
122: c.registerComponentImplementation(SimpleTypeFactoryImpl.class);
123: c
124: .registerComponentImplementation(ArraySimpleFeatureFactory.class);
125:
126: c.registerComponentImplementation(GeometryFactory.class);
127: c.registerComponentImplementation(FilterFactoryImpl.class);
128:
129: // builders (utility classes for creation)
130: c.registerComponent(new ConstructorInjectionComponentAdapter(
131: SimpleTypeBuilder.class, SimpleTypeBuilder.class));
132: c
133: .registerComponent(new ConstructorInjectionComponentAdapter(
134: SimpleFeatureBuilder.class,
135: SimpleFeatureBuilder.class));
136:
137: // utilities
138: c.registerComponentImplementation(SimpleFeatureTypes.class);
139: c.registerComponentImplementation(SimpleFeatures.class);
140:
141: return c;
142: }
143: }
|