1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 |
|
---|
6 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
7 | using System.ServiceModel;
|
---|
8 |
|
---|
9 | namespace HeuristicLab.Hive.Server.Console {
|
---|
10 | internal class ServiceLocator {
|
---|
11 | private static IClientManager clientManager = null;
|
---|
12 | private static IJobManager jobManager = null;
|
---|
13 | private static IUserRoleManager userManager = null;
|
---|
14 |
|
---|
15 | internal static string Address { get; set; }
|
---|
16 | internal static string Port { get; set; }
|
---|
17 |
|
---|
18 | internal static IClientManager GetClientManager() {
|
---|
19 | if (clientManager == null &&
|
---|
20 | Address != String.Empty &&
|
---|
21 | Port != String.Empty) {
|
---|
22 | ChannelFactory<IClientManager> factory =
|
---|
23 | new ChannelFactory<IClientManager>(
|
---|
24 | new NetTcpBinding(),
|
---|
25 | new EndpointAddress("net.tcp://" + Address + ":" + Port + "/HiveServerConsole/ClientManager"));
|
---|
26 |
|
---|
27 | clientManager = factory.CreateChannel();
|
---|
28 | }
|
---|
29 |
|
---|
30 | return clientManager;
|
---|
31 | }
|
---|
32 |
|
---|
33 | internal static IJobManager GetJobManager() {
|
---|
34 | if (jobManager == null &&
|
---|
35 | Address != String.Empty &&
|
---|
36 | Port != String.Empty) {
|
---|
37 | ChannelFactory<IJobManager> factory =
|
---|
38 | new ChannelFactory<IJobManager>(
|
---|
39 | new NetTcpBinding(),
|
---|
40 | new EndpointAddress("net.tcp://" + Address + ":" + Port + "/HiveServerConsole/JobManager"));
|
---|
41 |
|
---|
42 | jobManager = factory.CreateChannel();
|
---|
43 | }
|
---|
44 |
|
---|
45 | return jobManager;
|
---|
46 | }
|
---|
47 |
|
---|
48 | internal static IUserRoleManager GetUserRoleManager() {
|
---|
49 | if (userManager == null &&
|
---|
50 | Address != String.Empty &&
|
---|
51 | Port != String.Empty) {
|
---|
52 | ChannelFactory<IUserRoleManager> factory =
|
---|
53 | new ChannelFactory<IUserRoleManager>(
|
---|
54 | new NetTcpBinding(),
|
---|
55 | new EndpointAddress("net.tcp://" + Address + ":" + Port + "/HiveServerConsole/UserRoleManager"));
|
---|
56 |
|
---|
57 | userManager = factory.CreateChannel();
|
---|
58 | }
|
---|
59 |
|
---|
60 | return userManager;
|
---|
61 | }
|
---|
62 | }
|
---|
63 | }
|
---|