[826] | 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 |
|
---|
[1377] | 22 | using HeuristicLab.Hive.Server.DataAccess;
|
---|
[826] | 23 | using HeuristicLab.PluginInfrastructure;
|
---|
[925] | 24 | using System.Runtime.CompilerServices;
|
---|
[948] | 25 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
[1099] | 26 | using HeuristicLab.Hive.Server.Core;
|
---|
[1272] | 27 | using HeuristicLab.Hive.Server.Core.InternalInterfaces;
|
---|
[1377] | 28 | using HeuristicLab.DataAccess.Interfaces;
|
---|
[1468] | 29 | using System.Data.SqlClient;
|
---|
[1648] | 30 | using HeuristicLab.Security.Contracts.Interfaces;
|
---|
[826] | 31 |
|
---|
| 32 | /// <summary>
|
---|
| 33 | /// The service locator for the server core
|
---|
| 34 | /// </summary>
|
---|
[925] | 35 | public class ServiceLocator {
|
---|
[826] | 36 | private static DiscoveryService discoveryService =
|
---|
| 37 | new DiscoveryService();
|
---|
| 38 |
|
---|
[1099] | 39 | private static IClientManager clientManager = null;
|
---|
| 40 |
|
---|
| 41 | private static IJobManager jobManager = null;
|
---|
| 42 |
|
---|
| 43 | private static IClientCommunicator clientCommunicator = null;
|
---|
| 44 |
|
---|
| 45 | private static ILifecycleManager lifecycleManager = null;
|
---|
| 46 |
|
---|
[1468] | 47 | private static ISessionFactory sessionFactory = null;
|
---|
[899] | 48 |
|
---|
[1272] | 49 | private static IScheduler scheduler = null;
|
---|
[1088] | 50 |
|
---|
[1648] | 51 | private static IPermissionManager permManager = null;
|
---|
| 52 |
|
---|
[1768] | 53 | private static IHivePermissionManager hivePermManager = null;
|
---|
| 54 |
|
---|
[826] | 55 | /// <summary>
|
---|
[1099] | 56 | /// Gets the client manager
|
---|
| 57 | /// </summary>
|
---|
| 58 | /// <returns></returns>
|
---|
| 59 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 60 | public static IClientManager GetClientManager() {
|
---|
| 61 | if (clientManager == null)
|
---|
| 62 | clientManager = new ClientManager();
|
---|
| 63 |
|
---|
| 64 | return clientManager;
|
---|
| 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 IClientCommunicator GetClientCommunicator() {
|
---|
| 85 | if (clientCommunicator == null)
|
---|
| 86 | clientCommunicator = new ClientCommunicator();
|
---|
| 87 |
|
---|
| 88 | return clientCommunicator;
|
---|
| 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 = new LifecycleManager();
|
---|
| 99 | }
|
---|
| 100 | return lifecycleManager;
|
---|
| 101 | }
|
---|
| 102 |
|
---|
| 103 | /// <summary>
|
---|
[1468] | 104 | /// Gets the db session factory
|
---|
[826] | 105 | /// </summary>
|
---|
| 106 | /// <returns></returns>
|
---|
[925] | 107 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
[1468] | 108 | public static ISessionFactory GetSessionFactory() {
|
---|
| 109 | if (sessionFactory == null) {
|
---|
| 110 | sessionFactory =
|
---|
| 111 | discoveryService.GetInstances<ISessionFactory>()[0];
|
---|
[826] | 112 |
|
---|
[1468] | 113 | sessionFactory.DbConnectionType =
|
---|
| 114 | typeof(SqlConnection);
|
---|
| 115 |
|
---|
| 116 | sessionFactory.DbConnectionString =
|
---|
| 117 | HeuristicLab.Hive.Server.Core.Properties.Settings.Default.HiveServerConnectionString;
|
---|
[910] | 118 | }
|
---|
| 119 |
|
---|
[1468] | 120 | return sessionFactory;
|
---|
[910] | 121 | }
|
---|
| 122 |
|
---|
| 123 | /// <summary>
|
---|
[1272] | 124 | /// Gets the scheduler
|
---|
| 125 | /// </summary>
|
---|
| 126 | /// <returns></returns>
|
---|
| 127 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 128 | public static IScheduler GetScheduler() {
|
---|
| 129 | if (scheduler == null) {
|
---|
| 130 | scheduler = discoveryService.GetInstances<IScheduler>()[0];
|
---|
| 131 | }
|
---|
| 132 |
|
---|
| 133 | return scheduler;
|
---|
| 134 | }
|
---|
[1648] | 135 |
|
---|
| 136 | /// <summary>
|
---|
| 137 | /// Gets the permission manager
|
---|
| 138 | /// </summary>
|
---|
| 139 | /// <returns></returns>
|
---|
| 140 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 141 | public static IPermissionManager GetPermissionManager() {
|
---|
| 142 | if (permManager == null)
|
---|
| 143 | permManager = discoveryService.GetInstances<IPermissionManager>()[0];
|
---|
| 144 | return permManager;
|
---|
| 145 |
|
---|
| 146 | }
|
---|
[1768] | 147 |
|
---|
| 148 | /// <summary>
|
---|
| 149 | /// Gets the permission manager
|
---|
| 150 | /// </summary>
|
---|
| 151 | /// <returns></returns>
|
---|
| 152 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 153 | public static IHivePermissionManager GetHivePermissionManager() {
|
---|
| 154 | if (hivePermManager == null)
|
---|
| 155 | hivePermManager = discoveryService.GetInstances<IHivePermissionManager>()[0];
|
---|
| 156 | return hivePermManager;
|
---|
| 157 |
|
---|
| 158 | }
|
---|
[826] | 159 | } |
---|