1
2
3
4
5
6
7
8
9
10
11
12
13
14 package org.eclipse.jetty.jndi.java;
15
16 import java.util.Hashtable;
17
18 import javax.naming.Context;
19 import javax.naming.Name;
20 import javax.naming.NamingException;
21 import javax.naming.spi.ObjectFactory;
22
23 import org.eclipse.jetty.util.log.Log;
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public class javaURLContextFactory implements ObjectFactory
44 {
45
46
47
48
49
50
51
52
53
54
55
56 public Object getObjectInstance(Object url, Name name, Context ctx, Hashtable env)
57 throws Exception
58 {
59
60 if (url == null)
61 {
62 if(Log.isDebugEnabled())Log.debug(">>> new root context requested ");
63 return new javaRootURLContext(env);
64 }
65
66
67 if (url instanceof String)
68 {
69 if(Log.isDebugEnabled())Log.debug(">>> resolution of url "+url+" requested");
70 Context rootctx = new javaRootURLContext (env);
71 return rootctx.lookup ((String)url);
72 }
73
74
75 if (url instanceof String[])
76 {
77 if(Log.isDebugEnabled())Log.debug(">>> resolution of array of urls requested");
78 String[] urls = (String[])url;
79 Context rootctx = new javaRootURLContext (env);
80 Object object = null;
81 NamingException e = null;
82 for (int i=0;(i< urls.length) && (object == null); i++)
83 {
84 try
85 {
86 object = rootctx.lookup (urls[i]);
87 }
88 catch (NamingException x)
89 {
90 e = x;
91 }
92 }
93
94 if (object == null)
95 throw e;
96 else
97 return object;
98 }
99
100 if(Log.isDebugEnabled())Log.debug(">>> No idea what to do, so return a new root context anyway");
101 return new javaRootURLContext (env);
102 }
103 };