-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPluginAgentFactory.cs
31 lines (28 loc) · 1.24 KB
/
PluginAgentFactory.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
using System;
using System.Collections.Generic;
using NewRelic.Platform.Sdk;
namespace org.healthwise.newrelic.rabbitmq
{
class PluginAgentFactory : AgentFactory
{
/// <summary>
/// Creates agents for each item in the plugin.json file
/// </summary>
/// <param name="properties"></param>
/// <returns></returns>
public override Agent CreateAgentWithConfiguration(IDictionary<string, object> properties)
{
string protocol = (string)properties["protocol"];
string name = (string)properties["name"];
string host = (string)properties["host"];
int port = int.Parse((string)properties["port"]);
string username = (string)properties["username"];
string password = (string)properties["password"];
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(host) || string.IsNullOrEmpty(username) || string.IsNullOrEmpty(password))
{
throw new ArgumentNullException("'name', 'host', 'port', 'username' and 'password' cannot be null or empty. Do you have a 'config/plugin.json' file?");
}
return new PluginAgent(protocol, name, host, port, username, password);
}
}
}