Este contenido no está disponible en el idioma seleccionado.
6.6. Exposing POJOs as MBeans
Example 6.8. Exposing an Existing POJO as an MBean
This descriptor exposes an existing POJO as an MBean, and registers it into an MBean server.
To expose a POJO as an MBean, end it with an @JMX annotation, assuming that you have imported
org.jboss.aop.microcontainer.aspects.jmx.JMX
. The bean can either be exposed directly, or in its property.
Example 6.9. Exposing a POJO as an MBean Using Its Property
You can use any of the injection look-up types, by either looking up a plain POJO or getting a handle to an MBean from the MBean server. One of the injection options is to use type injection, sometimes called autowiring, and shown in Example 6.10, “Autowiring”.
Example 6.10. Autowiring
The FromGuice bean injects the Guice bean via type matching, where
PlainPojo
is injected with a common name injection. Now, you can test if Guice binding works as expected, as shown in Example 6.11, “Testing Guice Functionality”.
Example 6.11. Testing Guice Functionality
Example 6.11, “Testing Guice Functionality” only provides an alias component model. The alias is a trivial, but necessary feature. It must be introduced as a new component model inside the Microcontainer, in order to implement it as a true dependency. The implementation details are shown in Example 6.12, “AbstractController Source Code”.
Example 6.12. AbstractController Source Code
This descriptor maps the SpringPojo name to the springPojo alias. The benefit of aliases as true component models is that timing of bean deployment becomes less important. The alias waits in a non-installed state until the real bean triggers it.