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

Introduce a configurable strategy-based approach to bean property access [SPR-8822] #13464

Closed
spring-projects-issues opened this issue Nov 6, 2011 · 4 comments
Assignees
Labels
in: core status: declined type: enhancement

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Nov 6, 2011

Michael Vorburger opened SPR-8822 and commented

It would be wonderful if the org.springframework.beans.BeanWrapperImpl were a little less "monolithic" than it appears to be today, and had support for some pluggable PropertyAccessStrategy & PropertyMetadataAccessStrategy, à la what package org.springframework.binding in spring-rich-c (from http://www.springsource.org/spring-rcp) appears to have.

The default BeanWrapperImpl would be using an implementation of PropertyAccessStrategy doing what it does today - but one would be apply to supply it other ones, which would, for example, allow directly supporting any kind of more dynamic "Bean" implementations.

Support for DynaBean comes to mind naturally, but beyond DynaBeans as in Apache Commons BeanUtil, pluggable support for dynamic data structures such as simple Maps, Jackson JSON objects, or some XML frameworks in core Spring Beans could allow e.g. SpEL to directly access such data!

I do understand that in theory one could write one's own BeanWrapper implementation (and/or extending AbstractPropertyAccessor & PropertyEditorRegistrySupport, but as there appears to be a lot of logic in them (how to "traverse" / navigate beans, indexed & mapped access etc.) should probably stay inside BeanWrapperImpl - as long as it has some way to extend it.


2 votes, 6 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 6, 2011

Michael Vorburger commented

Without having this, funky tricks like https://issues.apache.org/jira/browse/BEANUTILS-407 are necessary... ;-)

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 8, 2011

Michael Vorburger commented

The org.springframework.expression.PropertyAccessor looks like something related?

I could not find any documentation illustrating how something like this could be made possible with it:

Map<String, Object> struct = new HashMap<String, Object>();
struct.put("name", "Mickey Mouse");
ExpressionParser parser = new SpelExpressionParser();
Expression exp = parser.parseExpression("name");
String name = (String) exp.getValue(struct);
assertEquals("Mickey Mouse", name);

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Nov 12, 2011

Chris Beams commented

Hi Michael,

This is something that we may take a look at in the Spring 3.2 timeline. There are other areas where a strategy-based approach to properties could be helpful, especially with regard to other JVM languages that may have differing conventions for property method signatures.

We'd be interested to hear more about your use case. Is it actually only around DynaBeans as you mentioned above?

Note that it may be possible to achieve what you need via SpEL expressions. Would need to hear more about what you're trying to do.

At any rate, we'll leave this issue 'under consideration' for 3.2 as a place where folks can comment further, add use cases, vote, etc.

Thanks,

Chris

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 9, 2015

Juergen Hoeller commented

We won't be introducing a strategy quite like that anymore, since as a result of the work in #17402, we have a quite powerful AbstractNestablePropertyAccessor base class now that a custom accessor class can be derived from. BeanWrapperImpl itself is rather thin now.

Juergen

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: core labels Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core status: declined type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants