GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||
GeezerVison is showing javaee.github.io — Injecting Objects by Using Producer Methods
Injecting Objects by Using Producer MethodsProducer methods provide a way to inject objects that are not beans,
objects whose values may vary at runtime, and objects that require
custom initialization. For example, if you want to initialize a numeric
value defined by a qualifier named
When you inject the object in another managed bean, the container automatically invokes the producer method, initializing the value to 100:
If the value can vary at runtime, then the process is slightly different. For
example, the following code defines a producer method that generates a
random number defined by a qualifier called
When you inject this object in another managed bean, you declare a contextual instance of the object:
You then call the
Copyright © 2017, Oracle and/or its affiliates. All rights reserved.
| |||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |