Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Server.Console/ServiceLocator.cs @ 833

Last change on this file since 833 was 799, checked in by aleitner, 16 years ago

Added ServiceLocator to project (#380)

File size: 2.0 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6using HeuristicLab.Hive.Contracts.Interfaces;
7using System.ServiceModel;
8
9namespace 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}
Note: See TracBrowser for help on using the repository browser.