Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Adding AdapterFinderBean and interceptor functionality.#34744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
joe-chambers wants to merge1 commit intospring-projects:main
base:main
Choose a base branch
Loading
fromjoe-chambers:adapter-locator

Conversation

@joe-chambers
Copy link

AdapterFinderBean and AdapterFinderInterceptor allow for similar functionality to ServiceLocatorFactoryBean but without the call from the client to find the appropriate service bean for each call. This crosscutting concern can be implemented in an "AdapterFinderBean" used by an "AdapterFinderInterceptor" proxy bean that directs the method call to the "Adapter" returned by the "AdapterFinderBean"

Problem:

A business logic process such as "shipping" requires access to multiple services i.e. UPS, USPS, DHL, and FEDEX existing solutions at best require cluttering the client space with calls to find the service and then call it. When expanding from a single shipping service to an array of adapters this requires significant changes throughout the coad base with client pollution.

Solution:

In order to reduce the client side polution and make a flexible system, an AdapterFinderBean can be implemented so that it has access to each implementation by "Qualifier" and based on one or more of the method parameters (TenantId, CustomerId, OrderId, etc...) the finder determines which implementation of the defined Adapter interface to return.

Example

Each implementation has an Adapter implementation of a defined interface e.g. UPSShippingAdapter, USPSShippingAdapter, DHLShippingAdapter, and FEDEXShippingAdapter all implementations of the ShippingAdapter interface.

A "Finder" ShippingAdapterFinder implements the AdapterFinderBean with qualifier based access to all of the ShippingAdapter implementations. The finder returns the appropriate implementation based on the parameters passed in to each call such as TenantId, CustomerId, OrderId, and etc....

The AdapterFinderInterceptor is used to construct a "Proxy" of the ShippingAdapter that will query the "ShippingAdapterFinder" to determine which concrete implementation to pass the method call on to.

Additionally this same structures could be used to lookup based on feature flags, or properties (potentially a beta vs legacy) or versions i.e. a telephone system where the east coast (US) has upgraded from version 14 of the SIP server to version 16, but central, and west coast (US) have not.

Further

It is thought that a spring-cloud or spring-boot implementation could look through the bean definition registry to find implementations of the AdapterFinderBean, and create a "Primary" instance of the interface the AdapterFinderBean returns that is proxy bean that uses the finder in the application context.

Please excuse the terminology, you probably have better terminology this is my first PR into the spring ecosystem.

AdapterFinderBean and AdapterFinderInterceptor allow for similarfunctionality to ServiceLocatorFactoryBean but without the call fromthe client to find the appropriate service bean for each call.It would be anticipated that spring-boot functionality would becreated in the future to search the bean definition registry afterthe registry is created to find finder beans and build proxies forthe interfaces exposed by them and register those implementationswithin the application context.Signed-off-by: Joe Chambers <25091819+joe-chambers@users.noreply.github.com>
@spring-projects-issuesspring-projects-issues added the status: waiting-for-triageAn issue we've not yet triaged or decided on labelApr 12, 2025
@bclozelbclozel added the in: coreIssues in core modules (aop, beans, core, context, expression) labelJun 3, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: waiting-for-triageAn issue we've not yet triaged or decided on

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@joe-chambers@bclozel@spring-projects-issues

[8]ページ先頭

©2009-2025 Movatter.jp