#region License Information
/* HeuristicLab
* Copyright (C) 2002-2008 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
*
* This file is part of HeuristicLab.
*
* HeuristicLab is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HeuristicLab is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with HeuristicLab. If not, see .
*/
#endregion
using HeuristicLab.Hive.Server.DataAccess;
using HeuristicLab.PluginInfrastructure;
using System.Runtime.CompilerServices;
using HeuristicLab.Hive.Contracts.Interfaces;
using HeuristicLab.Hive.Server.Core;
using HeuristicLab.Hive.Server.Core.InternalInterfaces;
using HeuristicLab.DataAccess.Interfaces;
using System.Data.SqlClient;
using HeuristicLab.Security.Contracts.Interfaces;
///
/// The service locator for the server core
///
public class ServiceLocator {
private static DiscoveryService discoveryService =
new DiscoveryService();
private static IClientManager clientManager = null;
private static IJobManager jobManager = null;
private static IClientCommunicator clientCommunicator = null;
private static ILifecycleManager lifecycleManager = null;
private static ISessionFactory sessionFactory = null;
private static IScheduler scheduler = null;
private static IPermissionManager permManager = null;
private static IHivePermissionManager hivePermManager = null;
///
/// Gets the client manager
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IClientManager GetClientManager() {
if (clientManager == null)
clientManager = new ClientManager();
return clientManager;
}
///
/// Gets the job manager
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IJobManager GetJobManager() {
if (jobManager == null)
jobManager = new JobManager();
return jobManager;
}
///
/// Gets the client Communicator
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IClientCommunicator GetClientCommunicator() {
if (clientCommunicator == null)
clientCommunicator = new ClientCommunicator();
return clientCommunicator;
}
///
/// Gets the lifecycle manager
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static ILifecycleManager GetLifecycleManager() {
if (lifecycleManager == null) {
lifecycleManager = new LifecycleManager();
}
return lifecycleManager;
}
///
/// Gets the db session factory
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static ISessionFactory GetSessionFactory() {
if (sessionFactory == null) {
sessionFactory =
discoveryService.GetInstances()[0];
sessionFactory.DbConnectionType =
typeof(SqlConnection);
sessionFactory.DbConnectionString =
HeuristicLab.Hive.Server.Core.Properties.Settings.Default.HiveServerConnectionString;
}
return sessionFactory;
}
///
/// Gets the scheduler
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IScheduler GetScheduler() {
if (scheduler == null) {
scheduler = discoveryService.GetInstances()[0];
}
return scheduler;
}
///
/// Gets the permission manager
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IPermissionManager GetPermissionManager() {
if (permManager == null)
permManager = discoveryService.GetInstances()[0];
return permManager;
}
///
/// Gets the permission manager
///
///
[MethodImpl(MethodImplOptions.Synchronized)]
public static IHivePermissionManager GetHivePermissionManager() {
if (hivePermManager == null)
hivePermManager = discoveryService.GetInstances()[0];
return hivePermManager;
}
}