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

Allow nested, anonymous bean definitions in the XML namespace. [DATACASS-299] #470

Closed
spring-projects-issues opened this issue Jun 15, 2016 · 1 comment
Assignees
Labels
in: core status: declined type: enhancement

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Jun 15, 2016

John Blum opened DATACASS-299 and commented

Spring Data Cassandra, XML namespace configuration support is currently limited to bean definition "references" only; i.e. a developer cannot nest anonymous bean definition(s) in another bean definition property in order to effectively limit the scope of the "referenced" bean.

This forces all "referenced" beans to be top-level beans in the Spring context, which exposes their scope beyond it's intended use, which could be problematic for non-Thread-safe (Singleton) beans and such.

By way of example, consider a Session bean declaration with a CassandraConverter.

The beans would currently have to be defined as...

<beans>

  <session keyspace-name = "Example" ... cassandra-converter-ref="ExampleConverter">
    ...
  </session>

  <bean id="ExampleConverter" class="org.springframework.data.cassandra.convert.CassandraConverter"/>

</beans>

However, if the CassandraConverter bean (i.e. "ExampleConverter") was not useful outside the Cassandra Session context (or were stateful in some way), then it is difficult to limit the scope of the bean, unlike an anonymous, nested bean definition, where the above configuration could become...

<beans>

  <session keyspace-name = "Example" ...>
    <cassandra-converter>
        <bean class="org.springframework.data.cassandra.convert.CassandraConverter"/>
    </cassandra-converter>
    ...
  </session>

</beans>

Note, in this example, the nested Converter bean definition has no need for an ID (it is "anonymous"). As well, it's scope is effectively limited to the containing Session bean definition.

Still, a reference could be specified using the following configuration...

<beans>

  <session keyspace-name = "Example" ...>
    <cassandra-converter ref="ExampleConverter"/>
    ...
  </session>

   <bean id="ExampleConverter" class="org.springframework.data.cassandra.convert.CassandraConverter"/>

</beans>

Affects: 1.3.4 (Gosling SR4), 1.4.1 (Hopper SR1)

1 votes, 1 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Jul 11, 2019

Mark Paluch commented

Not going to extend namespace support as this isn't really a requirement

@spring-projects-issues spring-projects-issues added status: declined type: enhancement in: core labels Dec 31, 2020
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