in web jsf application, display different messages user using method:
private void showerrormessage(final string message) { facescontext.getcurrentinstance().addmessage(null, new facesmessage(message)); }
which located in each bean requires warn user in way.
now, want apply dry rule , make static class showerrormessage method static one, not sure if safe... mean static method vs instance of faces context based on session, can produce conflicts?
thanks.
static methods not safe when use mutable variables can changed outside. e.g.
private static string foo; // +getter +setter public static void foo() { // foo. }
this not threadsafe. race condition can occur when other thread changes foo
while current thread inside foo()
. yours, however, don't use externally mutable variables. declared , used methodlocal/threadlocal. it's safe.
Comments
Post a Comment