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?
Asked
Active
Viewed 5,780 times
7
-
Are you looking to inject the values into your own bean (which is the way that those properties are normally used), or are you hoping to dynamically look up random properties at runtime? – Gagravarr May 04 '12 at 22:01
-
Either would work, though probably the former. I'm not too worried about the config values after Alfresco has started up. – patorjk May 04 '12 at 22:12
3 Answers
9
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

plus-
- 45,453
- 15
- 60
- 73
-
How can you do to link the property added in java class to the name "properties" ? – anakin59490 Jul 26 '18 at 14:15
-
Perfectly worked for me. And the JAVA part is [ private Properties properties; properties.getProperty("your key from alfresco-global.properties"); ] – Gouranga Tarafder Jan 04 '19 at 05:20
-
8
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.

Florian
- 1,281
- 7
- 17
-
2It is also possibile to use annotation `@Value("${my.custom.option}")` in Java bean class. – baì Feb 22 '19 at 18:14
-
You are right, back in 2014 only XML configuration was used for Alfresco. – Florian Feb 25 '19 at 09:55