Colleagues,
Is it possible to use environment-specific variables in @ObjectClassDefinition's default values, such as in the code fragment below?
I tried it and it didn't work but maybe I am using incorrect notation.
@ObjectClassDefinition(name="Runmode Example Service")
public @interface Config {
@AttributeDefinition(name = "User Name")
String userName() default "$[env:INTEGRATION_USERNAME;default=dmytro@mape.com]";
@AttributeDefinition(name = "Password")
String password() default "$[secret:INTEGRATION_PASSWORD]";
}
Solved! Go to Solution.
Views
Replies
Total Likes
Yeah, that won't work in Java, in the first link I posted previously you can find the places where the variables can be used.
According to the documentation you can use this in OSGI configurations https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/using-....
That being said, you could let the default value empty in the JAVA class and the value through the OSGI config instead, something like this:
{
"userName" : "$[env:my_username_var]"
"password": "$[env:my_pass_var]"
}
Hi @EstebanBustamante ,
That notation ${env.VARIABLE_NAME} is for XML config files. I tried using that in the Java code and it didn't work.
Does it work in someone's code?
@EstebanBustamante wrote:That being said, you could let the default value empty in the JAVA class and the value through the OSGI config instead, something like this:
Yes, that's the proper way to do it. I am just getting ready for a training and want to explore all the possible options.
Yeah, that won't work in Java, in the first link I posted previously you can find the places where the variables can be used.
This syntax won't work in the Java Code. You don't need it in the Java code unless you haven't created the config files under the osgiconfig node within your projects. If the config files are not available, then only the default value from the Java code will be picked up. In that case, you can simply provide the default value using a constant or directly. There is no other way.
What is the symptom? any error message during the build? What's the output in the target/OSGI-INF/*.xml files for the relevant class?
Views
Replies
Total Likes