Unity in DevDash

I got a comment asking if I’ve used Unity. Oh yes. I do.

IServiceLocator, which is an abstraction of IOC so that you can use any container you want with a common interface, is the heart of DevDash. Each node, and the hub, is an instance of an application server. The application server is populated by unity. Unity may provide to the app server startup tasks, shutdown tasks, scheduled tasks, services, and the event-driven bus. If you want to add any functionality to DevDash, you can do so by implementing a task or a service and plugging it in to the container.

It provides two standard configurations: StandardNode and StandardHub. Each requires a different set of required settings for basic configuration information, but the unity containers are wired up and ready to go automatically. If you want to tweak it, you can do so in initialization code, or you can change it to use the configuration file rather than code. There is a lot of configuration, so I will provide the StandardNode and StandardHub configuraton as well.

Here is the configuration section:

image

If you are driving from configuration 100%, then you need to specify the MODE attribute. That tells it whether to start the standard node, standard hub, or whatever is specified in the unity container called “whatever”.

If you do it via code:

host = Host.CreateStandardHub();

host = Host.CreateStandardNode();

Then it ignores the MODE attribute and just goes to the appropriate section.

I will also reveal the methods that construct the container… just have to juggle a little bit of code. Then, you can get the standard hub or node as a container, modify it or add to it, then pass it to the host when you’re ready to go.

So, you have options. You can either use it out of the box, you can start from scratch, or anything in between.

The windows service that hosts the hub and node is based on the configuration section and the MODE attribute. If you want to change the container, then you’ll have to switch the mode to UNITY and modify the xml.

Here is the unity populate code that fires up the hub and node:

image

image

You may notice a couple extension methods in there. I plan to add more to simplify the process of populating the container via code. You’ll see that I started at the top of the registration list, then quickly got bored.

Also, the Wcf services are constructed by unity. There is a custom service host (per an earlier blog post) that swaps out the Wcf instance provider with an IServiceLocator aware instance provider. The IServiceLocator is stored as a property of a subclass of the service host.

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: