Search

7.8. Bean Metadata Builder

download PDF
When using the Microcontainer in your code, use BeanMetaDataBuilder to create and configure your bean metadata.

Example 7.17. BeanMetaDataBuilder

<bean name="BuilderUtil" class="org.jboss.demos.ioc.builder.BuilderUtil"/>
<bean name="BuilderExampleHolder" class="org.jboss.demos.ioc.builder.BuilderExampleHolder">
  <constructor>
    <parameter><inject bean="BUExample"/></parameter>
  </constructor>
</bean>
Using this concept, you don't expose your code to any Microcontainer implementation details.
public class BuilderUtil {
    private KernelController controller;
    @Constructor
	public BuilderUtil(@Inject(bean = KernelConstants.KERNEL_CONTROLLER_NAME) KernelController controller) {
	this.controller = controller;
    }
    public void create() throws Throwable {
	BeanMetaDataBuilder builder = BeanMetaDataBuilder.createBuilder("BUExample", BuilderExample.class.getName());
	builder.addStartParameter(Kernel.class.getName(), builder.createInject(KernelConstants.KERNEL_NAME));
	controller.install(builder.getBeanMetaData());
    }
    public void destroy() {
	controller.uninstall("BUExample");
    }
}
			
			
			
			

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.