Embedding a property in a bean

I am trying to decalre a spring bean in xml (Mule configuration file) and I created a bean like this:

<bean id="IsActiveFilter" class="com.TimeLineListener.IsActiveFilter"> <property name="isChatActive" value="${chatListener.isActive}"/> </bean> 

Now, my question is: how can I get the isChatActive value from a valid bean class? I mean, can I just create a variable (private int isChatActive) called isChatActive and it will get some value that the placeholder gives? I mean something like:

 public class IsActiveFilter{ { private int isChatActive; } 

Will this work? if not, how do I use it?

early

0
source share
2 answers

Create a getter and setter and you are fine:

 public class IsActiveFilter{ private int isChatActive; public int getIsChatActive() { return this.isChatActive; } public void setIsChatActive(int isChatActive) { this.isChatActive = isChatActive; } } 
+2
source
 public class IsActiveFilter { private int chatActive; public boolean isChatActive() { return chatActive; } public void setChatActive(boolean chatActive) { this.chatActive = chatActive; } } 
+1
source

Source: https://habr.com/ru/post/956279/


All Articles