Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.Services.Hive/3.3/ServiceLocator.cs @ 13887

Last change on this file since 13887 was 12962, checked in by ascheibe, 9 years ago

#2388 merged r12878, r12879, r12883, r12885, r12913, r12914, r12925, r12932, r12961 into stable

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Services.Hive.DataAccess;
23using HeuristicLab.Services.Hive.DataAccess.Interfaces;
24using HeuristicLab.Services.Hive.DataAccess.Manager;
25using HeuristicLab.Services.Hive.Manager;
26
27namespace HeuristicLab.Services.Hive {
28  public class ServiceLocator : IServiceLocator {
29    private static IServiceLocator instance;
30    public static IServiceLocator Instance {
31      get {
32        if (instance == null) instance = new ServiceLocator();
33        return instance;
34      }
35      set { instance = value; }
36    }
37
38    public IPersistenceManager PersistenceManager {
39      get {
40        var dataContext = HiveOperationContext.Current != null
41                            ? HiveOperationContext.Current.DataContext
42                            : new HiveDataContext(Settings.Default.HeuristicLab_Hive_LinqConnectionString);
43        return new PersistenceManager(dataContext);
44      }
45    }
46
47    private Access.IRoleVerifier roleVerifier;
48    public Access.IRoleVerifier RoleVerifier {
49      get {
50        if (roleVerifier == null) roleVerifier = new Access.RoleVerifier();
51        return roleVerifier;
52      }
53    }
54
55    private IAuthorizationManager authorizationManager;
56    public IAuthorizationManager AuthorizationManager {
57      get {
58        if (authorizationManager == null) authorizationManager = new AuthorizationManager();
59        return authorizationManager;
60      }
61    }
62
63    private IEventManager eventManager;
64    public IEventManager EventManager {
65      get {
66        if (eventManager == null) eventManager = new EventManager();
67        return eventManager;
68      }
69    }
70
71    private IStatisticsGenerator statisticsGenerator;
72    public IStatisticsGenerator StatisticsGenerator {
73      get { return statisticsGenerator ?? (statisticsGenerator = new HiveStatisticsGenerator()); }
74    }
75
76    private Access.IUserManager userManager;
77    public Access.IUserManager UserManager {
78      get {
79        if (userManager == null) userManager = new Access.UserManager();
80        return userManager;
81      }
82    }
83
84    private HeartbeatManager heartbeatManager;
85    public HeartbeatManager HeartbeatManager {
86      get {
87        if (heartbeatManager == null) heartbeatManager = new HeartbeatManager();
88        return heartbeatManager;
89      }
90    }
91
92    private ITaskScheduler taskScheduler;
93    public ITaskScheduler TaskScheduler {
94      get {
95        if (taskScheduler == null) taskScheduler = new RoundRobinTaskScheduler();
96        return taskScheduler;
97      }
98    }
99  }
100}
Note: See TracBrowser for help on using the repository browser.