// 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.Framework
{
using System;
///
/// Enumeration used to mark the component's lifestyle.
///
public enum Lifestyle
{
///
/// Singleton components are instantiated once, and shared
/// between all clients.
///
Singleton,
///
/// Thread components have a unique instance per thread.
///
Thread,
///
/// Pooled components have a unique instance per client,
/// but they are managed in a pool.
///
Pooled,
///
/// Transient components are created on demand.
///
Transient,
///
/// Custom lifestyle components should be managed by custom component factories.
///
Custom
}
///
/// Attribute used to mark a component as an Avalon component.
///
[AttributeUsage(AttributeTargets.Class,AllowMultiple=false,Inherited=false)]
public sealed class AvalonComponentAttribute : Attribute
{
private Lifestyle m_lifestyle;
private string m_name;
///
/// Marks a class as a component, providing a configuration name and preferred lifestyle
///
/// The component logical name (may be used for configuration elements)
/// The lifestyle used for the component
public AvalonComponentAttribute( string name, Lifestyle lifestyle )
{
m_lifestyle = lifestyle;
m_name = name;
}
///
/// The component name assigned to this component.
///
public string Name
{
get
{
return m_name;
}
}
///
/// The lifestyle associated with the component
///
public Lifestyle Lifestyle
{
get
{
return m_lifestyle;
}
}
}
}