Class CompositeClientAdapter

  • All Implemented Interfaces:
    ClientAdapter

    public final class CompositeClientAdapter
    extends Object
    implements ClientAdapter
    Adapter that allows composing multiple adapter implementations. invokes all registered adapters in order in which they were registered, and returns first non-empty match for a name.

    Downstream adapters are registered by constructing a new CompositeClientAdapter.Builder, or method newBuilder()

    Downstream adapters can also be customized by decorators provided by ClientAdapterCustomizer, which allows separating name matching from proxy construction in adapters' implementations.

    See Also:
    ClientAdapterCustomizer
    • Method Detail

      • makeLocalProxy

        public Optional<Object> makeLocalProxy​(String jndiName,
                                               Context remoteContext)
                                        throws NamingException
        Find a client adapter for handling specific jndiName. Composite client adapter will attempt invoking ClientAdapter.makeLocalProxy(String, Context) for all registered adapters in order they were registered in. The iteration ends when
        1. A registered adapter returns non-empty value; or
        2. A registered adapter throws NamingException
        3. All adapters are tried and return empty value
        Specified by:
        makeLocalProxy in interface ClientAdapter
        Parameters:
        jndiName - JNDI name that is being looked up
        remoteContext - EJB HTTP Client naming context for delegating the calls
        Returns:
        adapter object if any of registered client adapters returns one, Optional.empty() otherwise
        Throws:
        NamingException - if any of attempted client adapters throws one