Class 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:

    1. Create an instance passing in a list of "bean" classes you wish to publish:
       ProcessFactory factory = new AnnotatedBeanProcessFactory( Text.text("Internal"),"internal", ExampleProcess);
             
    2. 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();
            }
            
    3. 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 {
           ...
       }
       
    • Constructor Detail

    • 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 class AnnotationDrivenProcessFactory
        Parameters:
        name - Process name
        Returns:
        DescribeProcess annotation for the named process
      • 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 class AnnotationDrivenProcessFactory
        Parameters:
        name - Name of the process bean
        Returns:
        intance of process bean; or null if the method is a static method