Class CompositeClientAdapter
- java.lang.Object
-
- fish.payara.ejb.http.client.adapter.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 methodnewBuilder()
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CompositeClientAdapter.Builder
Builder for composite Client Adapter.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Optional<Object>
makeLocalProxy(String jndiName, Context remoteContext)
Find a client adapter for handling specificjndiName
.static CompositeClientAdapter.Builder
newBuilder()
Convenience method for constructing aCompositeClientAdapter.Builder
-
-
-
Method Detail
-
makeLocalProxy
public Optional<Object> makeLocalProxy(String jndiName, Context remoteContext) throws NamingException
Find a client adapter for handling specificjndiName
. Composite client adapter will attempt invokingClientAdapter.makeLocalProxy(String, Context)
for all registered adapters in order they were registered in. The iteration ends when- A registered adapter returns non-empty value; or
- A registered adapter throws
NamingException
- All adapters are tried and return empty value
- Specified by:
makeLocalProxy
in interfaceClientAdapter
- Parameters:
jndiName
- JNDI name that is being looked upremoteContext
- 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
-
newBuilder
public static CompositeClientAdapter.Builder newBuilder()
Convenience method for constructing aCompositeClientAdapter.Builder
- Returns:
- new builder instance
-
-