Skip to content

Commit

Permalink
Recommend ObjectProvider as alternative to @lazy for optional depende…
Browse files Browse the repository at this point in the history
…ncies

Closes gh-27649
  • Loading branch information
jhoeller committed Nov 9, 2021
1 parent 17c3976 commit f0de3a9
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 69 deletions.
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,6 +47,11 @@
* or {@link javax.inject.Inject}: In that context, it leads to the creation of a
* lazy-resolution proxy for all affected dependencies, as an alternative to using
* {@link org.springframework.beans.factory.ObjectFactory} or {@link javax.inject.Provider}.
* Please note that such a lazy-resolution proxy will always be injected; if the target
* dependency does not exist, you will only be able to find out through an exception on
* invocation. As a consequence, such an injection point results in unintuitive behavior
* for optional dependencies. For a programmatic equivalent, allowing for lazy references
* with more sophistication, consider {@link org.springframework.beans.factory.ObjectProvider}.
*
* @author Chris Beams
* @author Juergen Hoeller
Expand Down

0 comments on commit f0de3a9

Please sign in to comment.