Reading properties file through java backend webscript

cancel
Showing results for 
Search instead for 
Did you mean: 
Active Member II

Reading properties file through java backend webscript

Jump to solution

How we will read alfresco-global.properties file through java backend webscript??

 For example mail.username 

1 Solution

Accepted Solutions
Advanced II

Re: Reading properties file through java backend webscript

Jump 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... 

View solution in original post

5 Replies
Senior Member II

Re: Reading properties file through java backend webscript

Jump to solution

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>

Advanced II

Re: Reading properties file through java backend webscript

Jump to solution

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 

Established Member II

Re: Reading properties file through java backend webscript

Jump to solution

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

Advanced II

Re: Reading properties file through java backend webscript

Jump 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... 

View solution in original post

Active Member

Re: Reading properties file through java backend webscript

Jump to solution

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