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 | 0 | public class SimpleJndiNameResolver extends AbstractJndiNameResolver |
20 | |
{ |
21 | |
|
22 | |
|
23 | |
private Context jndiContext; |
24 | |
|
25 | |
public synchronized Object lookup(String name) throws NamingException |
26 | |
{ |
27 | 0 | return jndiContext.lookup(name); |
28 | |
} |
29 | |
|
30 | |
public void initialise() throws InitialisationException |
31 | |
{ |
32 | 0 | if (jndiContext == null) |
33 | |
{ |
34 | |
try |
35 | |
{ |
36 | 0 | jndiContext = createInitialContext(); |
37 | |
} |
38 | 0 | catch (NamingException e) |
39 | |
{ |
40 | 0 | throw new InitialisationException(e, this); |
41 | 0 | } |
42 | |
} |
43 | 0 | } |
44 | |
|
45 | |
@Override |
46 | |
public void dispose() |
47 | |
{ |
48 | 0 | if (jndiContext != null) |
49 | |
{ |
50 | |
try |
51 | |
{ |
52 | 0 | jndiContext.close(); |
53 | 0 | } |
54 | 0 | catch (NamingException e) |
55 | |
{ |
56 | 0 | logger.error("Jms connector failed to dispose properly: ", e); |
57 | 0 | } |
58 | |
finally |
59 | |
{ |
60 | 0 | jndiContext = null; |
61 | 0 | } |
62 | |
} |
63 | 0 | } |
64 | |
} |