Class TransformationClassSelector

java.lang.Object
org.chenile.core.interceptors.BaseChenileInterceptor
org.chenile.core.transform.TransformationClassSelector
All Implemented Interfaces:
Command<ChenileExchange>

public class TransformationClassSelector extends BaseChenileInterceptor
Selects the target Java type for the request body and stores it in ChenileExchange.getBodyType() for the following Transformer interceptor.

Selection runs in this order:

  1. An operation-level body type selector, if configured.
  2. Otherwise, a service-level body type selector, if configured.
  3. Otherwise, the static operation and BODY parameter metadata, resolved by setDefaultBodyType(ChenileExchange).
A registered selector owns the decision; the static fallback is used only when neither selector is present. On the default path, the chosen Type is kept in a TypeReference so that parameterized request bodies, such as List<MyRequest>, retain their element type through JSON conversion. A configured selector is responsible for setting the exchange body type. The following Transformer uses this type to convert raw JSON, decoded maps, decoded collections, and JSON nodes before service arguments are bound. Already-compatible decoded values are preserved, and ordinary Java object bodies are passed through unchanged.
Author:
Raja Shankar Kolluru
  • Constructor Details

    • TransformationClassSelector

      public TransformationClassSelector()
  • Method Details

    • doPreProcessing

      public void doPreProcessing(ChenileExchange exchange)
      Description copied from class: BaseChenileInterceptor
      Override this to do pre-processing. This will be called before the service is invoked. Don't expect to see exception or response being set in ChenileExchange. However you can check for ChenileExchange.getBody() to manipulate the body if this interceptor is a Chenile post processor or a service specific or operation specific interceptor.
      If this interceptor is a Chenile pre-processor, then ChenileExchange.getBody() will return null. Then you need to look at headers only.
      Overrides:
      doPreProcessing in class BaseChenileInterceptor
      Parameters:
      exchange -
    • obtainBodyTypeSelector

      private Command<ChenileExchange> obtainBodyTypeSelector(ChenileExchange exchange)
    • setDefaultBodyType

      private void setDefaultBodyType(ChenileExchange exchange)
    • convertClassToTypeReference

      public static tools.jackson.core.type.TypeReference<?> convertClassToTypeReference(Class<?> clazz)
    • convertTypeToTypeReference

      public static tools.jackson.core.type.TypeReference<?> convertTypeToTypeReference(Type type)