Cómo Usar PropertiesService de JBoss en proyectos ESB




Hay un archivo dentro del servidor llamado properties-service.xml, alojado en /jboss-as/server/[curren_conf]/deploy. Este archivo permite definir variables globales en la VM, tal como si se usase System.setProperty.

La estructura del archivo es la siguiente:

<server>
    <mbean  

                code="org.jboss.varia.property.SystemPropertiesService"
                name="jboss.util:type=Service,name=SystemProperties">
           
        <!-- Load properties from each of the given comma seperated URLs -->
        <attribute name
="URLList">
            http://somehost/some-location.properties,
            ./conf/somelocal.properties

        </attribute>
           
        <!-- Set properties using the properties file style. -->
        <attribute name
="Properties">
            property1=This is the value of my property
            property2=This is the value of my other property

        </attribute>
           
    </mbean>
</server>


Hay dos formas de usarlo:

  •  La primera, es linkeando todos los archivos de propiedades dentro del tag <attribute name="URLList"> separdados por coma
  • La segunda, es definiendo propiedades tal como si lo hicieras en un archivo properties en el tag  <attribute name="Properties">

Para acceder a las variables definidas, la sintaxis es la siguiente:
  • Desde el archivo jboss-esb.xml : ${property1}
  • Desde una clase java  : System.getProperty("property1")

Comentarios

Entradas populares