Este contenido no está disponible en el idioma seleccionado.

6.3. Using the Microcontainer with Spring


Example 6.2. Descriptor with Spring Support

<beans xmlns="urn:jboss:spring-beans:2.0">

  <!-- Adding @Spring annotation handler -->
  <bean id="SpringAnnotationPlugin" class="org.jboss.spring.annotations.SpringBeanAnnotationPlugin" />

  <bean id="SpringPojo" class="org.jboss.demos.models.spring.Pojo"/>

</beans>

			
			
			

Copy to Clipboard Toggle word wrap
This file's namespace is different from the plain Microcontainer bean’s file. The urn:jboss:spring-beans:2.0 namespace points to your version of the Spring schema port, which describes your bean's Spring style. The Microcontainer, rather than Spring's bean factory notion, deploys the beans.

Example 6.3. Using Spring with the Microcontainer

public class Pojo extends AbstractPojo implements BeanNameAware {
    private String beanName;

    public void setBeanName(String name)
    {
	beanName = name;
    }

    public String getBeanName()
    {
	return beanName;
    }

    public void start()
    {
	if ("SpringPojo".equals(getBeanName()) == false)
	    throw new IllegalArgumentException("Name does not match: " + getBeanName());
    }
}
			
			
			

Copy to Clipboard Toggle word wrap
Although the SpringPojo bean has a dependency on Spring's library caused by implementing BeanNameAware interface, its only purpose is to expose and mock some of the Spring's callback behavior.
Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat