-
1. Re: EJB entity with static final field
peterj Nov 28, 2006 10:59 AM (in response to buggsbunny101)You used the term "constant". Do you mean something like this:
public static final String FOO = "something";
public static final int BAR = 123;
If so, feel free to use these in EJBs, as static finals (constants) of the basic data types and strings are perfectly acceptable. -
2. Re: EJB entity with static final field
buggsbunny101 Nov 29, 2006 5:05 AM (in response to buggsbunny101)Yes this is exactly how I want too use it.
Thanks.
Now, another question:
Because I will need this "constant" outsite the EJB and because the bean definition is not availlable outside, How can I define this constant?
I use XDoclet to generate my classes and interfaces. Is there a way to tell it to "export" this static final field in the generated class? (interfaces and dataClasses)? Should I define some function giving me the constant value? (Bhaaaaa! Sound really dirty) -
3. Re: EJB entity with static final field
peterj Nov 29, 2006 10:30 AM (in response to buggsbunny101)I'm not sure what you are asking, so if the following doesn't answer your question, please rephrase it.
I typically have a class named Constant, and in the class I place a lot of static final fields. Then in my EJB code, I have statements like:
MyEjb ejb = (MyEjb)context.lookup(Constant.FOO);
Of course, I also often place the static final fields in the EJB itself.