Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes #183 cannot register trigger persistence delegates with assembl…

…y qualified names
  • Loading branch information...
commit e4e71b78bea5a4b7cb41408902207e9880b027ad 1 parent 0b932db
@lahma lahma authored
View
24 src/Quartz.Tests.Unit/Impl/AdoJobStore/StdAdoDelegateTest.cs
@@ -235,6 +235,25 @@ public void TestSelectSimpleTriggerWithDeleteBeforeSelectExtendedProps()
persistenceDelegate.AssertWasCalled(x => x.LoadExtendedTriggerProperties(Arg<ConnectionAndTransactionHolder>.Is.Anything, Arg<TriggerKey>.Is.Anything));
}
+ [Test]
+ public void ShouldSupportAssemblyQualifiedTriggerPersistenceDelegates()
+ {
+ StdAdoDelegate adoDelegate = new TestStdAdoDelegate(new SimpleTriggerPersistenceDelegate());
+
+ var delegateInitializationArgs = new DelegateInitializationArgs
+ {
+ TablePrefix = "QRTZ_",
+ InstanceId = "TESTSCHED",
+ InstanceName = "INSTANCE",
+ TypeLoadHelper = new SimpleTypeLoadHelper(),
+ UseProperties = false,
+ InitString = "triggerPersistenceDelegateClasses=" + typeof(TestTriggerPersistenceDelegate).AssemblyQualifiedName + ";" + typeof(TestTriggerPersistenceDelegate).AssemblyQualifiedName,
+ Logger = LogManager.GetLogger(GetType()),
+ DbProvider = MockRepository.GenerateMock<IDbProvider>()
+ };
+ adoDelegate.Initialize(delegateInitializationArgs);
+ }
+
private class TestStdAdoDelegate : StdAdoDelegate
{
private readonly ITriggerPersistenceDelegate testDelegate;
@@ -364,4 +383,9 @@ public override void AddRange(Array values)
{
}
}
+
+ public class TestTriggerPersistenceDelegate : SimpleTriggerPersistenceDelegate
+ {
+
+ }
}
View
34 src/Quartz/Impl/AdoJobStore/StdAdoDelegate.cs
@@ -82,22 +82,44 @@ public virtual void Initialize(DelegateInitializationArgs args)
foreach (string setting in settings)
{
- string[] parts = setting.Split('=');
- string name = parts[0];
- if (parts.Length == 1 || parts[1] == null || parts[1].Equals(""))
+ var index = setting.IndexOf('=');
+ if (index == -1 || index == setting.Length - 1)
{
continue;
}
- if (name.Equals("triggerPersistenceDelegateClasses"))
+ string name = setting.Substring(0, index).Trim();
+ string value = setting.Substring(index + 1).Trim();
+
+ if (string.IsNullOrEmpty(value))
+ {
+ continue;
+ }
+
+ // we support old *Classes and new *Types, latter has better support for assembly qualified names
+ if (name.Equals("triggerPersistenceDelegateClasses") || name.Equals("triggerPersistenceDelegateTypes"))
{
- string[] trigDelegates = parts[1].Split(',');
+ var separator = ',';
+ if (value.IndexOf(';') != -1 || name.Equals("triggerPersistenceDelegateTypes"))
+ {
+ // use separator that allows assembly qualified names
+ separator = ';';
+ }
+
+ string[] trigDelegates = value.Split(separator);
foreach (string triggerTypeName in trigDelegates)
{
+ var typeName = triggerTypeName.Trim();
+
+ if (string.IsNullOrEmpty(typeName))
+ {
+ continue;
+ }
+
try
{
- Type trigDelClass = typeLoadHelper.LoadType(triggerTypeName);
+ Type trigDelClass = typeLoadHelper.LoadType(typeName);
AddTriggerPersistenceDelegate((ITriggerPersistenceDelegate) Activator.CreateInstance(trigDelClass));
}
catch (Exception e)
Please sign in to comment.
Something went wrong with that request. Please try again.