Index: /trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Contracts/HeuristicLab.Hive.Contracts.csproj	(revision 925)
@@ -4,5 +4,5 @@
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{134F93D7-E7C8-4ECD-9923-7F63259A60D8}</ProjectGuid>
@@ -87,4 +87,5 @@
     <Compile Include="Interfaces\IClientManager.cs" />
     <Compile Include="Interfaces\IJobManager.cs" />
+    <Compile Include="Interfaces\ILifecycleManager.cs" />
     <Compile Include="Interfaces\IServerConsoleFacade.cs" />
     <Compile Include="Interfaces\IUserRoleManager.cs" />
Index: /trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs	(revision 925)
+++ /trunk/sources/HeuristicLab.Hive.Contracts/Interfaces/ILifecycleManager.cs	(revision 925)
@@ -0,0 +1,42 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Hive.Contracts.Interfaces {
+  /// <summary>
+  /// Manages the lifecycle of the application
+  /// </summary>
+  public interface ILifecycleManager {
+    /// <summary>
+    /// Initializes the application
+    /// </summary>
+    void Init();
+
+    /// <summary>
+    /// Shuts the application down
+    /// </summary>
+    void Shtudown();
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ClientAdapter.cs	(revision 925)
@@ -26,14 +26,26 @@
 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
 using HeuristicLab.Hive.Contracts.BusinessObjects;
+using System.Linq.Expressions;
+using System.Runtime.CompilerServices;
 
 namespace HeuristicLab.Hive.Server.ADODataAccess {
-  class ClientAdapter: IClientAdapter {
+  class ClientAdapter: DataAdapterBase, IClientAdapter {
     private dsHiveServerTableAdapters.ClientTableAdapter adapter =
         new dsHiveServerTableAdapters.ClientTableAdapter();
 
-    private ResourceAdapter resAdapter = 
-      new ResourceAdapter();
+    private dsHiveServer.ClientDataTable data =
+      new dsHiveServer.ClientDataTable();
+
+    private IResourceAdapter resAdapter =
+      ServiceLocator.GetResourceAdapter();
+
+    public ClientAdapter() {
+      adapter.Fill(data);
+    }
+
+    protected override void Update() {
+      this.adapter.Update(this.data);
+    }
     
-    #region IClientAdapter Members
     private ClientInfo Convert(dsHiveServer.ClientRow row, 
       ClientInfo client) {
@@ -41,5 +53,5 @@
         /*Parent - resource*/
         client.ResourceId = row.ResourceId;
-        resAdapter.FillResource(client);
+        resAdapter.GetResourceById(client);
 
         /*ClientInfo*/
@@ -82,5 +94,4 @@
       dsHiveServer.ClientRow row) {
       if (client != null && row != null) {      
-        row.ResourceId = client.ResourceId;
         row.GUID = client.ClientId;
         row.CPUSpeed = client.CpuSpeedPerCore;
@@ -100,23 +111,20 @@
     }
 
+    #region IClientAdapter Members
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public void UpdateClient(ClientInfo client) {
       if (client != null) {
         resAdapter.UpdateResource(client);
 
-        dsHiveServer.ClientDataTable data =
-          adapter.GetDataById(client.ClientId);
+        dsHiveServer.ClientRow row = 
+          data.FindByResourceId(client.ResourceId);
 
-        dsHiveServer.ClientRow row;
-        if (data.Count == 0) {
+        if (row == null) {
           row = data.NewClientRow();
           row.ResourceId = client.ResourceId;
           data.AddClientRow(row);
-        } else {
-          row = data[0];
-        }
+        } 
 
         Convert(client, row);
-
-        adapter.Update(data);
       }
     }
@@ -124,10 +132,10 @@
     public ClientInfo GetClientById(Guid clientId) {
       ClientInfo client = new ClientInfo();
-      
-      dsHiveServer.ClientDataTable data =
-          adapter.GetDataById(clientId);
-      if (data.Count == 1) {
-        dsHiveServer.ClientRow row = 
-          data[0];
+
+      dsHiveServer.ClientRow row =
+        data.Single<dsHiveServer.ClientRow>(
+          r => !r.IsGUIDNull() && r.GUID == clientId);
+
+      if (row != null) {
         Convert(row, client);
 
@@ -142,7 +150,4 @@
         new List<ClientInfo>();
 
-      dsHiveServer.ClientDataTable data =
-          adapter.GetData();
-
       foreach (dsHiveServer.ClientRow row in data) {
         ClientInfo client = new ClientInfo();
@@ -154,7 +159,19 @@
     }
 
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public bool DeleteClient(ClientInfo client) {
-      //referential integrity will delete the client object
-      return resAdapter.DeleteResource(client);
+      if (client != null) {
+        dsHiveServer.ClientRow row =
+          data.Single<dsHiveServer.ClientRow>(
+            r => r.GUID == client.ClientId);
+
+        if (row != null) {
+          data.RemoveClientRow(row);
+
+          return resAdapter.DeleteResource(client);
+        }
+      }
+
+      return false;
     }
 
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs	(revision 925)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/DataAdapterBase.cs	(revision 925)
@@ -0,0 +1,19 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Hive.Server.ADODataAccess {
+  abstract class DataAdapterBase {
+    protected abstract void Update();
+
+    protected DataAdapterBase() {
+      ServiceLocator.GetTransactionManager().OnUpdate += 
+        new EventHandler(DataAdapterBase_OnUpdate);
+    }
+
+    void DataAdapterBase_OnUpdate(object sender, EventArgs e) {
+      this.Update();
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/HeuristicLab.Hive.Server.ADODataAccess.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/HeuristicLab.Hive.Server.ADODataAccess.csproj	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/HeuristicLab.Hive.Server.ADODataAccess.csproj	(revision 925)
@@ -4,5 +4,5 @@
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{715A9134-B6E4-4CB9-8A5A-E6601497565A}</ProjectGuid>
@@ -66,4 +66,5 @@
     <Compile Include="ClientAdapter.cs" />
     <Compile Include="ClientGroupAdapter.cs" />
+    <Compile Include="DataAdapterBase.cs" />
     <Compile Include="dsHiveServer.cs">
       <DependentUpon>dsHiveServer.xsd</DependentUpon>
@@ -84,4 +85,5 @@
     </Compile>
     <Compile Include="ResourceAdapter.cs" />
+    <Compile Include="TransactionManager.cs" />
     <Compile Include="UserAdapter.cs" />
     <Compile Include="UserGroupAdapter.cs" />
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/PermissionOwnerAdapter.cs	(revision 925)
@@ -27,12 +27,23 @@
 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
 using HeuristicLab.Hive.Contracts.BusinessObjects;
+using System.Runtime.CompilerServices;
 
 namespace HeuristicLab.Hive.Server.ADODataAccess {
-  class PermissionOwnerAdapter: IPermissionOwner {
-    #region IPermissionOwner Members
+  class PermissionOwnerAdapter: DataAdapterBase, IPermissionOwnerAdapter {
     private dsHiveServerTableAdapters.PermissionOwnerTableAdapter adapter =
      new dsHiveServerTableAdapters.PermissionOwnerTableAdapter();
 
-    private PermissionOwner Convert(dsHiveServer.PermissionOwnerRow row, 
+    private dsHiveServer.PermissionOwnerDataTable data =
+      new dsHiveServer.PermissionOwnerDataTable();
+
+    public PermissionOwnerAdapter() {
+      adapter.Fill(data);
+    }
+
+    protected override void Update() {
+      this.adapter.Update(this.data);
+    }
+
+    private PermissionOwner Convert(dsHiveServer.PermissionOwnerRow row,
       PermissionOwner permOwner) {
       if (row != null && permOwner != null) {
@@ -52,5 +63,4 @@
       dsHiveServer.PermissionOwnerRow row) {
       if (row != null && permOwner != null) {
-        row.PermissionOwnerId = permOwner.PermissionOwnerId;
         row.Name = permOwner.Name;
 
@@ -59,33 +69,31 @@
         return null;
     }
-
+    
+    #region IPermissionOwner Members
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public void UpdatePermissionOwner(PermissionOwner permOwner) {
       if (permOwner != null) {
-        dsHiveServer.PermissionOwnerDataTable data =
-          adapter.GetDataById(permOwner.PermissionOwnerId);
-
-        dsHiveServer.PermissionOwnerRow row;
-        if (data.Count == 0) {
+        dsHiveServer.PermissionOwnerRow row = 
+          data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
+        
+        if (row == null) {
           row = data.NewPermissionOwnerRow();
           data.AddPermissionOwnerRow(row);
-        } else {
-          row = data[0];
+
+          //write row to db to get primary key
+          adapter.Update(row);
         }
 
-        row.Name = permOwner.Name;
-
-        adapter.Update(data);
-
+        Convert(permOwner, row);
         permOwner.PermissionOwnerId = row.PermissionOwnerId;
       }
     }
 
-    internal bool FillPermissionOwner(PermissionOwner permOwner) {
+    public bool GetPermissionOwnerById(PermissionOwner permOwner) {
       if (permOwner != null) {
-        dsHiveServer.PermissionOwnerDataTable data =
-          adapter.GetDataById(permOwner.PermissionOwnerId);
-        if (data.Count == 1) {
           dsHiveServer.PermissionOwnerRow row =
-            data[0];
+            data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
+
+        if(row != null) {
           Convert(row, permOwner);
 
@@ -101,5 +109,5 @@
       permOwner.PermissionOwnerId = permOwnerId;
 
-      if (FillPermissionOwner(permOwner))
+      if (GetPermissionOwnerById(permOwner))
         return permOwner;
       else
@@ -107,10 +115,23 @@
     }
 
+    public PermissionOwner GetPermissionOwnerByName(String name) {
+      PermissionOwner permOwner = new PermissionOwner();
+
+      dsHiveServer.PermissionOwnerRow row =
+        data.Single<dsHiveServer.PermissionOwnerRow>(
+          r => !r.IsNameNull() && r.Name == name);
+
+      if (row != null) {
+        Convert(row, permOwner);
+
+        return permOwner;
+      } else {
+        return null;
+      }
+    }
+
     public ICollection<PermissionOwner> GetAllPermissionOwners() {
       ICollection<PermissionOwner> allPermissionOwners =
         new List<PermissionOwner>();
-
-      dsHiveServer.PermissionOwnerDataTable data =
-          adapter.GetData();
 
       foreach (dsHiveServer.PermissionOwnerRow row in data) {
@@ -123,16 +144,16 @@
     }
 
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public bool DeletePermissionOwner(PermissionOwner permOwner) {
       if (permOwner != null) {
-        dsHiveServer.PermissionOwnerDataTable data =
-           adapter.GetDataById(permOwner.PermissionOwnerId);
+          dsHiveServer.PermissionOwnerRow row = 
+            data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
 
-        if (data.Count == 1) {
-          dsHiveServer.PermissionOwnerRow row = data[0];
+          if(row != null) {
+            data.RemovePermissionOwnerRow(row);
 
-          row.Delete();
-          return adapter.Update(data) > 0;
+            return true;
+          }
         }
-      }
 
       return false;
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/ResourceAdapter.cs	(revision 925)
@@ -26,12 +26,23 @@
 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
 using HeuristicLab.Hive.Contracts.BusinessObjects;
+using System.Runtime.CompilerServices;
 
 namespace HeuristicLab.Hive.Server.ADODataAccess {
-  class ResourceAdapter: IResourceAdapter {
-    #region IResourceAdapter Members
+  class ResourceAdapter: DataAdapterBase, IResourceAdapter {
     private dsHiveServerTableAdapters.ResourceTableAdapter adapter =
-      new dsHiveServerTableAdapters.ResourceTableAdapter();
+        new dsHiveServerTableAdapters.ResourceTableAdapter();
 
-    private Resource Convert(dsHiveServer.ResourceRow row, 
+    private dsHiveServer.ResourceDataTable data =
+        new dsHiveServer.ResourceDataTable();
+
+    public ResourceAdapter() {
+      adapter.Fill(data);
+    }
+
+    protected override void Update() {
+      this.adapter.Update(this.data);
+    }
+
+    private Resource Convert(dsHiveServer.ResourceRow row,
       Resource resource) {
       if (row != null && resource != null) {
@@ -43,5 +54,5 @@
 
         return resource;
-      } else 
+      } else
         return null;
     }
@@ -57,32 +68,29 @@
     }
 
+    #region IResourceAdapter Members
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public void UpdateResource(Resource resource) {
       if (resource != null) {
-        dsHiveServer.ResourceDataTable data =
-          adapter.GetDataById(resource.ResourceId);
+        dsHiveServer.ResourceRow row =
+          data.FindByResourceId(resource.ResourceId);
 
-        dsHiveServer.ResourceRow row;
-        if (data.Count == 0) {
+        if (row == null) {
           row = data.NewResourceRow();
           data.AddResourceRow(row);
-        } else {
-          row = data[0];
-        }
+
+          //write row to db to get primary key
+          adapter.Update(row);
+        } 
 
         Convert(resource, row);
-
-        adapter.Update(data);
-
         resource.ResourceId = row.ResourceId;
       }
     }
 
-    internal bool FillResource(Resource resource) {
+    public bool GetResourceById(Resource resource) {
       if (resource != null) {
-        dsHiveServer.ResourceDataTable data =
-          adapter.GetDataById(resource.ResourceId);
-        if (data.Count == 1) {
-          dsHiveServer.ResourceRow row =
-            data[0];
+        dsHiveServer.ResourceRow row =
+          data.FindByResourceId(resource.ResourceId);
+        if (row != null) {
           Convert(row, resource);
 
@@ -98,5 +106,5 @@
       resource.ResourceId = resourceId;
 
-      if(FillResource(resource)) 
+      if(GetResourceById(resource)) 
         return resource;
       else 
@@ -105,10 +113,7 @@
 
     public ICollection<Resource> GetAllResources() {
-      ICollection<Resource> allResources =
+      IList<Resource> allResources =
         new List<Resource>();
-
-      dsHiveServer.ResourceDataTable data =
-          adapter.GetData();
-
+      
       foreach (dsHiveServer.ResourceRow row in data) {
         Resource resource = new Resource();
@@ -120,15 +125,14 @@
     }
 
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public bool DeleteResource(Resource resource) {
       if(resource != null) {
+        dsHiveServer.ResourceRow row =
+          data.FindByResourceId(resource.ResourceId);
 
-        dsHiveServer.ResourceDataTable data =
-           adapter.GetDataById(resource.ResourceId);
+        if (row != null) {
+          data.RemoveResourceRow(row);
 
-        if (data.Count == 1) {
-          dsHiveServer.ResourceRow row = data[0];
-
-          row.Delete();
-          return adapter.Update(data) > 0;
+          return true;
         } 
       }
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/TransactionManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/TransactionManager.cs	(revision 925)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/TransactionManager.cs	(revision 925)
@@ -0,0 +1,58 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
+using System.Timers;
+
+namespace HeuristicLab.Hive.Server.ADODataAccess {
+  class TransactionManager: ITransactionManager {
+    private Timer timer =
+      new Timer();
+
+    void timer_Elapsed(object sender, ElapsedEventArgs e) {
+      UpdateDB();
+    }
+
+    #region ITransactionManager Members
+    public event EventHandler OnUpdate;
+
+    public void EnableAutoUpdate(TimeSpan interval) {
+      timer.Interval = interval.TotalMilliseconds;
+      timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
+      timer.Start();
+    }
+
+    public void DisableAutoUpdate() {
+      timer.Stop();
+    }
+
+    public void UpdateDB() {
+      if (OnUpdate != null)
+        OnUpdate(this, null);
+    }
+
+    #endregion
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/UserAdapter.cs	(revision 925)
@@ -27,12 +27,24 @@
 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
 using HeuristicLab.Hive.Contracts.BusinessObjects;
+using System.Runtime.CompilerServices;
 
 namespace HeuristicLab.Hive.Server.ADODataAccess {
-  class UserAdapter: IUserAdapter {
+  class UserAdapter : DataAdapterBase, IUserAdapter {
     private dsHiveServerTableAdapters.HiveUserTableAdapter adapter =
         new dsHiveServerTableAdapters.HiveUserTableAdapter();
 
-    private PermissionOwnerAdapter permOwnerAdapter =
-      new PermissionOwnerAdapter();
+    private dsHiveServer.HiveUserDataTable data =
+        new dsHiveServer.HiveUserDataTable();
+
+    private IPermissionOwnerAdapter permOwnerAdapter =
+       ServiceLocator.GetPermissionOwnerAdapter();
+
+    public UserAdapter() {
+      adapter.Fill(data);
+    }
+
+    protected override void Update() {
+      this.adapter.Update(this.data);
+    }
 
     private User Convert(dsHiveServer.HiveUserRow row, 
@@ -41,5 +53,5 @@
         /*Parent - PermissionOwner*/
         user.PermissionOwnerId = row.PermissionOwnerId;
-        permOwnerAdapter.FillPermissionOwner(user);
+        permOwnerAdapter.GetPermissionOwnerById(user);
 
         /*User*/
@@ -57,5 +69,4 @@
       dsHiveServer.HiveUserRow row) {
       if (user != null && row != null) {
-        row.PermissionOwnerId = user.PermissionOwnerId;
         row.Password = user.Password;
 
@@ -67,23 +78,18 @@
     #region IUserAdapter Members
 
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public void UpdateUser(User user) {
       if (user != null) {
         permOwnerAdapter.UpdatePermissionOwner(user);
 
-        dsHiveServer.HiveUserDataTable data =
-          adapter.GetDataById(user.PermissionOwnerId);
-
-        dsHiveServer.HiveUserRow row;
-        if (data.Count == 0) {
+        dsHiveServer.HiveUserRow row = 
+          data.FindByPermissionOwnerId(user.PermissionOwnerId);
+        if (row == null) {
           row = data.NewHiveUserRow();
           row.PermissionOwnerId = user.PermissionOwnerId;
           data.AddHiveUserRow(row);
-        } else {
-          row = data[0];
-        }
+        } 
 
         Convert(user, row);
-
-        adapter.Update(data);
       }
     }
@@ -92,9 +98,8 @@
       User user = new User();
 
-      dsHiveServer.HiveUserDataTable data =
-          adapter.GetDataById(userId);
-      if (data.Count == 1) {
-        dsHiveServer.HiveUserRow row =
-          data[0];
+      dsHiveServer.HiveUserRow row =
+          data.FindByPermissionOwnerId(userId);
+
+      if(row != null) {
         Convert(row, user);
 
@@ -108,15 +113,19 @@
       User user = new User();
 
-      dsHiveServer.HiveUserDataTable data =
-          adapter.GetDataByName(name);
-      if (data.Count == 1) {
+      PermissionOwner permOwner =
+        permOwnerAdapter.GetPermissionOwnerByName(name);
+
+      if (permOwner != null) {
         dsHiveServer.HiveUserRow row =
-          data[0];
-        Convert(row, user);
+          data.FindByPermissionOwnerId(permOwner.PermissionOwnerId);
 
-        return user;
-      } else {
-        return null;
+        if (row != null) {
+          Convert(row, user);
+
+          return user;
+        }
       }
+
+      return null;
     }
 
@@ -124,7 +133,4 @@
       ICollection<User> allUsers =
         new List<User>();
-
-      dsHiveServer.HiveUserDataTable data =
-          adapter.GetData();
 
       foreach (dsHiveServer.HiveUserRow row in data) {
@@ -137,7 +143,18 @@
     }
 
+    [MethodImpl(MethodImplOptions.Synchronized)]
     public bool DeleteUser(User user) {
-      //referential integrity will delete the client object
-      return permOwnerAdapter.DeletePermissionOwner(user);
+      if (user != null) {
+        dsHiveServer.HiveUserRow row =
+          data.FindByPermissionOwnerId(user.PermissionOwnerId);
+
+        if (row != null) {
+          data.RemoveHiveUserRow(row);
+
+          return permOwnerAdapter.DeletePermissionOwner(user);
+        }
+      }
+
+      return false;
     }
 
Index: /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/dsHiveServer.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/dsHiveServer.Designer.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.ADODataAccess/dsHiveServer.Designer.cs	(revision 925)
@@ -2,5 +2,5 @@
 // <auto-generated>
 //     This code was generated by a tool.
-//     Runtime Version:2.0.50727.3053
+//     Runtime Version:2.0.50727.1433
 //
 //     Changes to this file may cause incorrect behavior and will be lost if
@@ -3628,4 +3628,14 @@
             }
             set {
+                if (((this._resourceTableAdapter != null) 
+                            && (this.TableAdapterInstanceCount == 1))) {
+                    this._resourceTableAdapter = value;
+                    return;
+                }
+                if (((value != null) 
+                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
+                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
+                            "tring.");
+                }
                 this._resourceTableAdapter = value;
             }
@@ -3641,4 +3651,14 @@
             }
             set {
+                if (((this._clientTableAdapter != null) 
+                            && (this.TableAdapterInstanceCount == 1))) {
+                    this._clientTableAdapter = value;
+                    return;
+                }
+                if (((value != null) 
+                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
+                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
+                            "tring.");
+                }
                 this._clientTableAdapter = value;
             }
@@ -3654,4 +3674,14 @@
             }
             set {
+                if (((this._hiveUserTableAdapter != null) 
+                            && (this.TableAdapterInstanceCount == 1))) {
+                    this._hiveUserTableAdapter = value;
+                    return;
+                }
+                if (((value != null) 
+                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
+                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
+                            "tring.");
+                }
                 this._hiveUserTableAdapter = value;
             }
@@ -3667,4 +3697,14 @@
             }
             set {
+                if (((this._permissionOwnerTableAdapter != null) 
+                            && (this.TableAdapterInstanceCount == 1))) {
+                    this._permissionOwnerTableAdapter = value;
+                    return;
+                }
+                if (((value != null) 
+                            && (this.MatchTableAdapterConnection(value.Connection) == false))) {
+                    throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
+                            "tring.");
+                }
                 this._permissionOwnerTableAdapter = value;
             }
@@ -3893,24 +3933,4 @@
                 return 0;
             }
-            if (((this._resourceTableAdapter != null) 
-                        && (this.MatchTableAdapterConnection(this._resourceTableAdapter.Connection) == false))) {
-                throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
-                        "tring.");
-            }
-            if (((this._clientTableAdapter != null) 
-                        && (this.MatchTableAdapterConnection(this._clientTableAdapter.Connection) == false))) {
-                throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
-                        "tring.");
-            }
-            if (((this._hiveUserTableAdapter != null) 
-                        && (this.MatchTableAdapterConnection(this._hiveUserTableAdapter.Connection) == false))) {
-                throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
-                        "tring.");
-            }
-            if (((this._permissionOwnerTableAdapter != null) 
-                        && (this.MatchTableAdapterConnection(this._permissionOwnerTableAdapter.Connection) == false))) {
-                throw new global::System.ArgumentException("All TableAdapters managed by a TableAdapterManager must use the same connection s" +
-                        "tring.");
-            }
             global::System.Data.IDbConnection workConnection = this.Connection;
             if ((workConnection == null)) {
@@ -3919,9 +3939,6 @@
             }
             bool workConnOpened = false;
-            if (((workConnection.State & global::System.Data.ConnectionState.Broken) 
-                        == global::System.Data.ConnectionState.Broken)) {
-                workConnection.Close();
-            }
-            if ((workConnection.State == global::System.Data.ConnectionState.Closed)) {
+            if (((workConnection.State & global::System.Data.ConnectionState.Closed) 
+                        == global::System.Data.ConnectionState.Closed)) {
                 workConnection.Open();
                 workConnOpened = true;
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/DbTestApp.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/DbTestApp.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/DbTestApp.cs	(revision 925)
@@ -105,4 +105,9 @@
       TestClientAdapter();
       TestUserAdapter();
+
+      ITransactionManager transactionManager =
+        ServiceLocator.GetTransactionManager();
+
+      transactionManager.UpdateDB();
     }
   }
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/HeuristicLab.Hive.Server.Core.csproj	(revision 925)
@@ -4,5 +4,5 @@
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.30729</ProductVersion>
+    <ProductVersion>9.0.21022</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{898B31CF-81DC-453B-AEB3-BDF83197A7EE}</ProjectGuid>
@@ -75,7 +75,9 @@
     <Compile Include="InternalInterfaces\DataAccess\IPermissionOwnerAdapter.cs" />
     <Compile Include="InternalInterfaces\DataAccess\IResourceAdapter.cs" />
+    <Compile Include="InternalInterfaces\DataAccess\ITransactionManager.cs" />
     <Compile Include="InternalInterfaces\DataAccess\IUserAdapter.cs" />
     <Compile Include="InternalInterfaces\DataAccess\IUserGroupAdapter.cs" />
     <Compile Include="JobManager.cs" />
+    <Compile Include="LifecycleManager.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="ServerConsoleFacade.cs" />
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IPermissionOwnerAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IPermissionOwnerAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IPermissionOwnerAdapter.cs	(revision 925)
@@ -30,5 +30,5 @@
   /// The permission owner database adapter
   /// </summary>
-  public interface IPermissionOwner {
+  public interface IPermissionOwnerAdapter {
     /// <summary>
     /// Save or update the permission owner
@@ -38,4 +38,11 @@
 
     /// <summary>
+    /// Gets the permission owner and updates the values of the object
+    /// </summary>
+    /// <param name="resource"></param>
+    /// <returns></returns>
+    bool GetPermissionOwnerById(PermissionOwner permOwner);
+
+    /// <summary>
     /// Get the permission owner with the specified ID
     /// </summary>
@@ -43,4 +50,11 @@
     /// <returns></returns>
     PermissionOwner GetPermissionOwnerById(long permOwnerId);
+
+    /// <summary>
+    /// Get the permission owner with the specified name
+    /// </summary>
+    /// <param name="clientId"></param>
+    /// <returns></returns>
+    PermissionOwner GetPermissionOwnerByName(String name);
 
     /// <summary>
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IResourceAdapter.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IResourceAdapter.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/IResourceAdapter.cs	(revision 925)
@@ -45,4 +45,11 @@
 
     /// <summary>
+    /// Gets the resource and updates the values of the object
+    /// </summary>
+    /// <param name="resource"></param>
+    /// <returns></returns>
+    bool GetResourceById(Resource resource);
+
+    /// <summary>
     /// Get all resuorces
     /// </summary>
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/ITransactionManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/ITransactionManager.cs	(revision 925)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/InternalInterfaces/DataAccess/ITransactionManager.cs	(revision 925)
@@ -0,0 +1,32 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess {
+  /// <summary>
+  /// Transaction manager for the DB access layer
+  /// </summary>
+  public interface ITransactionManager {
+    /// <summary>
+    /// This event is fired when an update occurs
+    /// </summary>
+    event EventHandler OnUpdate; 
+
+    /// <summary>
+    /// Enables the auto update of the DB
+    /// </summary>
+    /// <param name="interval"></param>
+    void EnableAutoUpdate(TimeSpan interval);
+
+    /// <summary>
+    /// Disables the auto update of the DB
+    /// </summary>
+    void DisableAutoUpdate();
+
+    /// <summary>
+    /// Update the DB from the cache
+    /// </summary>
+    void UpdateDB();
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs	(revision 925)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/LifecycleManager.cs	(revision 925)
@@ -0,0 +1,42 @@
+﻿#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 <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using HeuristicLab.Hive.Contracts.Interfaces;
+
+namespace HeuristicLab.Hive.Server.Core {
+  class LifecycleManager: ILifecycleManager {
+    #region ILifecycleManager Members
+
+    public void Init() {
+      //nothing to do
+    }
+
+    public void Shtudown() {
+      ServiceLocator.GetTransactionManager().UpdateDB();
+    }
+
+    #endregion
+  }
+}
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/ServerConsoleFacade.cs	(revision 925)
@@ -94,14 +94,4 @@
     #endregion
 
-
-    #region IServerConsoleFacade Members
-
-    public Response Login(string userName, string password) {
-      Response response = new Response();
-      response.Success = true;
-      return response;
-    }
-
-    #endregion
   }
 }
Index: /trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server.Core/ServiceLocator.cs	(revision 925)
@@ -22,11 +22,14 @@
 using HeuristicLab.Hive.Server.Core.InternalInterfaces.DataAccess;
 using HeuristicLab.PluginInfrastructure;
+using System.Runtime.CompilerServices;
 
 /// <summary>
 /// The service locator for the server core
 /// </summary>
-class ServiceLocator {
+public class ServiceLocator {
   private static DiscoveryService discoveryService =
     new DiscoveryService();
+
+  private static ITransactionManager transManager = null;
 
   private static IClientAdapter clientAdapter = null;
@@ -34,13 +37,31 @@
   private static IClientGroupAdapter clientGroupAdapter = null;
 
+  private static IResourceAdapter resourceAdapter = null;
+
   private static IUserAdapter userAdapter = null;
 
   private static IUserGroupAdapter userGroupAdapter = null;
-  
+
+  private static IPermissionOwnerAdapter permOwnerAdapter = null;
+
+  /// <summary>
+  /// Gets the db transaction manager
+  /// </summary>
+  /// <returns></returns>
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static ITransactionManager GetTransactionManager() {
+    if (transManager == null) {
+      transManager = discoveryService.GetInstances<ITransactionManager>()[0];
+    }
+
+    return transManager;
+  }
+
   /// <summary>
   /// Gets the client database adapter
   /// </summary>
   /// <returns></returns>
-  internal static IClientAdapter GetClientAdapter() {
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IClientAdapter GetClientAdapter() {
     if (clientAdapter == null) {
       clientAdapter = discoveryService.GetInstances<IClientAdapter>()[0];
@@ -54,5 +75,6 @@
   /// </summary>
   /// <returns></returns>
-  internal static IClientGroupAdapter GetClientGroupAdapter() {
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IClientGroupAdapter GetClientGroupAdapter() {
     if (clientGroupAdapter == null) {
       clientGroupAdapter = discoveryService.GetInstances<IClientGroupAdapter>()[0];
@@ -63,8 +85,22 @@
 
   /// <summary>
+  /// Gets the resource database adapter
+  /// </summary>
+  /// <returns></returns>
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IResourceAdapter GetResourceAdapter() {
+    if (resourceAdapter == null) {
+      resourceAdapter = discoveryService.GetInstances<IResourceAdapter>()[0];
+    }
+
+    return resourceAdapter;
+  }
+
+  /// <summary>
   /// Gets the user database adapter
   /// </summary>
   /// <returns></returns>
-  internal static IUserAdapter GetUserAdapter() {
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IUserAdapter GetUserAdapter() {
     if (userAdapter == null) {
       userAdapter = discoveryService.GetInstances<IUserAdapter>()[0];
@@ -78,5 +114,6 @@
   /// </summary>
   /// <returns></returns>
-  internal static IUserGroupAdapter GetUserGroupAdapter() {
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IUserGroupAdapter GetUserGroupAdapter() {
     if (userGroupAdapter == null) {
       userGroupAdapter = discoveryService.GetInstances<IUserGroupAdapter>()[0];
@@ -85,3 +122,16 @@
     return userGroupAdapter;
   }
+
+  /// <summary>
+  /// Gets the permission owner database adapter
+  /// </summary>
+  /// <returns></returns>
+  [MethodImpl(MethodImplOptions.Synchronized)]
+  public static IPermissionOwnerAdapter GetPermissionOwnerAdapter() {
+    if (permOwnerAdapter == null) {
+      permOwnerAdapter = discoveryService.GetInstances<IPermissionOwnerAdapter>()[0];
+    }
+
+    return permOwnerAdapter;
+  }
 }
Index: /trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs
===================================================================
--- /trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs	(revision 924)
+++ /trunk/sources/HeuristicLab.Hive.Server/HiveServerApplication.cs	(revision 925)
@@ -88,5 +88,5 @@
       if (serverConsoleInstances.Length > 0) {
         ServiceHost serviceHost =
-                new ServiceHost(serverConsoleInstances[0].GetType(),
+            new ServiceHost(serverConsoleInstances[0].GetType(),
                   uriTcp);
 
@@ -139,11 +139,25 @@
         StartServerConsoleFacade(uriTcp);
 
-      Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
-        serverConsoleFacade.BaseAddresses[0]);
+      ILifecycleManager[] lifecycleManagers =
+         discService.GetInstances<ILifecycleManager>();
 
-      Application.Run(mainForm);
+      if (lifecycleManagers.Length > 0) {
+        ILifecycleManager lifecycleManager = 
+          lifecycleManagers[0];
+
+        lifecycleManager.Init();
+
+        Form mainForm = new MainForm(clientCommunicator.BaseAddresses[0],
+            serverConsoleFacade.BaseAddresses[0]);
+
+         Application.Run(mainForm);
+
+         lifecycleManager.Shtudown();
+      }
 
       clientCommunicator.Close();
       serverConsoleFacade.Close();
+
+      
     }
   }
