1
2
3
4
5
6
7 package org.mule.transport.jms.jndi;
8
9 import org.mule.api.lifecycle.InitialisationException;
10
11 import javax.naming.Context;
12 import javax.naming.NamingException;
13
14
15
16
17
18
19 public class SimpleJndiNameResolver extends AbstractJndiNameResolver
20 {
21
22
23 private Context jndiContext;
24
25 public synchronized Object lookup(String name) throws NamingException
26 {
27 return jndiContext.lookup(name);
28 }
29
30 public void initialise() throws InitialisationException
31 {
32 if (jndiContext == null)
33 {
34 try
35 {
36 jndiContext = createInitialContext();
37 }
38 catch (NamingException e)
39 {
40 throw new InitialisationException(e, this);
41 }
42 }
43 }
44
45 @Override
46 public void dispose()
47 {
48 if (jndiContext != null)
49 {
50 try
51 {
52 jndiContext.close();
53 }
54 catch (NamingException e)
55 {
56 logger.error("Jms connector failed to dispose properly: ", e);
57 }
58 finally
59 {
60 jndiContext = null;
61 }
62 }
63 }
64 }