Package org.geotools.process.factory
Class AnnotatedBeanProcessFactory
- Object
-
- AnnotationDrivenProcessFactory
-
- AnnotatedBeanProcessFactory
-
- All Implemented Interfaces:
ProcessFactory
,Factory
,OptionalFactory
- Direct Known Subclasses:
RasterProcessFactory
,VectorProcessFactory
public class AnnotatedBeanProcessFactory extends AnnotationDrivenProcessFactory
Annotation driven process factory; used to wrap up a bunch of Java beans as a single Process Factory.To make use of this class you will need to:
- Create an instance passing in a list of "bean" classes you wish to publish:
ProcessFactory factory = new AnnotatedBeanProcessFactory( Text.text("Internal"),"internal", ExampleProcess);
- Create an implementation of each bean class referenced:
- Annotate the class with
DescribeProcess
:@DescribeProcess( title = "bounds", description = "Computes the overlall bounds of the input features") public class BoundsProcess { ... }
- Supply an execute method (which we can call by reflection):
@DescribeResult(name = "bounds", description = "The feature collection bounds") public ReferencedEnvelope execute( @DescribeParameter(name = "features", description = "Collection whose bounds will be computed") FeatureCollection features) { return features.getBounds(); }
- Annotate the class with
- Optional: If you are using this technique in an environment such as Spring you may wish to
use a "marker interface" to allow Spring to discover implementations on the classpath.
public class BoundsProcess implements GeoServerProcess { ... }
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AnnotatedBeanProcessFactory.BeanFactoryRegistry<T>
Subclass of FactoryRegistry meant for convenience of looking up all the classes that implement a specific bean interface.
-
Field Summary
-
Fields inherited from class AnnotationDrivenProcessFactory
namespace
-
-
Constructor Summary
Constructors Constructor Description AnnotatedBeanProcessFactory(InternationalString title, String namespace, Class<?>... beanClasses)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
createProcessBean(Name name)
Create an instance of the named process bean.Set<Name>
getNames()
List of processes published; generated from the classMap created in the constructuor.protected DescribeProcess
getProcessDescription(Name name)
Used to go through the list of java beans; returning the DescribeProcess annotation for each one.protected Method
method(String className)
Resolves to the execute method for the provided java bean.-
Methods inherited from class AnnotationDrivenProcessFactory
create, getDescription, getImplementationHints, getParameterInfo, getResultInfo, getTitle, getTitle, getVersion, isAvailable, lookupClipOnRenderingArea, lookupCustomizeReadParams, lookupInvertGridGeometry, lookupInvertQuery, supportsProgress
-
-
-
-
Constructor Detail
-
AnnotatedBeanProcessFactory
public AnnotatedBeanProcessFactory(InternationalString title, String namespace, Class<?>... beanClasses)
-
-
Method Detail
-
getProcessDescription
protected DescribeProcess getProcessDescription(Name name)
Used to go through the list of java beans; returning the DescribeProcess annotation for each one.- Specified by:
getProcessDescription
in classAnnotationDrivenProcessFactory
- Parameters:
name
- Process name- Returns:
- DescribeProcess annotation for the named process
-
method
protected Method method(String className)
Resolves to the execute method for the provided java bean.- Specified by:
method
in classAnnotationDrivenProcessFactory
- Returns:
- the "execute" method of the indicated java bean.
-
getNames
public Set<Name> getNames()
List of processes published; generated from the classMap created in the constructuor.- Returns:
- a set of names handled by this process factory
-
createProcessBean
protected Object createProcessBean(Name name)
Create an instance of the named process bean.By having an actual object here we allow implementors to hold onto a bit of state if they wish. The object will need to have an
execute method and be annotated with a describe process annotation. - Specified by:
createProcessBean
in classAnnotationDrivenProcessFactory
- Parameters:
name
- Name of the process bean- Returns:
- intance of process bean; or null if the method is a static method
-
-