access to a properties file under shared folder from a java class
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2013 08:07 AM
I want to know how to access to a properties file that is under shared folder from a java class which will be exported later as a jar file under alfresco/lib, Thanks
Labels:
- Labels:
-
Archive
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2013 02:15 AM
Hi,
you need to define the properties file in a bean and use the properties in java thorugh bean property setting.
<strong>bean definition in Context file</strong>
<strong>custom.properties file</strong>
you need to define the properties file in a bean and use the properties in java thorugh bean property setting.
<strong>bean definition in Context file</strong>
<bean id="custom-properties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="ignoreUnresolvablePlaceholders"> <value>true</value> </property> <property name="locations"> <list> <value>classpath:alfresco/extension/custom.properties</value> </list> </property> </bean> <bean id="customDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName"> <value>${custom.db.driver}</value> </property> <property name="url"> <value>${custom.db.url}</value> </property> <property name="username"> <value>${custom.db.username}</value> </property> <property name="password"> <value>${custom.db.password}</value> </property> </bean>
<strong>custom.properties file</strong>
custom.db.username=alfrescocustom.db.password=alfrescocustom.db.driver=org.gjt.mm.mysql.Drivercustom.db.url=jdbc:mysql://192.168.1.118:3306/alfresco401
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2013 07:43 AM
You can user java's default resource bundle.
Put your properties files under shared/classes/alfresco/messages folder and you can access easily it in java class .Please refer the following snippet.
public static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("alfresco.messages.samplePropertyFile");
public static final String SAMPLE_PROPERTY = RESOURCE_BUNDLE.getString("samplePropertyName");
Put your properties files under shared/classes/alfresco/messages folder and you can access easily it in java class .Please refer the following snippet.
public static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle("alfresco.messages.samplePropertyFile");
public static final String SAMPLE_PROPERTY = RESOURCE_BUNDLE.getString("samplePropertyName");
