1 // Copyright 2004-2007 Castle Project - http://www.castleproject.org/
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 namespace Castle
.ActiveRecord
.Framework
23 /// Type of delegate that is called when a root type is registered.
25 /// <param name="sender"></param>
26 /// <param name="rootType"></param>
27 public delegate void RootTypeHandler(object sender
, Type rootType
);
30 /// Keeps an association of SessionFactories to a object model
33 public interface ISessionFactoryHolder
36 /// Raised when a new root type is registered.
37 /// A new root type creates a new <c>ISessionFactory</c>
39 event RootTypeHandler OnRootTypeRegistered
;
42 /// Associates a Configuration object to a root type
44 /// <param name="rootType"></param>
45 /// <param name="cfg"></param>
46 void Register(Type rootType
, Configuration cfg
);
51 /// <returns></returns>
52 Configuration
[] GetAllConfigurations();
55 /// Requests the Configuration associated to the type.
57 /// <param name="type"></param>
58 /// <returns></returns>
59 Configuration
GetConfiguration(Type type
);
62 /// Obtains the SessionFactory associated to the type.
64 /// <param name="type"></param>
65 /// <returns></returns>
66 ISessionFactory
GetSessionFactory(Type type
);
69 /// Creates a session for the associated type
71 /// <param name="type"></param>
72 /// <returns></returns>
73 ISession
CreateSession(Type type
);
76 /// Releases the specified session
78 /// <param name="session"></param>
79 void ReleaseSession(ISession session
);
82 /// Called if an action on the session fails
84 /// <param name="session"></param>
85 void FailSession(ISession session
);
88 /// Gets the type of the root.
90 /// <param name="type">The type.</param>
91 /// <returns></returns>
92 Type
GetRootType(Type type
);
95 /// Gets or sets the implementation of <see cref="IThreadScopeInfo"/>
97 IThreadScopeInfo ThreadScopeInfo { get; set; }
100 /// This method allows direct registration
101 /// of a session factory to a type, bypassing the normal preperation that AR
103 /// The main usage is in testing, so you would be able to switch the session factory
105 /// Note that this will override the current session factory for the baseType.
107 void RegisterSessionFactory(ISessionFactory sessionFactory
, Type baseType
);