Skip to content

GSIP 187

Jody Garnett edited this page Mar 14, 2020 · 8 revisions

GSIP 187 - New extension point in ResourcePool for retyping feature types and features

Overview

I would like to propose adding a new extension point in ResourcePool that would allow extensions to retype a feature type, and consequently change the associated features. In practice it would allow us to create extensions that would be able to add\hide attributes, generate new attributes or even just change the values of existing attributes.

Proposed By

Nuno Oliveira

Assigned to Release

This proposal is for GeoServer:

  • 2.17-RC
  • 2.16.3

State

  • Under Discussion
  • In Progress
  • Completed
  • Rejected
  • Deferred

Motivation

For those wondering if the current FeatureTypeCallback doesn't allow us already to do that, the answer is no 😱. FeatureTypeCallBack allows extensions to initiate, and manage, feature types that are generated based on user provided information, for example, SQL views or Solr feature types, but not to change existing types or features.

Proposal

The extensions code will be executed here and here, when a feature type is build (buildFeatureType) and when the source for a feature type is returned (getFeatureSource). The later will allow us to wrap a feature source, setting the feature type we want and\or apply the wrappers we want to the future stream of features.

I'm proposing the following interface for the extension point:

/**
 * Extension point for {@link ResourcePool} allowing us to retype an existing {@link FeatureType},
 * and to rearrange the features produced by the correspondent {@link FeatureSource} by wrapping it.
 * This extension point can be, for example, used to add a new attribute or remove an existing one.
 * If the intend is instead to create a new feature type, the existing {@link FeatureTypeCallback}
 * extension point should be used.
 */
public interface RetypeFeatureTypeCallback {

    /**
     * Gives a chance to this callback to retype the provided feature type, if this callback has no
     * interest in retyping the provided feature type, then the unchanged provided feature type
     * should be returned. NULL should never be returned.
     *
     * @param featureTypeInfo non NULL GeoServer feature type info
     * @param featureType non NULL GeoTools data source feature type
     * @return retyped feature type or the unchanged provided feature type
     */
    default FeatureType retypeFeatureType(FeatureTypeInfo featureTypeInfo, FeatureType featureType) {
        return featureType;
    }

    /**
     * Gives a chance to this callback to wrap the provided feature source, if this callback has no
     * interest in wrapping the provided feature source, then the unchanged provided feature source
     * should be returned. NULL should never be returned.
     *
     * @param featureTypeInfo non NULL GeoServer feature type info
     * @param featureSource non NULL GeoTools feature source
     * @return wrapped feature source or the unchanged provided feature source
     */
    default <T extends FeatureType, U extends Feature> FeatureSource<T, U> wrapFeatureSource(
            FeatureTypeInfo featureTypeInfo, FeatureSource<T, U> featureSource) {
        return featureSource;
    }
} 

Backwards Compatibility

No backwards compatibility issues are foreseen, this change is a small addition that will only have impact if an extension using the new extensions points is provided.

Feedback

Mailing list discussion available here.

Voting

Project Steering Committee:

  • Alessio Fabiani:
  • Andrea Aime:+0
  • Ian Turton:+1
  • Jody Garnett: +1
  • Jukka Rahkonen:
  • Kevin Smith:
  • Simone Giannecchini:+0
  • Torben Barsballe:+1
  • Nuno Oliveira:+0

Links

Clone this wiki locally