내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.

Mark Solution

활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.

해결됨

Reference environment variables in @ObjectClassDefinition default values - is it possible?

Avatar

Level 4

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]";
}

 

1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

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.

EstebanBustamante_0-1691066773614.png

 



Esteban Bustamante

원본 게시물의 솔루션 보기

5 답변 개

Avatar

Community Advisor and Adobe Champion

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]"
}

 

Reference: 
https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/deploy... 



Esteban Bustamante

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.

Avatar

정확한 답변 작성자:
Community Advisor and Adobe Champion

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.

EstebanBustamante_0-1691066773614.png

 



Esteban Bustamante

Avatar

Community Advisor

@Dmytro_Panchenk 

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.

 

 

Avatar

Employee Advisor

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?