Home JBoss howto Configuration How to inject System properties into JBoss ?
30 | 07 | 2010
JBoss 5 AS Book
"JBoss AS 5 development" reviews
Please share your feedback/review with other readers!
Banner
Dashboard
Advertise with Us
Banner
RSS Feed
Java EE 1.6 resources
Login
Sign here for the NewsLetter.



JBoss admin resources
Banner
Java EE 1.6 resources
JBoss howto

How to avoid the 50 seconds start up limit in Eclipse ?

JBoss recipe of the day ...
Read More

How can you solve deployment errors caused by large war/jar/ear files ?

jboss recipe of the day ...
Read More

How do you configure your .war to be deployed after your EJB ?

jboss recipe of the day ...
Read More
How to inject System properties into JBoss ?
Written by Mark S.   
JBoss recipe of the day
One cool way to add a list of System properties to JBoss is the Properties MBean Service.
In the deployment folder look for "properties-service.xml". (if you don't have it in your release you can create it at any time) :

Now add your properties either in the URLList Attribute or in the Properties Attribute:

<server>
<mbean code="org.jboss.varia.property.SystemPropertiesService" 
	 name="jboss:type=Service,name=SystemProperties">
 
    <attribute name="URLList">
      http://somehost/some-location.properties,
      ./conf/somelocal.properties
    </attribute>

    <attribute name="Properties">
       property1=This is the value of my property
       property2=This is the value of my other property
    </attribute>
   
</server>

As you can see the The "URLList" is a comma-separated list of URL strings from which to load properties file-formatted content while the "Properties" is a specification of multiple property name=value pairs

Now you can access your properties with standard:

System.getProperty("property1");


JBoss.org Search
Custom Search
Comments
Search
mannyd   |2009-11-28 21:04:07
The property service may be used to inject properties into Mbeans/Services
created after the property service. Is there a way to inject properties into
configuration of resources like datasources?
Only registered users can write comments!

3.26 Copyright (C) 2008 Compojoom.com / Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved."