Hi Cory,
My understanding is that this is thread-safe, because
MessageContext.getCurrentContext() uses a ThreadLocal variable to get
the current context (so each separate thread would "see" the correct
variable only for it's current thread).
ThreadLocal is very cool. :)
On Mon, 2003-01-27 at 12:38, Cory Wilkerson wrote:
> Is the following thread safe? The fact that this is a static method scares me a
>bit, ie, will MessageContext.getCurrentContext() hold true in situations like this or
>is it possible that as two threads enter this method simultaneously...things could
>get a little funky.
>
>
> public static RequestHandler getInstance() {
> RequestHandler handler = null;
>
> MessageContext mc = MessageContext.getCurrentContext();
> if (mc != null && mc.getService() != null) {
> String serviceName = mc.getService().getName();
> if (serviceName != null) {
> if (serviceName.equalsIgnoreCase("SomeServiceName")) {
> handler = new TNowAirHandler();
> }
> }
> }
>
> return handler;
> }
--
=======================================
Jess Sightler
Senior Developer
Exim Technologies
131 Falls Street
Greenville SC 29601
Phone: 864-679-4651
=======================================