Uploaded image for project: 'Spring Data for Apache Cassandra'
  1. Spring Data for Apache Cassandra
  2. DATACASS-299

Allow nested, anonymous bean definitions in the XML namespace.

    XMLWordPrintable

    Details

    • Last commented by a User:
      true
    • Sprint:
      Kay RC1, Kay RC3, Kay GA, Kay SR1, Lovelace M1, Lovelace M2 / M3, Lovelace RC1, Lovelace GA, Lovelace SR1, Moore RC1, Moore RC2

      Description

      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>
      

        Attachments

          Activity

            People

            Assignee:
            jblum John Blum
            Reporter:
            jblum John Blum
            Last updater:
            Mark Paluch
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Days since last comment:
              1 year, 11 weeks, 4 days ago

                Time Tracking

                Estimated:
                Original Estimate - 3d
                3d
                Remaining:
                Remaining Estimate - 3d
                3d
                Logged:
                Time Spent - Not Specified
                Not Specified