Creating and Starting an Application Server

The app server gets everything it needs from an IOC container. The IOC container is configured via extension methods, and may also be tweaked manually if necessary.

I have a console app that I use to host a hub and two nodes. This is my primary tool for testing. The console application itself isn’t important, so disregard the use of static fields, etc.

image

  • new UnityContainer() – I choose unity. Theoretically, you can use any container you want by writing an IDependencyResolver adapter for it. But, that is untested.’’
  • ToDependencyResolver() – that’s the unity adapter of IDependencyResolver
  • AsHub/AsNode – sets up the container with all of the default stuff it needs for each role. For a node, you pass it the server id object. For hub, it will create one on it’s own as the name is known to be HUB.
  • CreateServer – instantiates a server. This is very simple. It’s just new Server(serverId)
  • Start – an awaitable method that starts the server
  • Result – the server

AsHub/AsNode can be combined with CreateServer to do both steps at once. But, then you’d lose tweaking capabilities. Once you initialize it AsNode, you can then change whatever you want in the container before creating the server.

I will likely add a method such as CreateNodeServer() that combines both steps if you don’t require further configuration.

There are two other methods:

  • AsApplication – this is used for the applications hosted within the application server. This is done by the BRIDGE that links the app server to the applications.
  • AsStandAlone – with this configuration, it doesn’t use a hub. It gets it’s configuration, etc, locally. This worked when I wrote it, but i haven’t used it in several months.
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: