Red Hat Training

A Red Hat training course is available for Red Hat Fuse

16.2. Create a Custom Context Mapper

Procedure 16.1. Create a Custom Context Mapper

  1. Implement the org.switchyard.component.common.composer.ContextMapper interface:
    public interface ContextMapper<T> {
        void mapFrom(T source, Context context) throws Exception;
        void mapTo(Context context, T target) throws Exception;
    }
    
  2. Specify your implementation in your switchyard.xml file:
    <binding.xyz ...>
        <contextMapper class="com.example.MyContextMapper"/>
    </binding.xyz>
    
    
  3. Alternatively, you can implement the org.switchyard.component.common.composer.RegexContextMapper interface, which adds regular expression support:
    public interface RegexContextMapper<T> extends ContextMapper<T> {
        ContextMapper<T> setIncludes(String includes);
        ContextMapper<T> setExcludes(String excludes);
        ContextMapper<T> setIncludeNamespaces(String includeNamespaces);
        ContextMapper<T> setExcludeNamespaces(String excludeNamespaces);
        boolean matches(String name);
        boolean matches(QName qname);
    }