KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > codehaus > loom > components > util > info > ComponentInfo


1 /*
2  * Copyright (C) The Loom Group. All rights reserved.
3  *
4  * This software is published under the terms of the Loom
5  * Software License version 1.1, a copy of which has been included
6  * with this distribution in the LICENSE.txt file.
7  */

8 package org.codehaus.loom.components.util.info;
9
10 import java.io.Serializable JavaDoc;
11
12 /**
13  * This class contains the meta information about a particular component type.
14  * It describes;
15  *
16  * <ul> <li>Human presentable meta data such as name, version, description etc
17  * useful when assembling the system.</li> <li>the context object capabilities
18  * that this component requires</li> <li>the services that this component type
19  * is capable of providing</li> <li>the services that this component type
20  * requires to operate (and the names via which services are accessed)</li>
21  * </ul>
22  *
23  * @author Peter Donald
24  * @version $Revision: 1.2 $ $Date: 2004/05/01 12:48:34 $
25  */

26 public class ComponentInfo
27     implements Serializable JavaDoc
28 {
29     /** The type of the component. */
30     private final Class JavaDoc m_type;
31
32     /** Descriptors for the services exported by component. */
33     private final ServiceDescriptor[] m_services;
34
35     /** Descriptor for the schema of components parameters. */
36     private final SchemaDescriptor m_configurationSchema;
37
38     /** Descriptor for the service dependencies of component. */
39     private final DependencyDescriptor[] m_dependencies;
40
41     /**
42      * Basic constructor that takes as parameters all parts.
43      */

44     public ComponentInfo( final Class JavaDoc type,
45                           final ServiceDescriptor[] services,
46                           final DependencyDescriptor[] dependencies,
47                           final SchemaDescriptor configurationSchema )
48     {
49         if( null == type )
50         {
51             throw new NullPointerException JavaDoc( "type" );
52         }
53         if( null == services )
54         {
55             throw new NullPointerException JavaDoc( "services" );
56         }
57         if( null == dependencies )
58         {
59             throw new NullPointerException JavaDoc( "dependencies" );
60         }
61         m_type = type;
62         m_services = services;
63         m_dependencies = dependencies;
64         m_configurationSchema = configurationSchema;
65     }
66
67     /**
68      * Return the components type.
69      *
70      * @return the components type.
71      */

72     public Class JavaDoc getType()
73     {
74         return m_type;
75     }
76
77     /**
78      * Return the set of Services that this Component is capable of providing.
79      *
80      * @return the set of Services that this Component is capable of providing.
81      */

82     public ServiceDescriptor[] getServices()
83     {
84         return m_services;
85     }
86
87     /**
88      * Return the schema for the configuration.
89      *
90      * @return the schema for the configuration.
91      */

92     public SchemaDescriptor getConfigurationSchema()
93     {
94         return m_configurationSchema;
95     }
96
97     /**
98      * Return the set of Dependencies that this Component requires to operate.
99      *
100      * @return the set of Dependencies that this Component requires to operate.
101      */

102     public DependencyDescriptor[] getDependencies()
103     {
104         return m_dependencies;
105     }
106
107     /**
108      * Retrieve a dependency with a particular key.
109      *
110      * @param key the key
111      * @return the dependency or null if it does not exist
112      */

113     public DependencyDescriptor getDependency( final String JavaDoc key )
114     {
115         for( int i = 0; i < m_dependencies.length; i++ )
116         {
117             if( m_dependencies[ i ].getKey().equals( key ) )
118             {
119                 return m_dependencies[ i ];
120             }
121         }
122
123         return null;
124     }
125 }
126
Popular Tags