forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathICurrentSessionContext.cs
60 lines (58 loc) · 2.24 KB
/
ICurrentSessionContext.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using NHibernate.Bytecode;
using NHibernate.Engine;
namespace NHibernate.Context
{
/// <summary>
/// Defines the contract for implementations which know how to
/// scope the notion of a <see cref="ISessionFactory.GetCurrentSession()">current session</see>.
/// </summary>
/// <remarks>
/// <para>
/// Implementations should adhere to the following:
/// <list type="bullet">
/// <item><description>contain a constructor accepting a single argument of type
/// <see cref="ISessionFactoryImplementor" />, or implement
/// <see cref="ISessionFactoryAwareCurrentSessionContext"/></description></item>
/// <item><description>should be thread safe</description></item>
/// <item><description>should be fully serializable</description></item>
/// </list>
/// </para>
/// <para>
/// Implementors should be aware that they are also fully responsible for
/// cleanup of any generated current-sessions.
/// </para>
/// <para>
/// Note that there will be exactly one instance of the configured
/// ICurrentSessionContext implementation per <see cref="ISessionFactory" />.
/// </para>
/// <para>
/// It is recommended to inherit from the class <see cref="CurrentSessionContext" />
/// whenever possible as it simplifies the implementation and provides
/// single entry point with session binding support.
/// </para>
/// </remarks>
public interface ICurrentSessionContext
{
/// <summary>
/// Retrieve the current session according to the scoping defined
/// by this implementation.
/// </summary>
/// <returns>The current session.</returns>
/// <exception cref="HibernateException">Typically indicates an issue
/// locating or creating the current session.</exception>
ISession CurrentSession();
}
/// <summary>
/// An <see cref="ICurrentSessionContext"/> allowing to set its session factory. Implementing
/// this interface allows the <see cref="IObjectsFactory"/> to be used for instantiating the
/// session context.
/// </summary>
public interface ISessionFactoryAwareCurrentSessionContext : ICurrentSessionContext
{
/// <summary>
/// Sets the factory. This method should be called once after creating the context.
/// </summary>
/// <param name="factory">The factory.</param>
void SetFactory(ISessionFactoryImplementor factory);
}
}