Skip to content

Commit b5e2b3f

Browse files
NH-4003 - renaming then converting to properties some methods, to be squashed or dropped.
1 parent ab3797d commit b5e2b3f

File tree

6 files changed

+30
-32
lines changed

6 files changed

+30
-32
lines changed

src/NHibernate/Impl/AbstractSessionImpl.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ protected internal AbstractSessionImpl(ISessionFactoryImplementor factory, ISess
4646
{
4747
_factory = factory;
4848
Timestamp = factory.Settings.CacheProvider.NextTimestamp();
49-
_flushMode = options.GetInitialSessionFlushMode();
50-
Interceptor = options.GetInterceptor() ?? EmptyInterceptor.Instance;
49+
_flushMode = options.InitialSessionFlushMode;
50+
Interceptor = options.SessionInterceptor ?? EmptyInterceptor.Instance;
5151
}
5252

5353
#region ISessionImplementor Members

src/NHibernate/Impl/ISessionCreationOptions.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ namespace NHibernate.Impl
88
/// <seealso cref="ISessionBuilder"/>
99
public interface ISessionCreationOptions
1010
{
11-
// NH note: it is tempting to convert them to properties, but then their names conflict
12-
// with ISessionBuilder, which is implemented along this interface.
13-
FlushMode GetInitialSessionFlushMode();
11+
// NH note: naming "adjusted" for converting Java methods to properties while avoiding conflicts with
12+
// ISessionBuilder.
13+
FlushMode InitialSessionFlushMode { get; }
1414

15-
bool ShouldAutoClose();
15+
bool ShouldAutoClose { get; }
1616

17-
DbConnection GetConnection();
17+
DbConnection UserSuppliedConnection { get; }
1818

19-
IInterceptor GetInterceptor();
19+
IInterceptor SessionInterceptor { get; }
2020

2121
// Todo: port PhysicalConnectionHandlingMode
22-
ConnectionReleaseMode GetConnectionReleaseMode();
22+
ConnectionReleaseMode SessionConnectionReleaseMode { get; }
2323
}
2424
}

src/NHibernate/Impl/ISharedSessionCreationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace NHibernate.Impl
1010
public interface ISharedSessionCreationOptions : ISessionCreationOptions
1111
{
1212
// NH note: not converting them to properties for staying in sync with ISessionCreationOptions.
13-
bool IsTransactionCoordinatorShared();
13+
bool IsTransactionCoordinatorShared { get; }
1414
// NH different implementation: need to port Hibernate transaction management.
15-
ConnectionManager GetConnectionManager();
15+
ConnectionManager ConnectionManager { get; }
1616
}
1717
}

src/NHibernate/Impl/SessionFactoryImpl.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,20 +1309,18 @@ protected void SetSelf(T self)
13091309

13101310
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13111311
// SessionCreationOptions
1312-
// NH note: it is tempting to convert them to properties, but then their names conflict
1313-
// with SessionBuilder interface.
13141312

1315-
public virtual FlushMode GetInitialSessionFlushMode() => _flushMode;
1313+
public virtual FlushMode InitialSessionFlushMode => _flushMode;
13161314

1317-
public virtual bool ShouldAutoClose() => _autoClose;
1315+
public virtual bool ShouldAutoClose => _autoClose;
13181316

1319-
public DbConnection GetConnection() => _connection;
1317+
public DbConnection UserSuppliedConnection => _connection;
13201318

13211319
// NH different implementation: Hibernate here ignore EmptyInterceptor.Instance too, resulting
13221320
// in the "NoInterceptor" being unable to override a session factory interceptor.
1323-
public virtual IInterceptor GetInterceptor() => _interceptor ?? _sessionFactory.Interceptor;
1321+
public virtual IInterceptor SessionInterceptor => _interceptor ?? _sessionFactory.Interceptor;
13241322

1325-
public virtual ConnectionReleaseMode GetConnectionReleaseMode() => _connectionReleaseMode;
1323+
public virtual ConnectionReleaseMode SessionConnectionReleaseMode => _connectionReleaseMode;
13261324

13271325
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13281326
// SessionBuilder
@@ -1400,15 +1398,15 @@ public IStatelessSessionBuilder Connection(DbConnection connection)
14001398
return this;
14011399
}
14021400

