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.core;
18:
19: import javax.naming.CompositeName;
20: import javax.naming.InvalidNameException;
21: import javax.naming.Name;
22:
23: /**
24: * Implementation of Name with support for extra information.
25: *
26: * An extra feature ( not yet implemneted ) is the support for
27: * MessageBytes. This allows tomcat to operate lookup operations
28: * on the original message, without creating Strings.
29: *
30: * Another feature is support for extra information that can be cached.
31: * This brakes a bit the JNDI requirements, as Contexts can modify the
32: * Name and add anotations. The main benefit is that after the first
33: * lookup it'll be possible to avoid some expensive operations.
34: *
35: * @author Costin Manolache
36: */
37: public class ServerName extends CompositeName {
38: private int id = 0;
39:
40: public ServerName(String s) throws InvalidNameException {
41: super (s);
42: }
43:
44: /** ID is a small int, equivalent with a note.
45: The name is reused in the server environment, and various
46: components can use the id for fast access.
47:
48: The id is local for a particular context.
49:
50: /Servlet/ClassName -> ClassName will have an ID ( note id ) unique
51: for the Servlet
52: */
53: public final int getId() {
54: return id;
55: }
56:
57: // XXX Should we allow setting the id, or use a counter for each prefix ?
58: public final void setId(int id) {
59: this .id = id;
60: }
61:
62: /**
63: * Factory method to create server names.
64: */
65: public static Name getName(String s) throws InvalidNameException {
66: return new ServerName(s);
67: }
68:
69: /**
70: * @todo: optimize parsing and cache ( reuse existing instances ).
71: */
72: // public static Name getName( MessageBytes mb ) {
73: // return new ServerName( mb.toString() );
74: // }
75: }
|