// 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.Composition.Data { using System; /// A context descriptor declares the context creation criteria for /// the context instance and context entries. /// ///

XML

///

A context directive may contain multiple import statements. Each import /// statement corresponds to a request for a context value from the container.

///
	/// <context class="MyContextClass">
	/// <entry key="special">
	/// <import key="urn:avalon:classloader"/>
	/// </entry>
	/// <entry key="xxx">
	/// <param class="MySpecialClass">
	/// <param>hello</param>
	/// <param class="java.io.File">../lib</param>
	/// </param>
	/// </entry>
	/// </context>
	/// 
/// ///
/// /// /// Avalon Development Team /// /// $Revision: 1.2 $ $Date: 2004/02/28 22:15:36 $ /// [Serializable] public class ContextDirective { /// The set of entry directives. private EntryDirective[] m_entries; /// The constext casting classname. private System.String m_classname; /// The optional provider source path. private System.String m_source; /// Creation of a new file target. /// the set of entry descriptors /// public ContextDirective(EntryDirective[] entries):this(null, entries) { } /// Creation of a new file target. /// the context implementation class /// /// the set of entry descriptors /// public ContextDirective(System.String classname, EntryDirective[] entries):this(classname, entries, null) { } /// Creation of a new file target. /// the context implementation class /// /// the set of entry descriptors /// /// a path to a source component for contextualization /// phase handling /// public ContextDirective(System.String classname, EntryDirective[] entries, System.String source) { m_source = source; m_classname = classname; if (entries != null) { m_entries = entries; } else { m_entries = new EntryDirective[0]; } } /// Return a named entry. /// the context entry key /// /// the entry corresponding to the supplied key or null if the /// key is unknown /// public virtual EntryDirective getEntryDirective(System.String key) { for (int i = 0; i < m_entries.Length; i++) { EntryDirective entry = m_entries[i]; if (entry.Key.Equals(key)) { return entry; } } return null; } /// Return the relative path to a source provider component that /// will handle a custom contextualization phase implementation. /// /// the source path /// public virtual System.String Source { get { return m_source; } } /// Return the classname of the context implementation to use. /// the classname /// public virtual System.String Classname { get { return m_classname; } } /// Return the set of entry directives. /// the entries /// public virtual EntryDirective[] EntryDirectives { get { return m_entries; } } } }