-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The host now actually uses the /BootStrapper argument if specified
- Loading branch information
1 parent
c4a3d43
commit cafe675
Showing
1 changed file
with
91 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
Sorry, something went wrong. |
||
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(); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This commit removed setting the host variable. I have a pull request for this in commit bdbaf8a