Skip to content

Commit

Permalink
The host now actually uses the /BootStrapper argument if specified
Browse files Browse the repository at this point in the history
  • Loading branch information
mattburton committed Jan 31, 2012
1 parent c4a3d43 commit cafe675
Showing 1 changed file with 91 additions and 47 deletions.
138 changes: 91 additions & 47 deletions Rhino.ServiceBus.Host/RhinoServiceBusHost.cs
Original file line number Diff line number Diff line change
@@ -1,55 +1,99 @@

using System;
using System.IO;
using System.Reflection;

namespace Rhino.ServiceBus.Host
{
using System.ServiceProcess;
using Hosting;

internal partial class RhinoServiceBusHost : ServiceBase
{
private RemoteAppDomainHost host;
private string asm;
private string cfg;
private string hostType;

public RhinoServiceBusHost()
{
InitializeComponent();
}

public void SetArguments(ExecutingOptions options)
{
asm = options.Assembly;
cfg = options.ConfigFile;
hostType = options.Host;
}

protected override void OnStart(string[] ignored)
{
host = new RemoteAppDomainHost(asm, cfg);

This comment has been minimized.

Copy link
@ketiko

ketiko Jun 8, 2012

Contributor

This commit removed setting the host variable. I have a pull request for this in commit bdbaf8a

using System.ServiceProcess;
using Hosting;

internal partial class RhinoServiceBusHost : ServiceBase
{
private RemoteAppDomainHost host;
private string asm;
private string cfg;
private string bootStrapper;
private string hostType;

public RhinoServiceBusHost()
{
InitializeComponent();
}

public void SetArguments(ExecutingOptions options)
{
asm = options.Assembly;
cfg = options.ConfigFile;
bootStrapper = options.BootStrapper;
hostType = options.Host;
}

protected override void OnStart(string[] ignored)
{
RemoteAppDomainHost remoteAppDomainHost;

if (string.IsNullOrEmpty(bootStrapper) == false)
{
var assembly = LoadAssembly();
var bootStrapperType = LoadBootStrapperType(assembly);
remoteAppDomainHost = new RemoteAppDomainHost(bootStrapperType);
remoteAppDomainHost.Configuration(cfg);
}
else
{
remoteAppDomainHost = new RemoteAppDomainHost(asm, cfg);
}

if (string.IsNullOrEmpty(hostType) == false)
host.SetHostType(hostType);
host.Start();
}

protected override void OnStop()
{
if (host != null)
host.Close();
}

public void DebugStart(string[] arguments)
{
OnStart(arguments);
}

public void InitialDeployment(string user)
{
var tmpHost = new RemoteAppDomainHost(asm, cfg);
tmpHost.InitialDeployment(user);
{
remoteAppDomainHost.SetHostType(hostType);
}

remoteAppDomainHost.Start();
}

private Assembly LoadAssembly()
{
try
{
return Assembly.LoadFrom(asm);
}
catch (FileNotFoundException)
{
throw new InvalidOperationException("The specified assembly file was not found: " + asm);
}
}

private Type LoadBootStrapperType(Assembly assembly)
{
var type = assembly.GetType(bootStrapper);

if (type == null)
{
throw new InvalidOperationException("Unable to load the specified bootstrapper type: " + bootStrapper);
}

return type;
}

protected override void OnStop()
{
if (host != null)
host.Close();
}

public void DebugStart(string[] arguments)
{
OnStart(arguments);
}

public void InitialDeployment(string user)
{
var tmpHost = new RemoteAppDomainHost(asm, cfg);
tmpHost.InitialDeployment(user);
tmpHost.Close();
}
}

}
}
}

0 comments on commit cafe675

Please sign in to comment.