The Bitter Coder Tutorials, Binsor Style: XIV Startable Facilities
Previous posts in the series:
facility “logging.facility”,LoggingFacility: loggingApi=LoggerImplementation.Console
component “lame.http”, LameHttpServer: prefix=“http://*:8089/” path=“lame.html” So, we register the facilities discussed earlier. BTW, in order to resolve the facilities, I had to add the following to the top of Windsor.boo, in the import section:
Also, I added a reference to the Castle.Facilites.Logging assembly. I already had a reference for Castle.MicroKernel from a previous post.
Let’s look at our console code to crank up the server:
Client: requesting http://localhost:8089/… Client: success, content follows.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0 Transitional//EN”> <html> <head> <title></title> </head> <body> <h1>Lame.html</h1> <h2>Welcome to lame.html file</h2> <p>This is the contents of the lame.html file, neat huh?</p> </body> </html> [Debug] ‘BitterCoder.Tutorials.Binsor.Core.LameHttpServer’ Stopping LameWebService… [Info] ‘BitterCoder.Tutorials.Binsor.Core.LameHttpServer’ LameWebService stopped.
Client: requesting http://localhost:8089/… Client: Exception occurred, message Unable to connect to the remote server The error at the end of the results is due to us disposing of the container, which decommisions all the components in the container. Alex explains this well…so read what he said.
So, I am gonna modify Alex’s final example where he demonstrates lifestyles and their effect on Startable facilities. The only difference, really, is I am going to show you what the Binsor looks like to control the lifestyle of a component.
Here’s our StartableExperiment:
Running the following program code:
Started #1 Started #2 Stopped #2 Started #3 Stopped #3 Stopped #1
If I change the @lifestyle attribute in the Binsor to LifestyleType.Singleton, I get:
Started #1 Stopped #1
And that’s Startable Facilities and their lifestyles, from a Binsor point-of-view.
So, I hope someone enjoyed the series. Thanks again to Alex for his tutorials. They were a big rung in my learning ladder for Windsor.
I created a VS.NET project with all the code from this series. If you’re interested, hit me at glenn(dot)goodrich(at)gmail.com.