01: /*
02: * Copyright 1999-2004 The Apache Software Foundation
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package org.apache.naming.handler.jndi;
18:
19: import java.net.URLStreamHandler;
20: import java.net.URLStreamHandlerFactory;
21:
22: /**
23: * Factory for Stream handlers to a JNDI directory context.
24: *
25: * @author <a href="mailto:remm@apache.org">Remy Maucherat</a>
26: * @version $Revision: 1.3 $
27: */
28: public class DirContextURLStreamHandlerFactory implements
29: URLStreamHandlerFactory {
30:
31: // ----------------------------------------------------------- Constructors
32:
33: public DirContextURLStreamHandlerFactory() {
34: }
35:
36: // ----------------------------------------------------- Instance Variables
37:
38: // ------------------------------------------------------------- Properties
39:
40: // ---------------------------------------- URLStreamHandlerFactory Methods
41:
42: /**
43: * Creates a new URLStreamHandler instance with the specified protocol.
44: * Will return null if the protocol is not <code>jndi</code>.
45: *
46: * @param protocol the protocol (must be "jndi" here)
47: * @return a URLStreamHandler for the jndi protocol, or null if the
48: * protocol is not JNDI
49: */
50: public URLStreamHandler createURLStreamHandler(String protocol) {
51: if (protocol.equals("jndi")) {
52: return new DirContextURLStreamHandler();
53: } else {
54: return null;
55: }
56: }
57:
58: }
|