[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;
|
---|
[826] | 26 |
|
---|
| 27 | /// <summary>
|
---|
| 28 | /// The service locator for the server core
|
---|
| 29 | /// </summary>
|
---|
[925] | 30 | public class ServiceLocator {
|
---|
[826] | 31 | private static DiscoveryService discoveryService =
|
---|
| 32 | new DiscoveryService();
|
---|
| 33 |
|
---|
[925] | 34 | private static ITransactionManager transManager = null;
|
---|
| 35 |
|
---|
[826] | 36 | private static IClientAdapter clientAdapter = null;
|
---|
[899] | 37 |
|
---|
[910] | 38 | private static IClientGroupAdapter clientGroupAdapter = null;
|
---|
| 39 |
|
---|
[925] | 40 | private static IResourceAdapter resourceAdapter = null;
|
---|
| 41 |
|
---|
[899] | 42 | private static IUserAdapter userAdapter = null;
|
---|
[910] | 43 |
|
---|
| 44 | private static IUserGroupAdapter userGroupAdapter = null;
|
---|
[925] | 45 |
|
---|
| 46 | private static IPermissionOwnerAdapter permOwnerAdapter = null;
|
---|
| 47 |
|
---|
[962] | 48 | private static IJobAdapter jobAdapter = null;
|
---|
| 49 |
|
---|
[826] | 50 | /// <summary>
|
---|
[925] | 51 | /// Gets the db transaction manager
|
---|
| 52 | /// </summary>
|
---|
| 53 | /// <returns></returns>
|
---|
| 54 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 55 | public static ITransactionManager GetTransactionManager() {
|
---|
| 56 | if (transManager == null) {
|
---|
| 57 | transManager = discoveryService.GetInstances<ITransactionManager>()[0];
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | return transManager;
|
---|
| 61 | }
|
---|
| 62 |
|
---|
| 63 | /// <summary>
|
---|
[826] | 64 | /// Gets the client database adapter
|
---|
| 65 | /// </summary>
|
---|
| 66 | /// <returns></returns>
|
---|
[925] | 67 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 68 | public static IClientAdapter GetClientAdapter() {
|
---|
[826] | 69 | if (clientAdapter == null) {
|
---|
| 70 | clientAdapter = discoveryService.GetInstances<IClientAdapter>()[0];
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | return clientAdapter;
|
---|
| 74 | }
|
---|
[899] | 75 |
|
---|
| 76 | /// <summary>
|
---|
[910] | 77 | /// Gets the client group database adapter
|
---|
| 78 | /// </summary>
|
---|
| 79 | /// <returns></returns>
|
---|
[925] | 80 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 81 | public static IClientGroupAdapter GetClientGroupAdapter() {
|
---|
[910] | 82 | if (clientGroupAdapter == null) {
|
---|
| 83 | clientGroupAdapter = discoveryService.GetInstances<IClientGroupAdapter>()[0];
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | return clientGroupAdapter;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | /// <summary>
|
---|
[925] | 90 | /// Gets the resource database adapter
|
---|
| 91 | /// </summary>
|
---|
| 92 | /// <returns></returns>
|
---|
| 93 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 94 | public static IResourceAdapter GetResourceAdapter() {
|
---|
| 95 | if (resourceAdapter == null) {
|
---|
| 96 | resourceAdapter = discoveryService.GetInstances<IResourceAdapter>()[0];
|
---|
| 97 | }
|
---|
| 98 |
|
---|
| 99 | return resourceAdapter;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | /// <summary>
|
---|
[899] | 103 | /// Gets the user database adapter
|
---|
| 104 | /// </summary>
|
---|
| 105 | /// <returns></returns>
|
---|
[925] | 106 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 107 | public static IUserAdapter GetUserAdapter() {
|
---|
[899] | 108 | if (userAdapter == null) {
|
---|
| 109 | userAdapter = discoveryService.GetInstances<IUserAdapter>()[0];
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | return userAdapter;
|
---|
| 113 | }
|
---|
[910] | 114 |
|
---|
| 115 | /// <summary>
|
---|
| 116 | /// Gets the user group database adapter
|
---|
| 117 | /// </summary>
|
---|
| 118 | /// <returns></returns>
|
---|
[925] | 119 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 120 | public static IUserGroupAdapter GetUserGroupAdapter() {
|
---|
[910] | 121 | if (userGroupAdapter == null) {
|
---|
| 122 | userGroupAdapter = discoveryService.GetInstances<IUserGroupAdapter>()[0];
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | return userGroupAdapter;
|
---|
| 126 | }
|
---|
[925] | 127 |
|
---|
| 128 | /// <summary>
|
---|
| 129 | /// Gets the permission owner database adapter
|
---|
| 130 | /// </summary>
|
---|
| 131 | /// <returns></returns>
|
---|
| 132 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 133 | public static IPermissionOwnerAdapter GetPermissionOwnerAdapter() {
|
---|
| 134 | if (permOwnerAdapter == null) {
|
---|
| 135 | permOwnerAdapter = discoveryService.GetInstances<IPermissionOwnerAdapter>()[0];
|
---|
| 136 | }
|
---|
| 137 |
|
---|
| 138 | return permOwnerAdapter;
|
---|
| 139 | }
|
---|
[962] | 140 |
|
---|
| 141 | /// <summary>
|
---|
| 142 | /// Gets the job database adapter
|
---|
| 143 | /// </summary>
|
---|
| 144 | /// <returns></returns>
|
---|
| 145 | [MethodImpl(MethodImplOptions.Synchronized)]
|
---|
| 146 | public static IJobAdapter GetJobAdapter() {
|
---|
| 147 | if (jobAdapter == null) {
|
---|
| 148 | jobAdapter = discoveryService.GetInstances<IJobAdapter>()[0];
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | return jobAdapter;
|
---|
| 152 | }
|
---|
[826] | 153 | } |
---|