Projets
Pages enfant
  • 1.7 Les beans Spring

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.
Commentaire: Migrated to Confluence 5.3

...

Bloc de code
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:aop="http://www.springframework.org/schema/aop"        
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd" >
...
</beans>

HTML Comment

Récupération des beans

Il est possible de récupérer un bean à partir de son nom à partir du code JAVA. La classe BeanUtils fournie par esup-commons V1 n'est plus utilisée.

Balise Wiki
{htmlcomment} h2. Récupération des _beans_ Il est possible de récupérer un _bean_ à partir de son nom à partir du code JAVA. La classe *BeanUtils* fournie par _esup-commons_ V1 n'est plus utilisée. On utilise un mécanisme interne à Spring basé sur l'implémentation de *

On utilise un mécanisme interne à Spring basé sur l'implémentation de

org.springframework.context.ApplicationContextAware

* _

esup-commons

_

V2

fournit

une

telle

implémentation

qu'il

suffit

de

déclarer

dans

un

fichier

de

configuration

Spring

(ex

:

*

properties/applicationContext.xml

*

)

:

{

Bloc de code
}

<bean id="app_context" class="org.esupportail.commons.context.ApplicationContextHolder"/>
{code}

Depuis

le

code

java,

on

utilisera

:

{

Bloc de code
}

ApplicationContext springContext = ApplicationContextHolder.getContext();
DomainService domainService = (DomainService) springContext.getBean("domainService");
{code} {warning}*
Avertissement
  • L'utilisation
  • de
  • cette
  • méthode
  • devrait
  • rester
  • exceptionnelle
  • (mode
_
  • batch
_
  • par
  • exemple)
{warning}{htmlcomment}