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;
    }
    
    Copy to Clipboard Toggle word wrap
  2. Specify your implementation in your switchyard.xml file:
    <binding.xyz ...>
        <contextMapper class="com.example.MyContextMapper"/>
    </binding.xyz>
    
    
    Copy to Clipboard Toggle word wrap
  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);
    }
    
    
    Copy to Clipboard Toggle word wrap
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2026 Red Hat