IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Spring Java Discussion :

Alias dans la config


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Mars 2011
    Messages
    63
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Mars 2011
    Messages : 63
    Par défaut Alias dans la config
    Bonsoir,

    J'aimerais savoir qu'elle est l'utilité d'utiliser un alias dans nos déclarations des beans dans la configurations xml ?

    Merci d'avace

  2. #2
    Membre très actif
    Avatar de Khaled.Noordin
    Homme Profil pro
    Inscrit en
    Janvier 2005
    Messages
    354
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 354
    Billets dans le blog
    1
    Par défaut
    Salut
    Qu'est ce qu'un alias?

  3. #3
    Membre Expert
    Homme Profil pro
    Inscrit en
    Septembre 2006
    Messages
    2 963
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Belgique

    Informations forums :
    Inscription : Septembre 2006
    Messages : 2 963
    Par défaut
    Citation Envoyé par V4Vendetta Voir le message
    J'aimerais savoir qu'elle est l'utilité d'utiliser un alias dans nos déclarations des beans dans la configurations xml ?
    Citation Envoyé par Reference documentation
    In a bean definition itself, you can supply more than one name for the bean, by using a combination of up to one name specified by the id attribute, and any number of other names in the name attribute. These names can be equivalent aliases to the same bean, and are useful for some situations, such as allowing each component in an application to refer to a common dependency by using a bean name that is specific to that component itself.

    Specifying all aliases where the bean is actually defined is not always adequate, however. It is sometimes desirable to introduce an alias for a bean that is defined elsewhere. This is commonly the case in large systems where configuration is split amongst each subsystem, each subsystem having its own set of object definitions. In XML-based configuration metadata, you can use the element to accomplish this.


    As a concrete example, consider the case where component A defines a DataSource bean called componentA-dataSource, in its XML fragment. Component B would however like to refer to the DataSource as componentB-dataSource in its XML fragment. And the main application, MyApp, defines its own XML fragment and assembles the final application context from all three fragments, and would like to refer to the DataSource as myApp-dataSource.
    le "commonly the case in large systems" signifie simplement que si vous vous posez la question de l'usage des alias, c'est que vous n'en avez pas besoin : vous ne travaillez pas sur des projets suffisamment complexes pour que le cas se présente.


    http://www.springframework.org/schem...ring-beans.xsd :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
     
    …
    <xsd:element name="alias">
    <xsd:annotation>
    <xsd:documentation>
    <![CDATA[
    Defines an alias for a bean (which can reside in a different definition resource).
    ]]>
    </xsd:documentation>
    </xsd:annotation>
    <xsd:complexType>
    <xsd:complexContent>
    <xsd:restriction base="xsd:anyType">
    <xsd:attribute name="name" type="xsd:string" use="required">
    <xsd:annotation>
    <xsd:documentation>
    <![CDATA[ The name of the bean to define an alias for. ]]>
    </xsd:documentation>
    </xsd:annotation>
    </xsd:attribute>
    <xsd:attribute name="alias" type="xsd:string" use="required">
    <xsd:annotation>
    <xsd:documentation>
    <![CDATA[ The alias name to define for the bean. ]]>
    </xsd:documentation>
    </xsd:annotation>
    </xsd:attribute>
    </xsd:restriction>
    </xsd:complexContent>
    </xsd:complexType>
    </xsd:element>
    …

Discussions similaires

  1. Configurer un pakage dans spring config ?
    Par Invité dans le forum Spring
    Réponses: 1
    Dernier message: 28/12/2006, 19h11
  2. Driver pour Sybase dans struts-config
    Par gloglo dans le forum Struts 1
    Réponses: 2
    Dernier message: 21/09/2006, 19h00
  3. [SQL2K][TSQL] Peut-on utiliser un alias dans une clause Where ?
    Par StormimOn dans le forum MS SQL Server
    Réponses: 4
    Dernier message: 23/05/2006, 09h25
  4. alias dans une requete
    Par fscli dans le forum Access
    Réponses: 1
    Dernier message: 16/05/2006, 16h26
  5. [Oracle 9.2]Utiliser un alias dans une contrainte ?
    Par belfaigore dans le forum Oracle
    Réponses: 5
    Dernier message: 29/06/2005, 14h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo