// 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 descriptor defines the type of service offerend or required /// by a component. The type corresponds to the class name of the /// class/interface implemented by component. Associated with each /// classname is a version object so that different versions of same /// interface can be represented. /// ///

Also associated with each service is a set of arbitrary /// attributes that can be used to store extra information /// about service. See {@link InfoDescriptor} for example /// of how to declare the container specific attributes.

/// ///

Possible uses for the attributes are to declare a service /// as "stateless", "pass-by-value", "remotable" or even to attach /// attributes such as security or transaction constraints. These /// attributes are container specific and should not be relied /// upon to work in all containers.

/// ///
[Serializable] public class ServiceDescriptor : Descriptor { /// The service reference that descriptor is describing. private ReferenceDescriptor m_designator; /// Construct a service descriptor. /// /// /// the service descriptor /// /// NullPointerException if the descriptor argument is null /// public ServiceDescriptor(ServiceDescriptor descriptor) : base(descriptor.Properties, null) { m_designator = descriptor.Reference; } /// Construct a service descriptor for specified ReferenceDescriptor /// /// /// the service reference /// /// NullPointerException if the designator argument is null /// public ServiceDescriptor(ReferenceDescriptor designator) : this(designator, null) { } /// Construct a service with specified name, version and attributes. /// /// /// the ReferenceDescriptor /// /// the attributes of service /// /// NullPointerException if the designator argument is null /// public ServiceDescriptor(ReferenceDescriptor designator, System.Collections.Specialized.NameValueCollection attributes) : base(attributes, null) { if (null == designator) { throw new System.NullReferenceException("designator"); } m_designator = designator; } /// Retrieve the reference that service descriptor refers to. /// /// /// the reference that service descriptor refers to. /// public virtual ReferenceDescriptor Reference { get { return m_designator; } } /// Return the cashcode for this instance. /// the instance hashcode /// public override int GetHashCode() { return m_designator.GetHashCode(); } /// 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 ServiceDescriptor; isEqual = isEqual && m_designator.Equals(((ServiceDescriptor) other).m_designator); return isEqual; } } }