// Copyright 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.Castle.MicroKernel
{
using System;
using Apache.Avalon.Castle.MicroKernel.Model;
using Apache.Avalon.Castle.MicroKernel.Interceptor;
public delegate void DependencyListenerDelegate( Type service, IHandler handler );
///
/// Defines the Kernel contract and behavior.
///
///
public interface IKernel : IKernelEvents, IDisposable
{
///
/// Adds a component to kernel.
///
/// The unique key that identifies the component
/// The service exposed by this component
/// The actual implementation
void AddComponent(String key, Type service, Type implementation);
///
/// Removes a component from the kernel.
///
/// The unique key that identifies the component
void RemoveComponent(String key);
///
/// IComponentModel instance builder.
///
IComponentModelBuilder ModelBuilder { get; set; }
///
/// Obtains a component handler using the
/// unique component key
///
IHandler this[String key] { get; }
///
/// Adds a implementation to
/// the kernel.
///
/// Facility id
/// Facility instance
void AddFacility( String key, IKernelFacility kernelFacility );
///
/// Removes a from the kernel.
///
/// Facility id
void RemoveFacility( String key );
///
/// Returns a handler for the specified key and criteria.
///
/// The unique key that identifies the component
///
/// Handler instance
IHandler GetHandler(String key, object criteria);
///
/// Gets or Sets the IHandlerFactory implementation
///
IHandlerFactory HandlerFactory { get; set; }
///
/// Gets or Sets the ILifestyleManagerFactory implementation
///
ILifestyleManagerFactory LifestyleManagerFactory { get; set; }
///
/// Returns true if kernel "knows" the specified
/// service
///
/// The service interface
/// true if is already registered
bool HasService(Type service);
///
/// Used by handlers to register itself as
/// and dependency to be satisfied.
///
/// The service interface
/// Delegate to be invoked
void AddDependencyListener(Type service, DependencyListenerDelegate depDelegate);
///
/// Returns a IHandler implementation for
/// the specified service
///
/// The service interface
/// IHandler implementation
IHandler GetHandlerForService(Type service);
///
/// Adds a subsystem.
///
/// Name of this subsystem
/// Subsystem implementation
void AddSubsystem(String key, IKernelSubsystem system);
///
/// Returns a registered subsystem;
///
/// Key used when registered subsystem
/// Subsystem implementation
IKernelSubsystem GetSubsystem(String key);
///
///
///
IInterceptedComponentBuilder InterceptedComponentBuilder { get; set; }
}
}