public final class ClientAdapterCustomizer extends Object implements ClientAdapter
Most common use case is represented by method matchPrefix(String)
: Given the prefix, the downstream
adapter is only called when requested name matches prefix, and it is invoked with the prefix stripped from name.
Class is intended to use as static import during construction of CompositeClientAdapter
.
import static fish.payara.ejb.http.client.adapter.ClientAdapterCustomizer.*;
...
CompositeClientAdapter.builder()
.register(customize(JmsStubAdapter.class).matchPrefix("java:comp/jms"),
customize(new ConnectionFactoryStub()).matchName(Pattern.compile("jms/.+Factory")::matches))
.build()
Modifier and Type | Method and Description |
---|---|
static ClientAdapterCustomizer |
customize(Class<? extends ClientAdapter> adapterClass)
Create customizer of given class.
|
static ClientAdapterCustomizer |
customize(ClientAdapter adapterInstance)
Create customizer decorating given instance.
|
static ClientAdapterCustomizer |
customize(Supplier<ClientAdapter> adapterSupplier)
Create customizer decorating given supplier.
|
Optional<Object> |
makeLocalProxy(String jndiName,
Context remoteContext)
Call downstream adapter when name matches, with jndiName parameter transformed.
|
ClientAdapterCustomizer |
matchName(Predicate<String> name)
Return new customizer with specified predicate for matching a name.
|
ClientAdapterCustomizer |
matchPrefix(String prefix)
Return new customizer that matches given prefix, and strips the prefix from the name before invoking downstream
adapter.
|
ClientAdapterCustomizer |
transformName(Function<String,String> nameTransformation)
Return new customizer with specified name transformation function.
|
public Optional<Object> makeLocalProxy(String jndiName, Context remoteContext) throws NamingException
makeLocalProxy
in interface ClientAdapter
jndiName
- jndi name requested for lookupremoteContext
- naming context for remote EJB invocationNamingException
- when downstream adapter throws onepublic ClientAdapterCustomizer matchName(Predicate<String> name)
name
- predicate for matching namepublic ClientAdapterCustomizer transformName(Function<String,String> nameTransformation)
matchName(Predicate)
passesnameTransformation
- JNDI name transformationpublic ClientAdapterCustomizer matchPrefix(String prefix)
prefix
- JNDI name prefix to match and strippublic static ClientAdapterCustomizer customize(Class<? extends ClientAdapter> adapterClass)
adapterClass
- public static ClientAdapterCustomizer customize(ClientAdapter adapterInstance)
adapterInstance
- public static ClientAdapterCustomizer customize(Supplier<ClientAdapter> adapterSupplier)
adapterSupplier
- Copyright © 2019. All rights reserved.