Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ServiceLocator.cs @ 4302

Last change on this file since 4302 was 4302, checked in by cneumuel, 14 years ago
  • made ServerConsole work with wsHttpBinding
  • applied role-base restrictions to all WCF-Services
  • made wcf-services work with certificates
  • renamed ExecutionEngineFacade to ClientFacade

(#1168)

File size: 4.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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 System.Linq;
23using HeuristicLab.Hive.Server.DataAccess;
24using HeuristicLab.PluginInfrastructure;
25using System.Runtime.CompilerServices;
26using HeuristicLab.Hive.Contracts.Interfaces;
27using HeuristicLab.Hive.Server.Core;
28using HeuristicLab.Hive.Server.Core.InternalInterfaces;
29using HeuristicLab.DataAccess.Interfaces;
30using System.Data.SqlClient;
31
32namespace HeuristicLab.Hive.Server.Core {
33  /// <summary>
34  /// The service locator for the server core
35  /// </summary>
36  public class ServiceLocator {
37    private static ISlaveManager slaveManager = null;
38
39    private static IJobManager jobManager = null;
40
41    private static ISlaveCommunicator slaveCommunicator = null;
42
43    private static ILifecycleManager lifecycleManager = null;
44
45    private static ISessionFactory sessionFactory = null;
46
47    private static IScheduler scheduler = null;
48
49    //private static IPermissionManager permManager = null;
50
51    private static IHivePermissionManager hivePermManager = null;
52
53    private static IContextFactory contextFactory = null;
54
55    /// <summary>
56    /// Gets the slave manager
57    /// </summary>
58    /// <returns></returns>
59    [MethodImpl(MethodImplOptions.Synchronized)]
60    public static ISlaveManager GetSlaveManager() {
61      if (slaveManager == null)
62        slaveManager = new SlaveManager();
63
64      return slaveManager;
65    }
66
67    /// <summary>
68    /// Gets the job manager
69    /// </summary>
70    /// <returns></returns>
71    [MethodImpl(MethodImplOptions.Synchronized)]
72    public static IJobManager GetJobManager() {
73      if (jobManager == null)
74        jobManager = new JobManager();
75
76      return jobManager;
77    }
78
79    /// <summary>
80    /// Gets the client Communicator
81    /// </summary>
82    /// <returns></returns>
83    [MethodImpl(MethodImplOptions.Synchronized)]
84    public static ISlaveCommunicator GetSlaveCommunicator() {
85      if (slaveCommunicator == null)
86        slaveCommunicator = new SlaveCommunicator();
87
88      return slaveCommunicator;
89    }
90
91    /// <summary>
92    /// Gets the lifecycle manager
93    /// </summary>
94    /// <returns></returns>
95    [MethodImpl(MethodImplOptions.Synchronized)]
96    public static ILifecycleManager GetLifecycleManager() {
97      if (lifecycleManager == null) {
98        lifecycleManager = ApplicationManager.Manager.GetInstances<ILifecycleManager>().First();
99      }
100      return lifecycleManager;
101    }
102
103    /// <summary>
104    /// Gets the scheduler
105    /// </summary>
106    /// <returns></returns>
107    [MethodImpl(MethodImplOptions.Synchronized)]
108    public static IScheduler GetScheduler() {
109      if (scheduler == null) {
110        scheduler = ApplicationManager.Manager.GetInstances<IScheduler>().First();
111      }
112
113      return scheduler;
114    }
115
116    /// <summary>
117    /// Gets the permission manager
118    /// </summary>
119    /// <returns></returns>
120    //[MethodImpl(MethodImplOptions.Synchronized)]
121    //public static IPermissionManager GetPermissionManager() {
122    //  if (permManager == null)
123    //    permManager = ApplicationManager.Manager.GetInstances<IPermissionManager>().First();
124    //  return permManager;
125
126    //}
127
128    ///// <summary>
129    ///// Gets the permission manager
130    ///// </summary>
131    ///// <returns></returns>
132    //[MethodImpl(MethodImplOptions.Synchronized)]
133    //public static IHivePermissionManager GetHivePermissionManager() {
134    //  if (hivePermManager == null)
135    //    hivePermManager = ApplicationManager.Manager.GetInstances<IHivePermissionManager>().First();
136    //  return hivePermManager;
137
138    //}
139
140    /// <summary>
141    /// Gets the database context manager
142    /// </summary>
143    /// <returns></returns>
144    [MethodImpl(MethodImplOptions.Synchronized)]
145    public static IContextFactory GetContextFactory() {
146      if (contextFactory == null)
147        contextFactory = ApplicationManager.Manager.GetInstances<IContextFactory>().First();
148      return contextFactory;
149    }
150  }
151}
Note: See TracBrowser for help on using the repository browser.