KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > naming > core > ServerName


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
20 import javax.naming.InvalidNameException JavaDoc;
21 import javax.naming.Name JavaDoc;
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 JavaDoc
38 {
39     private int id=0;
40
41     public ServerName( String JavaDoc s ) throws InvalidNameException JavaDoc {
42         super(s);
43     }
44
45     /** ID is a small int, equivalent with a note.
46         The name is reused in the server environment, and various
47         components can use the id for fast access.
48
49         The id is local for a particular context.
50
51         /Servlet/ClassName -> ClassName will have an ID ( note id ) unique
52                               for the Servlet
53     */

54     public final int getId() {
55         return id;
56     }
57
58     // XXX Should we allow setting the id, or use a counter for each prefix ?
59
public final void setId( int id ) {
60         this.id=id;
61     }
62
63     /**
64      * Factory method to create server names.
65      */

66     public static Name JavaDoc getName( String JavaDoc s ) throws InvalidNameException JavaDoc {
67         return new ServerName( s );
68     }
69
70     /**
71      * @todo: optimize parsing and cache ( reuse existing instances ).
72      */

73 // public static Name getName( MessageBytes mb ) {
74
// return new ServerName( mb.toString() );
75
// }
76
}
77
Popular Tags