KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > RoleEntry


1 /*
2  * Copyright 2003-2004 The Apache Software Foundation
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12  * implied.
13  *
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */

17
18 package org.apache.avalon.fortress;
19
20 /**
21  * Keeps track of the relationship of all the associated meta data for a
22  * component type. It records the role, short name, component class, and
23  * the handler class used to manage it. The short name is included strictly
24  * to enable "self-healing" configuration files.
25  *
26  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
27  * @version $Revision: 1.14 $ $Date: 2004/02/28 15:16:24 $
28  */

29 public final class RoleEntry
30 {
31     private final String JavaDoc m_shortName;
32     private final String JavaDoc m_role;
33     private final Class JavaDoc m_componentClass;
34     private final Class JavaDoc m_handlerClass;
35
36     /**
37      * Create a <code>RoleEntry</code> with all the associated information.
38      * All arguments must be supplied.
39      *
40      * @param role Role name for this component type
41      * @param shortName Short name for this component type
42      * @param componentClass <code>Class</code> to instantiate the
43      * component type
44      * @param handlerClass <code>Class</code> to instantiate the
45      * component handler
46      *
47      * @exception NullPointerException if any argument is <code>null</code>.
48      */

49     public RoleEntry( final String JavaDoc role,
50                       final String JavaDoc shortName,
51                       final Class JavaDoc componentClass,
52                       final Class JavaDoc handlerClass ) throws IllegalArgumentException JavaDoc
53     {
54         if ( null == role )
55         {
56             throw new NullPointerException JavaDoc( "\"role\" cannot be null." );
57         }
58         if ( null == shortName )
59         {
60             throw new NullPointerException JavaDoc( "\"shortname\" cannot be null." );
61         }
62         if ( null == componentClass )
63         {
64             throw new NullPointerException JavaDoc( "\"componentClass\" cannot be null." );
65         }
66         if ( null == handlerClass )
67         {
68             throw new NullPointerException JavaDoc( "\"handlerClass\" cannot be null." );
69         }
70
71         m_role = role;
72         m_shortName = shortName;
73         m_componentClass = componentClass;
74         m_handlerClass = handlerClass;
75     }
76
77     /**
78      * Get the role name for the component type.
79      *
80      * @return the role name
81      */

82     public String JavaDoc getRole()
83     {
84         return m_role;
85     }
86
87     /**
88      * Get the short name for the component type. This is used in
89      * "self-healing" configuration files.
90      *
91      * @return the short name
92      */

93     public String JavaDoc getShortname()
94     {
95         return m_shortName;
96     }
97
98     /**
99      * Get the <code>Class</code> for the component type.
100      *
101      * @return the <code>Class</code>
102      */

103     public Class JavaDoc getComponentClass()
104     {
105         return m_componentClass;
106     }
107
108     /**
109      * Get the <code>Class</code> for the component type's
110      * {@link org.apache.avalon.fortress.impl.handler.ComponentHandler}.
111      *
112      * @return the <code>Class</code>
113      */

114     public Class JavaDoc getHandlerClass()
115     {
116         return m_handlerClass;
117     }
118 }
119
Popular Tags