KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > fortress > impl > ComponentHandlerMetaData


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.impl;
19
20 import org.apache.avalon.framework.configuration.Configuration;
21
22 /**
23  * A class holding metadata about a component handler.
24  *
25  * @author <a HREF="mailto:dev@avalon.apache.org">Avalon Development Team</a>
26  * @version $Revision: 1.12 $ $Date: 2004/02/28 15:16:24 $
27  */

28 public final class ComponentHandlerMetaData
29 {
30     /** Component activation should be performed during container initialization. */
31     public static final int ACTIVATION_INLINE = 0;
32     
33     /** Component activation should be initiated during container
34      * initialization, but can be done asynchronously in a background
35      * thread. */

36     public static final int ACTIVATION_BACKGROUND = 1;
37     
38     /** Component activation will be delayed until the first time the
39      * component is looked up. */

40     public static final int ACTIVATION_LAZY = 2;
41     
42     private final String JavaDoc m_name;
43     private final String JavaDoc m_classname;
44     private final Configuration m_configuration;
45     private final int m_activation;
46
47     /**
48      * Creation of a new impl handler meta data instance.
49      *
50      * @param name the handler name
51      * @param classname the handler classname
52      * @param configuration the handler configuration
53      * @param activation the activation policy, one of
54      * ComponentHandlerMetaData.ACTIVATION_BACKGROUND,
55      * ComponentHandlerMetaData.ACTIVATION_INLINE,
56      * ComponentHandlerMetaData.ACTIVATION_LAZY.
57      */

58     public ComponentHandlerMetaData( final String JavaDoc name,
59                                      final String JavaDoc classname,
60                                      final Configuration configuration,
61                                      final int activation )
62     {
63         if ( null == name )
64         {
65             throw new NullPointerException JavaDoc( "name" );
66         }
67         if ( null == classname )
68         {
69             throw new NullPointerException JavaDoc( "classname" );
70         }
71         if ( null == configuration )
72         {
73             throw new NullPointerException JavaDoc( "configuration" );
74         }
75
76         m_name = name;
77         m_classname = classname;
78         m_configuration = configuration;
79         m_activation = activation;
80     }
81     
82     /**
83      * Creation of a new impl handler meta data instance.
84      *
85      * @param name the handler name
86      * @param classname the handler classname
87      * @param configuration the handler configuration
88      * @param lazyActivation the activation policy, true implies
89      * ACTIVATION_LAZY, and false implies
90      * ACTIVATION_BACKGROUND
91      *
92      * @deprecated in favor of construction which takes an integer activation.
93      */

94     public ComponentHandlerMetaData( final String JavaDoc name,
95                                      final String JavaDoc classname,
96                                      final Configuration configuration,
97                                      final boolean lazyActivation )
98     {
99         this( name, classname, configuration,
100             ( lazyActivation ? ACTIVATION_LAZY : ACTIVATION_BACKGROUND ) );
101     }
102
103     /**
104      * Returns the handler name
105      * @return the handler name
106      */

107     public String JavaDoc getName()
108     {
109         return m_name;
110     }
111
112     /**
113      * Returns the handler classname
114      * @return the classname
115      */

116     public String JavaDoc getClassname()
117     {
118         return m_classname;
119     }
120
121     /**
122      * Returns the handler configuration
123      * @return the configuration
124      */

125     public Configuration getConfiguration()
126     {
127         return m_configuration;
128     }
129     
130     /**
131      * Returns the handler activation policy
132      *
133      * @return the activation policy
134      */

135     public int getActivation()
136     {
137         return m_activation;
138     }
139
140     /**
141      * Returns the handler activation policy
142      * @return the activation policy
143      *
144      * @deprecated in favor of getActivation()
145      */

146     public boolean isLazyActivation()
147     {
148         return m_activation == ACTIVATION_LAZY;
149     }
150 }
151
Popular Tags