#164 improve performance a bit
* faster data structure access * less memory allocations
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <EFBFBD> 2002-2011 the original author or authors.
|
||||
* Copyright © 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace Spring.Objects.Factory
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
public IList<string> DependsOn
|
||||
public IReadOnlyList<string> DependsOn
|
||||
{
|
||||
get { throw new NotImplementedException(); }
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Spring.Objects.Factory.Xml
|
||||
protected void SetUp()
|
||||
{
|
||||
parent = new DefaultListableObjectFactory();
|
||||
IDictionary<string, object> m = new Dictionary<string, object>();
|
||||
var m = new Dictionary<string, object>();
|
||||
m["name"] = "Albert";
|
||||
parent.RegisterObjectDefinition("father", new RootObjectDefinition(typeof(TestObject), new MutablePropertyValues(m)));
|
||||
m = new Dictionary<string, object>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2011 the original author or authors.
|
||||
* Copyright <20> 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,6 @@
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
@@ -35,8 +33,6 @@ using Spring.Objects.Factory.Config;
|
||||
using Spring.Objects.Factory.Support;
|
||||
using Spring.Util;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring.Objects.Factory.Xml
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright <20> 2002-2011 the original author or authors.
|
||||
* Copyright <20> 2002-2011 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -963,8 +963,8 @@ namespace Spring.Objects.Factory.Xml
|
||||
|
||||
LazyWorker lw1 = new LazyWorker(xof);
|
||||
LazyWorker lw2 = new LazyWorker(xof);
|
||||
Thread thread1 = new Thread(new ThreadStart(lw1.DoWork));
|
||||
Thread thread2 = new Thread(new ThreadStart(lw2.DoWork));
|
||||
Thread thread1 = new Thread(lw1.DoWork);
|
||||
Thread thread2 = new Thread(lw2.DoWork);
|
||||
|
||||
thread1.Start();
|
||||
Thread.Sleep(1000);
|
||||
@@ -1883,10 +1883,7 @@ namespace Spring.Objects.Factory.Xml
|
||||
objectFromContext = xof.GetObject("lazyObject");
|
||||
}
|
||||
|
||||
public Object ObjectFromContext
|
||||
{
|
||||
get { return objectFromContext; }
|
||||
}
|
||||
public Object ObjectFromContext => objectFromContext;
|
||||
}
|
||||
public sealed class MyTestObject
|
||||
{
|
||||
@@ -1894,20 +1891,17 @@ namespace Spring.Objects.Factory.Xml
|
||||
|
||||
public Type[] Types
|
||||
{
|
||||
get { return _types; }
|
||||
set { _types = value; }
|
||||
get => _types;
|
||||
set => _types = value;
|
||||
}
|
||||
|
||||
public CultureInfo Culture
|
||||
{
|
||||
get { return _culture; }
|
||||
set { _culture = value; }
|
||||
get => _culture;
|
||||
set => _culture = value;
|
||||
}
|
||||
|
||||
public CultureInfo MyDefaultCulture
|
||||
{
|
||||
get { return Default; }
|
||||
}
|
||||
public CultureInfo MyDefaultCulture => Default;
|
||||
|
||||
private Type[] _types;
|
||||
private CultureInfo _culture;
|
||||
@@ -1925,8 +1919,8 @@ namespace Spring.Objects.Factory.Xml
|
||||
{
|
||||
public int Num
|
||||
{
|
||||
get { return num; }
|
||||
set { num = value; }
|
||||
get => num;
|
||||
set => num = value;
|
||||
}
|
||||
|
||||
private int num;
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace Spring.Objects
|
||||
[Test]
|
||||
public void InstantiationWithNulls ()
|
||||
{
|
||||
MutablePropertyValues props = new MutablePropertyValues ((IDictionary<string, object>) null);
|
||||
MutablePropertyValues props = new MutablePropertyValues((Dictionary<string, object>) null);
|
||||
Assert.AreEqual (0, props.PropertyValues.Count);
|
||||
MutablePropertyValues props2 = new MutablePropertyValues ((IPropertyValues) null);
|
||||
Assert.AreEqual (0, props2.PropertyValues.Count);
|
||||
@@ -97,7 +97,7 @@ namespace Spring.Objects
|
||||
MutablePropertyValues props = new MutablePropertyValues ();
|
||||
props.Add (new PropertyValue ("Name", "Fiona Apple"));
|
||||
props.Add (new PropertyValue ("Age", 24));
|
||||
props.AddAll ((IList<PropertyValue>) null);
|
||||
props.AddAll((List<PropertyValue>) null);
|
||||
Assert.AreEqual (2, props.PropertyValues.Count);
|
||||
}
|
||||
|
||||
@@ -157,7 +157,7 @@ namespace Spring.Objects
|
||||
[Test]
|
||||
public void ChangesSince ()
|
||||
{
|
||||
IDictionary<string, object> map = new Dictionary<string, object>();
|
||||
Dictionary<string, object> map = new Dictionary<string, object>();
|
||||
PropertyValue propName = new PropertyValue("Name", "Fiona Apple");
|
||||
map.Add (propName.Name, propName.Value);
|
||||
map.Add ("Age", 24);
|
||||
@@ -183,7 +183,7 @@ namespace Spring.Objects
|
||||
[Test]
|
||||
public void ChangesSinceWithSelf ()
|
||||
{
|
||||
IDictionary<string, object> map = new Dictionary<string, object>();
|
||||
Dictionary<string, object> map = new Dictionary<string, object>();
|
||||
map.Add("Name", "Fiona Apple");
|
||||
map.Add ("Age", 24);
|
||||
MutablePropertyValues props = new MutablePropertyValues (map);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using NUnit.Framework;
|
||||
using Spring.Collections;
|
||||
|
||||
namespace Spring.Transaction.Interceptor
|
||||
{
|
||||
@@ -10,75 +9,83 @@ namespace Spring.Transaction.Interceptor
|
||||
public class RuleBasedTransactionAttributeTests
|
||||
{
|
||||
[Test]
|
||||
public void DefaultRule()
|
||||
public void DefaultRule()
|
||||
{
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute();
|
||||
var rta = new RuleBasedTransactionAttribute();
|
||||
Assert.IsTrue(rta.RollbackOn(new SystemException()));
|
||||
//mlp 3/17 changed rollback to rollback on all exceptions.
|
||||
//mlp 3/17 changed rollback to rollback on all exceptions.
|
||||
Assert.IsTrue(rta.RollbackOn(new ApplicationException()));
|
||||
Assert.IsTrue( rta.RollbackOn(new TransactionSystemException()));
|
||||
Assert.IsTrue(rta.RollbackOn(new TransactionSystemException()));
|
||||
}
|
||||
[Test]
|
||||
public void RuleForRollbackOnApplicationException()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add(new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
|
||||
Assert.IsTrue( rta.RollbackOn(new SystemException()));
|
||||
//mlp 3/17 changed rollback to rollback on all exceptions.
|
||||
Assert.IsTrue( rta.RollbackOn(new ApplicationException()));
|
||||
Assert.IsTrue(( rta.RollbackOn( new TransactionSystemException())));
|
||||
}
|
||||
[Test]
|
||||
public void RuleForCommitOnUnchecked()
|
||||
public void RuleForRollbackOnApplicationException()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add( new NoRollbackRuleAttribute("System.SystemException"));
|
||||
var list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
RuleBasedTransactionAttribute
|
||||
rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
|
||||
Assert.IsTrue(rta.RollbackOn(new SystemException()));
|
||||
//mlp 3/17 changed rollback to rollback on all exceptions.
|
||||
Assert.IsTrue(rta.RollbackOn(new ApplicationException()));
|
||||
Assert.IsTrue((rta.RollbackOn(new TransactionSystemException())));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RuleForCommitOnUnchecked()
|
||||
{
|
||||
var list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new NoRollbackRuleAttribute("System.SystemException"));
|
||||
list.Add(new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
Assert.IsFalse( rta.RollbackOn(new SystemException()));
|
||||
Assert.IsTrue( rta.RollbackOn(new TransactionSystemException()));
|
||||
var rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
Assert.IsFalse(rta.RollbackOn(new SystemException()));
|
||||
Assert.IsTrue(rta.RollbackOn(new TransactionSystemException()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RuleForSelectiveRollbackOnCheckedWithString()
|
||||
public void RuleForSelectiveRollbackOnCheckedWithString()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add( new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
ruleForSelectionRollbackOnChecked( rta );
|
||||
IList<RollbackRuleAttribute> list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new RollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
var rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
ruleForSelectionRollbackOnChecked(rta);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RuleForSelectiveRollbackOnCheckedWithClass()
|
||||
public void RuleForSelectiveRollbackOnCheckedWithClass()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add( new RollbackRuleAttribute(typeof(TransactionSystemException)));
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
ruleForSelectionRollbackOnChecked( rta );
|
||||
var list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new RollbackRuleAttribute(typeof(TransactionSystemException)));
|
||||
var rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
ruleForSelectionRollbackOnChecked(rta);
|
||||
}
|
||||
private void ruleForSelectionRollbackOnChecked( RuleBasedTransactionAttribute rta )
|
||||
|
||||
private void ruleForSelectionRollbackOnChecked(RuleBasedTransactionAttribute rta)
|
||||
{
|
||||
Assert.IsTrue(rta.RollbackOn(new SystemException()));
|
||||
Assert.IsTrue( rta.RollbackOn(new TransactionSystemException()));
|
||||
Assert.IsTrue(rta.RollbackOn(new TransactionSystemException()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RuleForCommitOnSubclassOfChecked()
|
||||
public void RuleForCommitOnSubclassOfChecked()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add( new RollbackRuleAttribute("System.Data.DataException"));
|
||||
list.Add( new NoRollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
|
||||
Assert.IsTrue( rta.RollbackOn(new SystemException()));
|
||||
Assert.IsFalse( rta.RollbackOn(new TransactionSystemException()));
|
||||
var list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new RollbackRuleAttribute("System.Data.DataException"));
|
||||
list.Add(new NoRollbackRuleAttribute("Spring.Transaction.TransactionSystemException"));
|
||||
var rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
|
||||
Assert.IsTrue(rta.RollbackOn(new SystemException()));
|
||||
Assert.IsFalse(rta.RollbackOn(new TransactionSystemException()));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RollbackNever()
|
||||
public void RollbackNever()
|
||||
{
|
||||
IList list = new LinkedList();
|
||||
list.Add( new NoRollbackRuleAttribute("System.Exception"));
|
||||
RuleBasedTransactionAttribute rta = new RuleBasedTransactionAttribute( TransactionPropagation.Required, list );
|
||||
var list = new List<RollbackRuleAttribute>();
|
||||
list.Add(new NoRollbackRuleAttribute("System.Exception"));
|
||||
var rta = new RuleBasedTransactionAttribute(TransactionPropagation.Required, list);
|
||||
|
||||
Assert.IsFalse(rta.RollbackOn(new SystemException()));
|
||||
Assert.IsFalse(rta.RollbackOn(new DataException()));
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using Apache.NMS;
|
||||
using NUnit.Framework;
|
||||
using Spring.Collections;
|
||||
@@ -59,7 +60,7 @@ namespace Spring.Messaging.Nms.Connections
|
||||
|
||||
private CachedSession CreateCachedSession(ISession targetSession)
|
||||
{
|
||||
return new CachedSession(targetSession, new LinkedList(), new CachingConnectionFactory());
|
||||
return new CachedSession(targetSession, new List<ISession>(), new CachingConnectionFactory());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user