Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-15815

Avoid requiring it lambda parameter in Kotlin bean DSL

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Complete
    • Affects Version/s: 5.0 RC3
    • Fix Version/s: 5.0 RC4
    • Component/s: None
    • Labels:
    • Last commented by a User:
      true

      Description

      Based on a proposal by Joseph Taylor from Pivotal Labs London, it is possible to improve Kotlin bean DSL by avoid requiring it lambda parameter using function literals with receiver.

      Spring Framework 5 RC3 syntax:

      beans {
      	bean<Foo>()
      	bean<Bar>("bar")
      	bean { FooFoo(it.env["name"]) }
      	environment({it.activeProfiles.contains("baz")}) {
      		bean { Baz(it.ref()) }
      		bean { Baz(it.ref("bar")) }
      	}
      }
      

      Spring Framework 5 RC4+ syntax:

      beans {
      	bean<Foo>()
      	bean<Bar>("bar")
      	bean { FooFoo(env["name"]) }
      	environment({activeProfiles.contains("baz")}) {
      		bean { Baz(ref()) }
      		bean { Baz(ref("bar")) }
      	}
      }
      

        Activity

        There are no comments yet on this issue.

          People

          • Assignee:
            sdeleuze Sébastien Deleuze
            Reporter:
            sdeleuze Sébastien Deleuze
            Last updater:
            Stéphane Nicoll
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:
              Days since last comment:
              8 weeks, 4 days ago