WAS v8.5 > Administering applications and their environment > Administering the Liberty profile > Administering the Liberty profile manually > Using includes, variables, and Ref tags in configuration files

Use Ref tags in configuration files

We can define a common configuration element, then reuse that definition by referring to it (using a Ref tag) from elsewhere in the configuration. Ref tags can be used in the same configuration file containing the element definition, or in an included configuration file.

Different approaches are used to specify relationships between the required configuration elements. For example, the following data source definitions are all valid. The first uses no Ref tags, the second uses a combination of direct element definition and Ref tags, and the third uses Ref tags only.

Example

Example 1: Using no Ref tags.

< dataSource id="blogDS" jndiName="jdbc/blogDS"> 
  < properties createDatabase="create" 
              databaseName="C:/liberty/basics/derby/data/blogDB"/> 
  < jdbcDriver>
    < library>
      < fileset dir="C:/liberty/basics/derby" includes="derby.jar"/>     </library>   </jdbcDriver> 
  < connectionManager maxPoolSize="10"/> 
</dataSource>

Example 2: Combining direct element definition and Ref tags.

< dataSource id="blogDS" 
            jndiName="jdbc/blogDS" 
            connectionManagerRef="derbyPool"> 
  < properties createDatabase="create" 
              databaseName="C:/liberty/basics/derby/data/blogDB"/> 
  < jdbcDriver libraryRef="derbyLib"/> 
</dataSource> 
< connectionManager  maxPoolSize="10"/> 

< library id="derbyLib"/>   < fileset dir="C:/liberty/basics/derby" includes="derby.jar"/> </library>

Example 3: Using Ref tags only (except for the properties element, which is only permitted as nested).

 < dataSource id="blogDS" 
             jndiName="jdbc/blogDS" 
             connectionManagerRef="derbyPool" 
             jdbcDriverRef="derbyEmbedded"> 
   < properties createDatabase="create" 
               databaseName="C:/liberty/basics/derby/data/blogDB"/> 
 </dataSource> 
 < connectionManager  maxPoolSize="10"/> 

 < jdbcDriver libraryRef="derbyLib"/>    
 < library id="derbyLib" filesetRef="derbyFileset"/>  
 < fileset dir="C:/liberty/basics/derby" includes="derby.jar"/> 


Parent topic: Using includes, variables, and Ref tags in configuration files