Get the bound context. @return the Context bound with either the current thread or the current classloader @throws NamingException Bindings exception
()
| 343 | * @throws NamingException Bindings exception |
| 344 | */ |
| 345 | protected Context getBoundContext() throws NamingException { |
| 346 | |
| 347 | if (initialContext) { |
| 348 | String ICName = IC_PREFIX; |
| 349 | if (ContextBindings.isThreadBound()) { |
| 350 | ICName += ContextBindings.getThreadName(); |
| 351 | } else if (ContextBindings.isClassLoaderBound()) { |
| 352 | ICName += ContextBindings.getClassLoaderName(); |
| 353 | } |
| 354 | Context initialContext = ContextBindings.getContext(ICName); |
| 355 | if (initialContext == null) { |
| 356 | // Allocating a new context and binding it to the appropriate |
| 357 | // name |
| 358 | initialContext = new NamingContext(env, ICName); |
| 359 | ContextBindings.bindContext(ICName, initialContext); |
| 360 | } |
| 361 | return initialContext; |
| 362 | } else { |
| 363 | if (ContextBindings.isThreadBound()) { |
| 364 | return ContextBindings.getThread(); |
| 365 | } else { |
| 366 | return ContextBindings.getClassLoader(); |
| 367 | } |
| 368 | } |
| 369 | |
| 370 | } |
| 371 | |
| 372 | |
| 373 | /** |
no test coverage detected