// Copyright 2003-2004 The Apache Software Foundation // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. namespace Apache.Avalon.Meta { using System; using Apache.Avalon.Framework; /// This class is used to provide explicit information to assembler /// and administrator about the Component. It includes information /// such as; /// /// /// ///

The InfoDescriptor also includes an arbitrary set /// of attributes about component. Usually these are container /// specific attributes that can store arbitrary information. /// The attributes should be stored with keys based on package /// name of container. /// ///

/// Avalon Development Team /// /// $Revision: 1.4 $ $Date: 2004/02/28 22:15:37 $ /// [Serializable] public sealed class InfoDescriptor : Descriptor { //------------------------------------------------------------------- // immutable state //------------------------------------------------------------------- /// The short name of the Component Type. Useful for displaying /// human readable strings describing the type in /// assembly tools or generators. /// private System.String m_name; /// The implementation classname. private System.Type m_type; /// The component lifestyle. private Lifestyle m_lifestyle; /// The component configuration schema. private System.String m_schema; /// The component garbage collection policy. The value returned is either /// LIBERAL, DEMOCAT or CONSERVATIVE. A component implementing a LIBERAL policy /// will be decommissioned if no references exist. A component declaring a /// DEMOCRAT policy will exist without reference so long as memory contention /// does not occur. A component implementing CONSERVATIVE policies will be /// maintained irrespective of usage and memory constraints so long as its /// scope exists (the jvm for a "singleton" and Thread for "thread" lifestyles). /// The default policy is CONSERVATIVE. /// private CollectionPolicy m_collection; //------------------------------------------------------------------- // constructor //------------------------------------------------------------------- /// Creation of a new info descriptor using a supplied name, key /// and attribute set. /// /// /// the component name /// /// the implemetation classname /// /// a set of attributes associated with the component type /// /// IllegalArgumentException if the implementation key is not a classname /// @since 1.2 /// public InfoDescriptor(System.String name, System.Type type, Lifestyle lifestyle, CollectionPolicy collection, System.String schema, System.Collections.Specialized.NameValueCollection attributes) : base(attributes, null) { if (null == (System.Object) type) { throw new System.ArgumentNullException("type"); } if (null == (System.Object) name) { throw new System.ArgumentNullException("name"); } m_name = name; m_collection = collection; m_type = type; m_schema = schema; m_lifestyle = lifestyle; } /// Return the component termination policy as a String. /// /// /// the policy /// public CollectionPolicy CollectionPolicy { get { return m_collection; } } /// Return a string representation of the info descriptor. /// the stringified type /// public override System.String ToString() { return "[" + Name + "] " + Type; } /// Test is the supplied object is equal to this object. /// true if the object are equivalent /// public override bool Equals(System.Object other) { bool isEqual = base.Equals(other) && other is InfoDescriptor; if (isEqual) { InfoDescriptor info = (InfoDescriptor) other; isEqual = isEqual && m_type.Equals(info.m_type); isEqual = isEqual && (m_collection == info.m_collection); isEqual = isEqual && m_name.Equals(info.m_name); isEqual = isEqual && m_lifestyle.Equals(info.m_lifestyle); } return isEqual; } /// Return the hashcode for the object. /// the hashcode value /// public override int GetHashCode() { int hash = base.GetHashCode(); hash ^= m_type.GetHashCode(); if (null != (System.Object) m_name) { hash ^= m_name.GetHashCode(); } if (null != (System.Object) m_lifestyle) { hash ^= m_lifestyle.GetHashCode(); } return hash; } /// Return the symbolic name of component. /// /// /// the symbolic name of component. /// public System.String Name { get { return m_name; } } /// Return the configuration schema. /// /// /// the schema declaration (possibly null) /// public System.String ConfigurationSchema { get { return m_schema; } } /// Return the implementation class name for the component type. /// /// /// the implementation class name /// public System.Type Type { get { return m_type; } } /// Return the component lifestyle. /// /// /// the lifestyle /// public Lifestyle Lifestyle { get { return m_lifestyle; } } } }