[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 |
|
---|
| 22 | using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
|
---|
| 23 | using HeuristicLab.PluginInfrastructure;
|
---|
[925] | 24 | using System.Runtime.CompilerServices;
|
---|
[948] | 25 | using HeuristicLab.Hive.Contracts.Interfaces;
|
---|
[1099] | 26 | using HeuristicLab.Hive.Server.Core;
|
---|
[826] | 27 |
|
---|
| 28 | /// <summary>
|
---|
| 29 | /// The service locator for the server core
|
---|
| 30 | /// </summary>
|
---|
[925] | 31 | public class ServiceLocator {
|
---|
[826] | 32 | private static DiscoveryService discoveryService =
|
---|
| 33 | new DiscoveryService();
|
---|
| 34 |
|
---|
[925] | 35 | private static ITransactionManager transManager = null;
|
---|
| 36 |
|
---|
[1099] | 37 | private static IClientManager clientManager = null;
|
---|
| 38 |
|
---|
| 39 | private static IJobManager jobManager = null;
|
---|
| 40 |
|
---|
| 41 | private static IUserRoleManager userRoleManager = null;
|
---|
| 42 |
|
---|
| 43 | private static IClientCommunicator clientCommunicator = null;
|
---|
| 44 |
|
---|
| 45 | private static ILifecycleManager lifecycleManager = null;
|
---|
| 46 |
|
---|
[826] | 47 | private static IClientAdapter clientAdapter = null;
|
---|
[899] | 48 |
|
---|
[910] | 49 | private static IClientGroupAdapter clientGroupAdapter = null;
|
---|
| 50 |
|
---|
[925] | 51 | private static IResourceAdapter resourceAdapter = null;
|
---|
| 52 |
|
---|
[899] | 53 | private static IUserAdapter userAdapter = null;
|
---|
[910] | 54 |
|
---|
| 55 | private static IUserGroupAdapter userGroupAdapter = null;
|
---|
[925] | 56 |
|
---|
| 57 | private static IPermissionOwnerAdapter permOwnerAdapter = null;
|
---|
| 58 |
|
---|
[962] | 59 | private static IJobAdapter jobAdapter = null;
|
---|
| 60 |
|
---|
[1005] | 61 | private static IJobResultsAdapter jobResultsAdapter = null;
|
---|
| 62 |
|
---|
[1088] | 63 |
|
---|
[826] | 64 | /// <summary>
|
---|
[925] | 65 | /// Gets the db transaction manager
|
---|
| 66 | /// </summary>
|
---|
| 67 | /// <returns></returns>
|
---|
| 68 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 69 | public static ITransactionManager GetTransactionManager() {
|
---|
| 70 | if (transManager == null) {
|
---|
| 71 | transManager = discoveryService.GetInstances<ITransactionManager>()[0];
|
---|
| 72 | }
|
---|
| 73 |
|
---|
| 74 | return transManager;
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /// <summary>
|
---|
[1099] | 78 | /// Gets the client manager
|
---|
| 79 | /// </summary>
|
---|
| 80 | /// <returns></returns>
|
---|
| 81 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 82 | public static IClientManager GetClientManager() {
|
---|
| 83 | if (clientManager == null)
|
---|
| 84 | clientManager = new ClientManager();
|
---|
| 85 |
|
---|
| 86 | return clientManager;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /// <summary>
|
---|
| 90 | /// Gets the job manager
|
---|
| 91 | /// </summary>
|
---|
| 92 | /// <returns></returns>
|
---|
| 93 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 94 | public static IJobManager GetJobManager() {
|
---|
| 95 | if (jobManager == null)
|
---|
| 96 | jobManager = new JobManager();
|
---|
| 97 |
|
---|
| 98 | return jobManager;
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | /// <summary>
|
---|
| 102 | /// Gets the user role manager
|
---|
| 103 | /// </summary>
|
---|
| 104 | /// <returns></returns>
|
---|
| 105 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 106 | public static IUserRoleManager GetUserRoleManager() {
|
---|
| 107 | if (userRoleManager == null)
|
---|
| 108 | userRoleManager = new UserRoleManager();
|
---|
| 109 |
|
---|
| 110 | return userRoleManager;
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | /// <summary>
|
---|
| 114 | /// Gets the client Communicator
|
---|
| 115 | /// </summary>
|
---|
| 116 | /// <returns></returns>
|
---|
| 117 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 118 | public static IClientCommunicator GetClientCommunicator() {
|
---|
| 119 | if (clientCommunicator == null)
|
---|
| 120 | clientCommunicator = new ClientCommunicator();
|
---|
| 121 |
|
---|
| 122 | return clientCommunicator;
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | /// <summary>
|
---|
| 126 | /// Gets the lifecycle manager
|
---|
| 127 | /// </summary>
|
---|
| 128 | /// <returns></returns>
|
---|
| 129 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 130 | public static ILifecycleManager GetLifecycleManager() {
|
---|
| 131 | if (lifecycleManager == null) {
|
---|
| 132 | lifecycleManager = new LifecycleManager();
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | return lifecycleManager;
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | /// <summary>
|
---|
[826] | 139 | /// Gets the client database adapter
|
---|
| 140 | /// </summary>
|
---|
| 141 | /// <returns></returns>
|
---|
[925] | 142 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 143 | public static IClientAdapter GetClientAdapter() {
|
---|
[826] | 144 | if (clientAdapter == null) {
|
---|
| 145 | clientAdapter = discoveryService.GetInstances<IClientAdapter>()[0];
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 | return clientAdapter;
|
---|
| 149 | }
|
---|
[899] | 150 |
|
---|
| 151 | /// <summary>
|
---|
[910] | 152 | /// Gets the client group database adapter
|
---|
| 153 | /// </summary>
|
---|
| 154 | /// <returns></returns>
|
---|
[925] | 155 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 156 | public static IClientGroupAdapter GetClientGroupAdapter() {
|
---|
[910] | 157 | if (clientGroupAdapter == null) {
|
---|
| 158 | clientGroupAdapter = discoveryService.GetInstances<IClientGroupAdapter>()[0];
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 | return clientGroupAdapter;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
| 164 | /// <summary>
|
---|
[925] | 165 | /// Gets the resource database adapter
|
---|
| 166 | /// </summary>
|
---|
| 167 | /// <returns></returns>
|
---|
| 168 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 169 | public static IResourceAdapter GetResourceAdapter() {
|
---|
| 170 | if (resourceAdapter == null) {
|
---|
| 171 | resourceAdapter = discoveryService.GetInstances<IResourceAdapter>()[0];
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | return resourceAdapter;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /// <summary>
|
---|
[899] | 178 | /// Gets the user database adapter
|
---|
| 179 | /// </summary>
|
---|
| 180 | /// <returns></returns>
|
---|
[925] | 181 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 182 | public static IUserAdapter GetUserAdapter() {
|
---|
[899] | 183 | if (userAdapter == null) {
|
---|
| 184 | userAdapter = discoveryService.GetInstances<IUserAdapter>()[0];
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 | return userAdapter;
|
---|
| 188 | }
|
---|
[910] | 189 |
|
---|
| 190 | /// <summary>
|
---|
| 191 | /// Gets the user group database adapter
|
---|
| 192 | /// </summary>
|
---|
| 193 | /// <returns></returns>
|
---|
[925] | 194 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 195 | public static IUserGroupAdapter GetUserGroupAdapter() {
|
---|
[910] | 196 | if (userGroupAdapter == null) {
|
---|
| 197 | userGroupAdapter = discoveryService.GetInstances<IUserGroupAdapter>()[0];
|
---|
| 198 | }
|
---|
| 199 |
|
---|
| 200 | return userGroupAdapter;
|
---|
| 201 | }
|
---|
[925] | 202 |
|
---|
| 203 | /// <summary>
|
---|
| 204 | /// Gets the permission owner database adapter
|
---|
| 205 | /// </summary>
|
---|
| 206 | /// <returns></returns>
|
---|
| 207 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 208 | public static IPermissionOwnerAdapter GetPermissionOwnerAdapter() {
|
---|
| 209 | if (permOwnerAdapter == null) {
|
---|
| 210 | permOwnerAdapter = discoveryService.GetInstances<IPermissionOwnerAdapter>()[0];
|
---|
| 211 | }
|
---|
| 212 |
|
---|
| 213 | return permOwnerAdapter;
|
---|
| 214 | }
|
---|
[962] | 215 |
|
---|
| 216 | /// <summary>
|
---|
| 217 | /// Gets the job database adapter
|
---|
| 218 | /// </summary>
|
---|
| 219 | /// <returns></returns>
|
---|
| 220 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 221 | public static IJobAdapter GetJobAdapter() {
|
---|
| 222 | if (jobAdapter == null) {
|
---|
| 223 | jobAdapter = discoveryService.GetInstances<IJobAdapter>()[0];
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | return jobAdapter;
|
---|
| 227 | }
|
---|
[1005] | 228 |
|
---|
| 229 | /// <summary>
|
---|
| 230 | /// Gets the job results database adapter
|
---|
| 231 | /// </summary>
|
---|
| 232 | /// <returns></returns>
|
---|
| 233 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 234 | public static IJobResultsAdapter GetJobResultsAdapter() {
|
---|
| 235 | if (jobResultsAdapter == null) {
|
---|
| 236 | jobResultsAdapter = discoveryService.GetInstances<IJobResultsAdapter>()[0];
|
---|
| 237 | }
|
---|
| 238 |
|
---|
| 239 | return jobResultsAdapter;
|
---|
| 240 | }
|
---|
[826] | 241 | } |
---|