1403-
public FlushMode GetInitialSessionFlushMode() => FlushMode.Always;
1401+
public FlushMode InitialSessionFlushMode => FlushMode.Always;
14041402

1405-
public bool ShouldAutoClose() => false;
1403+
public bool ShouldAutoClose => false;
14061404

1407-
public DbConnection GetConnection() => _connection;
1405+
public DbConnection UserSuppliedConnection => _connection;
14081406

1409-
public IInterceptor GetInterceptor() => EmptyInterceptor.Instance;
1407+
public IInterceptor SessionInterceptor => EmptyInterceptor.Instance;
14101408

1411-
public ConnectionReleaseMode GetConnectionReleaseMode() => ConnectionReleaseMode.AfterTransaction;
1409+
public ConnectionReleaseMode SessionConnectionReleaseMode => ConnectionReleaseMode.AfterTransaction;
14121410
}
14131411
}
14141412
}

src/NHibernate/Impl/SessionImpl.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,22 +189,22 @@ internal SessionImpl(SessionFactoryImpl factory, ISessionCreationOptions options
189189
actionQueue = new ActionQueue(this);
190190
persistenceContext = new StatefulPersistenceContext(this);
191191

192-
autoCloseSessionEnabled = options.ShouldAutoClose();
192+
autoCloseSessionEnabled = options.ShouldAutoClose;
193193

194194
listeners = factory.EventListeners;
195-
connectionReleaseMode = options.GetConnectionReleaseMode();
195+
connectionReleaseMode = options.SessionConnectionReleaseMode;
196196

197-
if (options is ISharedSessionCreationOptions sharedOptions && sharedOptions.IsTransactionCoordinatorShared())
197+
if (options is ISharedSessionCreationOptions sharedOptions && sharedOptions.IsTransactionCoordinatorShared)
198198
{
199199
// NH specific implementation: need to port Hibernate transaction management.
200200
_transactionCoordinatorShared = true;
201-
if (options.GetConnection() != null)
201+
if (options.UserSuppliedConnection != null)
202202
throw new SessionException("Cannot simultaneously share transaction context and specify connection");
203-
connectionManager = sharedOptions.GetConnectionManager();
203+
connectionManager = sharedOptions.ConnectionManager;
204204
}
205205
else
206206
{
207-
connectionManager = new ConnectionManager(this, options.GetConnection(), connectionReleaseMode, Interceptor);
207+
connectionManager = new ConnectionManager(this, options.UserSuppliedConnection, connectionReleaseMode, Interceptor);
208208
}
209209

210210
if (factory.Statistics.IsStatisticsEnabled)
@@ -2552,10 +2552,10 @@ public override ISharedSessionBuilder Connection(DbConnection connection)
25522552
// SharedSessionCreationOptions
25532553

25542554
// NH note: not converting them to properties for staying in sync with ISessionCreationOptions.
2555-
public virtual bool IsTransactionCoordinatorShared() => _shareTransactionContext;
2555+
public virtual bool IsTransactionCoordinatorShared => _shareTransactionContext;
25562556

25572557
// NH different implementation: need to port Hibernate transaction management.
2558-
public ConnectionManager GetConnectionManager() => _shareTransactionContext ? _session.ConnectionManager : null;
2558+
public ConnectionManager ConnectionManager => _shareTransactionContext ? _session.ConnectionManager : null;
25592559
}
25602560
}
25612561
}

src/NHibernate/Impl/StatelessSessionImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ internal StatelessSessionImpl(SessionFactoryImpl factory, ISessionCreationOption
3838
using (new SessionIdLoggingContext(SessionId))
3939
{
4040
temporaryPersistenceContext = new StatefulPersistenceContext(this);
41-
connectionManager = new ConnectionManager(this, options.GetConnection(), ConnectionReleaseMode.AfterTransaction,
41+
connectionManager = new ConnectionManager(this, options.UserSuppliedConnection, ConnectionReleaseMode.AfterTransaction,
4242
EmptyInterceptor.Instance);
4343

4444
if (log.IsDebugEnabled)

0 commit comments

Comments
 (0)