이 콘텐츠는 선택한 언어로 제공되지 않습니다.
29.2.3. Deployment Via a -jboss-beans.xml File
Much like it can deploy MBean services described with a
-service.xml
, JBoss Enterprise Application Platform 5 can also deploy services that consist of Plain Old Java Objects (POJOs) if the POJOs are described using the JBoss Microcontainer schema in a -jboss-beans.xml
file. You create such a file and deploy it, either directly in the deploy
dir, or packaged in an ear or sar. Following is an example:
The bulk of the above is the creation of a JBoss Cache
Configuration
object; this is the same as what we saw in the configuration of the CacheManager service (see Section 29.1.1, “Editing the CacheManager Configuration”). In this case we are not using the CacheManager service as a cache factory, so instead we create our own factory bean and then use it to create the cache (the "ExampleCache" bean). The "ExampleCache" is then injected into a (fictitious) service that needs it.
An interesting thing to note in the above example is the use of the
RuntimeConfig
object. External resources like a TransactionManager
and a JGroups ChannelFactory
that are visible to the microcontainer are dependency injected into the RuntimeConfig
. The assumption here is that in some other deployment descriptor in the Enterprise Application Platform, the referenced beans have already been described.
Using the configuration above, the "ExampleCache" cache will not be visible in JMX. Here's an alternate approach that results in the cache being bound into JMX:
Here the "ExampleCacheJmxWrapper" bean handles the task of creating the cache from the configuration.
CacheJmxWrapper
is a JBoss Cache class that provides an MBean interface for a cache. Adding an <annotation> element binds the JBoss Microcontainer @JMX
annotation to the bean; that in turn results in JBoss Enterprise Application Platform registering the bean in JXM as part of the deployment process.
The actual underlying
org.jboss.cache.Cache
instance is available from the CacheJmxWrapper
via its cache
property; the example shows how this can be used to inject the cache into the "ExampleService".