Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a method to get the original bean name from a scoped target's bean name #23514

Closed
wilkinsona opened this issue Aug 23, 2019 · 4 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@wilkinsona
Copy link
Member

We have a case in Spring Boot's @SpyBean support where we need to get the original bean name from a scoped target. ScopedProxyUtils provides a method to go from the original to the scoped target name but not the other way around. Could such a method be added please?

For the time being, we'll probably do something like this:

if (ScopedProxyUtils.isScopedTarget(beanName)) {
	beanName = beanName.substring("scopedTarget.".length());
}
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Aug 23, 2019
@sbrannen sbrannen added in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Aug 25, 2019
@sbrannen sbrannen added this to the 5.2 RC2 milestone Aug 25, 2019
@sbrannen sbrannen self-assigned this Aug 25, 2019
sbrannen added a commit that referenced this issue Aug 25, 2019
@sbrannen
Copy link
Member

@wilkinsona, let me know if this (9be6aa6) is sufficient for you.

@wilkinsona
Copy link
Member Author

It is indeed. Thank you. Could this be considered for a backport to 5.1.x please? It's not essential by any means, but we have the same substring logic in Boot 2.1 and 2.2 and it would be nice to be able to use getOriginalBeanName in both branches if possible.

@sbrannen sbrannen modified the milestones: 5.2 RC2, 5.1.10 Aug 27, 2019
@sbrannen
Copy link
Member

Sure, we'll go ahead and backport this to 5.1.

@sbrannen sbrannen reopened this Aug 27, 2019
sbrannen added a commit that referenced this issue Aug 27, 2019
@sbrannen
Copy link
Member

Backported to 5.1.10 in 9d2a874.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants