Free cookie consent management tool by TermsFeed Policy Generator

Changeset 882 for trunk


Ignore:
Timestamp:
12/01/08 14:42:57 (16 years ago)
Author:
kgrading
Message:

moved the appdomain creator (#410)

Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Communication/ServiceLocator.cs

    r840 r882  
    1313        proxy = new ClientCommunicatorClient(
    1414          new NetTcpBinding(),
    15           new EndpointAddress("net.tcp://10.20.53.3:9000/HiveServer/ClientCommunicator")
     15          new EndpointAddress("net.tcp://192.168.132.1:9000/HiveServer/ClientCommunicator")
    1616          );
    1717      }
  • trunk/sources/HeuristicLab.Hive.Client.Core/Core.cs

    r843 r882  
    5050    Dictionary<long, AppDomain> appDomains = new Dictionary<long, AppDomain>();
    5151
    52     public static StrongName CreateStrongName(Assembly assembly) {
    53       if (assembly == null)
    54         throw new ArgumentNullException("assembly");
    55 
    56       AssemblyName assemblyName = assembly.GetName();
    57       Debug.Assert(assemblyName != null, "Could not get assembly name");
    58 
    59       // get the public key blob
    60       byte[] publicKey = assemblyName.GetPublicKey();
    61       if (publicKey == null || publicKey.Length == 0)
    62         throw new InvalidOperationException("Assembly is not strongly named");
    63 
    64       StrongNamePublicKeyBlob keyBlob = new StrongNamePublicKeyBlob(publicKey);
    65 
    66       // and create the StrongName
    67       return new StrongName(keyBlob, assemblyName.Name, assemblyName.Version);
    68     }
    69 
    7052    private ClientCommunicatorClient clientCommunicator;
    7153
    7254    public void Start() {
    73        DiscoveryService discService =
     55       /*DiscoveryService discService =
    7456        new DiscoveryService();
    7557      IClientConsoleCommunicator[] clientCommunicatorInstances =
     
    9981
    10082        serviceHost.Open();
    101       }
     83      }*/
    10284
    10385      clientCommunicator = ServiceLocator.GetClientCommunicator();
     
    10587      clientCommunicator.PullJobCompleted += new EventHandler<PullJobCompletedEventArgs>(ClientCommunicator_PullJobCompleted);
    10688      clientCommunicator.SendJobResultCompleted += new EventHandler<SendJobResultCompletedEventArgs>(ClientCommunicator_SendJobResultCompleted);
    107       clientCommunicator.LoginAsync(ConfigurationManager.GetInstance().GetClientInfo());
     89      //clientCommunicator.LoginAsync(ConfigurationManager.GetInstance().GetClientInfo());
    10890
    10991      Heartbeat beat = new Heartbeat { Interval = 5000 };
     
    127109      } else
    128110        Logging.GetInstance().Error(this.ToString(), e.Result.StatusMessage);
    129     }
    130 
    131     private AppDomain CreateNewAppDomain(bool sandboxed) {
    132       PermissionSet pset;
    133       if (sandboxed) {
    134         pset = new PermissionSet(PermissionState.None);
    135         pset.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));
    136       } else {
    137         pset = new PermissionSet(PermissionState.Unrestricted);
    138       }
    139       AppDomainSetup setup = new AppDomainSetup();
    140       setup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
    141       //Temp Fix!
    142       setup.PrivateBinPath = "plugins";
    143       return System.AppDomain.CreateDomain("appD", AppDomain.CurrentDomain.Evidence, setup, pset, CreateStrongName(Assembly.GetExecutingAssembly()));
    144 
    145111    }
    146112
     
    188154      bool sandboxed = false;
    189155
    190       //IJob job = new TestJob { JobId = e.Result.JobId };
    191 
    192       PluginManager pm = PluginManager.Manager;
    193       AppDomain appDomain =  pm.CreateAndInitAppDomain("AppDomain");
    194 
    195       //AppDomain appDomain = CreateNewAppDomain(sandboxed);
     156      AppDomain appDomain =  PluginManager.Manager.CreateAndInitAppDomainWithSandbox(e.Result.JobId.ToString(), sandboxed);
     157     
    196158      appDomains.Add(e.Result.JobId, appDomain);
    197159
  • trunk/sources/HeuristicLab.Hive.Client.Core/Properties/AssemblyInfo.frame

    r714 r882  
    2323using System.Runtime.CompilerServices;
    2424using System.Runtime.InteropServices;
     25using System.Security;
    2526using HeuristicLab.PluginInfrastructure;
    2627
     
    3637[assembly: AssemblyTrademark("")]
    3738[assembly: AssemblyCulture("")]
     39[assembly: AllowPartiallyTrustedCallers]
    3840
    3941// Setting ComVisible to false makes the types in this assembly not visible
  • trunk/sources/HeuristicLab.PluginInfrastructure/PluginManager.cs

    r766 r882  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Security.Policy;
     25using System.Reflection;
     26using System.Diagnostics;
     27using System.Security.Permissions;
     28using System.Security;
    2429
    2530namespace HeuristicLab.PluginInfrastructure {
     
    132137    }
    133138
     139    /// <summary>
     140    /// Creates a new AppDomain with all plugins preloaded and Sandboxing capability
     141    /// </summary>
     142    /// <param name="assembly">Assembly reference</param>
     143    /// <returns>the strongname of the assembly</returns>
     144    private StrongName CreateStrongName(Assembly assembly) {
     145      if (assembly == null)
     146        throw new ArgumentNullException("assembly");
     147
     148      AssemblyName assemblyName = assembly.GetName();
     149      Debug.Assert(assemblyName != null, "Could not get assembly name");
     150
     151      // get the public key blob
     152      byte[] publicKey = assemblyName.GetPublicKey();
     153      if (publicKey == null || publicKey.Length == 0)
     154        throw new InvalidOperationException("Assembly is not strongly named");
     155
     156      StrongNamePublicKeyBlob keyBlob = new StrongNamePublicKeyBlob(publicKey);
     157
     158      // and create the StrongName
     159      return new StrongName(keyBlob, assemblyName.Name, assemblyName.Version);
     160    }
     161
     162    public AppDomain CreateAndInitAppDomainWithSandbox(string friendlyName, bool sandboxed) {
     163
     164      PermissionSet pset;
     165      if (sandboxed) {
     166        pset = new PermissionSet(PermissionState.None);
     167        pset.AddPermission(new SecurityPermission(SecurityPermissionFlag.Execution));       
     168      } else {
     169        pset = new PermissionSet(PermissionState.Unrestricted);
     170      }
     171      AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
     172      setup.PrivateBinPath = pluginDir;
     173      setup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;     
     174      AppDomain applicationDomain = AppDomain.CreateDomain(friendlyName, AppDomain.CurrentDomain.Evidence, setup, pset, CreateStrongName(Assembly.GetExecutingAssembly()));
     175                     
     176      Runner remoteRunner = (Runner)applicationDomain.CreateInstanceAndUnwrap(typeof(Runner).Assembly.GetName().Name, typeof(Runner).FullName);
     177      NotifyListeners(PluginManagerAction.Initializing, "All plugins");
     178      if (remoteLoader != null) {
     179        remoteRunner.LoadPlugins(remoteLoader.ActivePlugins);
     180      } else if (LoadedPlugins != null && LoadedPlugins.Count > 0) {
     181        remoteRunner.LoadPlugins(LoadedPlugins);
     182      }
     183      NotifyListeners(PluginManagerAction.Initialized, "All plugins");
     184      return applicationDomain;
     185    }
    134186
    135187    /// <summary>
Note: See TracChangeset for help on using the changeset viewer.