Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing values from Alfresco's alfresco-global.properties file

Tags:

alfresco

Lets say I create a custom property called "test123" inside of the alfresco-global.properties file. Is there a custom object or some other way which I can use to access its value inside of a Java bean in Alfresco?

like image 912
patorjk Avatar asked May 04 '12 16:05

patorjk


2 Answers

The Spring bean is called "global-properties" and it's a java.util.Properties type

So you can inject it like that:

<property name="properties">
  <ref bean="global-properties"/>
</property

and add a properties property of type java.util.Properties to your bean

like image 170
plus- Avatar answered Sep 25 '22 15:09

plus-


All properties from the alfresco-global.properties are available as placeholders in the Spring bean definition. You can simply use:

<property name="myCustomOption" value="${my.custom.option}"/>

in your bean definition and in alfresco-global.properties:

my.custom.option=Some string value

Injecting the whole global-properties bean (as proposed above) also works but violates the principle of least knowledge.

like image 28
Florian Avatar answered Sep 21 '22 15:09

Florian