Returning transfers from EJB

I want to use Enum to return codes and messages from EJB. Currently, only the integer value Code is returned. Since we have several client applications, and clients are not always updated when the common EJB and vica versa classes are. What happens if client-side Enum types become out of sync?

Will it work if I have an old Enum definition on the client side and a new definition on the EJB and vica versa?

e.g. Client Side:

public enum Color { WHITE(21, "White"), BLACK(22, "Black"); private int code; private int message; private Color(int c, String message) { code = c; message = m; } public int getCode() { return code; } public String getMessage(){ return message; } 

EJB Side:

  public enum Color { WHITE(21, "White"), BLACK(22, "Black"), RED(23, "Red"); private int code; private int message; private Color(int c, String message) { code = c; message = m; } public int getCode() { return code; } public String getMessage(){ return message; } 

And my EJB method:

 public Color getBestColor(); 

And returns:

 Color.WHITE 
+4
source share
1 answer

If the definition of the client enumeration has a value that you submit, it will work fine (e.g. WHITE). if the client does not have a value then you will get a client-side IllegalArgumentException (e.g. RED). (details on enum serialization are here ).

+2
source

All Articles