I know that idref is used to pass the id of a bean (i.e String value but not the reference). I was asked in an interview, what can be the use case of idref? Why and when it should be used?
What can be the use case for Spring bean idref?
162 Views Asked by SSC At
1
There are 1 best solutions below
Related Questions in SPRING
- Redirect inside java interceptor
- Spring RestTemplate passing the type of the response
- spring-integration-dsl-groovy-http return null when i use httpGet method
- Custom Spring annotation for request parameters
- Spring - configure Jboss Intros for xml with java config?
- HTTP Status 404 - Not Found in Spring 3.2.7
- AndroidAnnotations how to use setBearerAuth
- android I/O error: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found
- Show login dialog when not authenticated yet
- Spring Data Rest supporting json and xml
- @Value annotation not resolved in a class that belongs to dependency jar
- Remove nested _embedded fields while using projections
- How to send Rest GET request that contains "#" value in url parameters?
- How to inject spring bean into Validator(hibernate)
- How to keep a variable in the URL when using Spring LocaleChangeInterceptor
Related Questions in IOC-CONTAINER
- Attempting to bind Guzzle Curl Client to Laravel's Service Container -- then Type Hint the Client Fails when attempting to __construct()
- How do I use GetAll with Ninject so that one failure doesn't stop the other bindings from resolving?
- Caliburn Micro EventAggregator subscribe/unsubscribe multiple instances of same ViewModel
- Define filter for DecorateAllWith() method in structure-map 3
- Autofac - DelegatingHandler (HttpMessageHandler) Registration
- BeanCurrentlyInCreationException: Error creating bean with name 'scrService'
- Lumen IoC binding resolution spotty within phpunit tests
- The benefits and correct usage of a DI Container
- Is there an Ioc container that supports assembly versioning by reflection?
- Why does laravel IoC does not provisioning my class with my method?
- Is it good practice to inject IUnityContainer into controller class to save extra code
- Using helper methods from Blade returning 'Cannot redeclare Class' error
- Laravel middleware to augment route model binding for security
- Laravel service container is it possible to bind to class AND all it's ancestors - like in Symfony
- Load external environment parameters in Symfony 3.2 using env() at runtime return unresolved values
Related Questions in IDREF
- How to do XML cross referencing?
- Which Java XML binding framework supports circular/cyclic dependencies?
- What can be the use case for Spring bean idref?
- How can I reference XML ids from another XML using XInclude in a way that Webstorm does not mark it as an error?
- HyperJAXB and ID/IDREF
- Circular reference in JSON call bring id and ref thus undefined values to the option list
- Two xsd:id and xsd:idref - XSL:SCHEMA
- DTD syntax for SQL UNIQUE constraint
- Usage of ID/IDREFS in XML Schema
- Usage of IDs / IDREFs in SVG documents
- Copy value of node using reference into other node
- What is the typical maximum length of values of the XML/XSD ID/IDREF types?
- XML DTD's ID and IDREF pointers
- Getting value of tag referenced by id ref
- jaxb unmarshall child @XmlIDREF
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
idrefjust adds a layer of security by validating at deployment time that the referenced, named bean actually exists.A very nice example with appropriate explanation is provided in this link
Example
can also be written as
The advantage of using first way is already described.
If you use the second method then no validation is performed on the value that is passed to the
abcNameproperty of thexyzbean i.e. during the loading of the context.Errors are only discovered when the
xyzbean is instantiated. So, we can never know if any typos have been injected by the developer during the instantiation phase.Note : It is just a recommended approach, not a mandatory approach