How we will read alfresco-global.properties file through java backend webscript??
For example mail.username
Solved! Go to Solution.
I know there has been a long time since you asked, but I am going to answer anyway, as it can be a reference for someone searching for the same in future.
In the links below, you can find some samples:
How to define de bean to inject the alfresco-global.properties into the Java class: alfresco-audit-analysis-reporting/webscript-context.xml at master · fcorti/alfresco-audit-analysis-r...
How to define a setter method to the property: alfresco-audit-analysis-reporting/GetCountersWebScript.java at master · fcorti/alfresco-audit-analys...
Below is one sample bean where I am reading properties from alfresco-global.properties file like server host port etc..You can use similarly in case of webscript.
<bean id="org.alfresco.tutorial.policy.documentEventHandler"
class="com.trantorinc.liferay.webservice.Sample"
init-method="registerEventHandlers">
<property name="liferayServerHost" value="${server.host}"/>
<property name="liferayServerPort" value="${server.port}"/>
<property name="userName" value="${username}"/>
<property name="password" value="${lpassword}"/>
</bean>
It is also possible to get the access to all the properties by using the method described at Accessing values from Alfresco's alfresco-global.properties file - Stack Overflow
Hi,
this what i have added in one of my xml config file :
<bean id="global-properties" parent="baseJavaScriptExtension" class="java.util.Properties">
<property name="properties">
<ref bean="global-properties"/>
</property>
</bean>
But how can i use it in my java class ?
Thank you
I know there has been a long time since you asked, but I am going to answer anyway, as it can be a reference for someone searching for the same in future.
In the links below, you can find some samples:
How to define de bean to inject the alfresco-global.properties into the Java class: alfresco-audit-analysis-reporting/webscript-context.xml at master · fcorti/alfresco-audit-analysis-r...
How to define a setter method to the property: alfresco-audit-analysis-reporting/GetCountersWebScript.java at master · fcorti/alfresco-audit-analys...
Thanks .This worked for me perfectly.
<!--Inside Bean-->
<property name="properties"> <ref bean="global-properties"/> </property
//In Java Class
private Properties properties;
// And while accessing
properties.getProperty("your key from alfresco-global.properties");
Reference : Accessing values from Alfresco's alfresco-global.properties file - Stack Overflow
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.