[mvccontrib-discuss] Portable Area Dependencies

17 views
Skip to first unread message

ben

unread,
May 17, 2010, 11:50:16 AM5/17/10
to mvccontrib-discuss
Hi,

Am loving the Portable Area functionality in the MvcContrib project. I
would like to lose the dependency that my main web app (entry point)
has to have on the portable area project, so have a few questions.

1. How can I change InputBuilder.BootStrap() so that it loads
additional assemblies that are not referenced by the project (for
example, using StructureMap's assembly scanning features).

2. In cases where I need to communicate over the message bus I would
move the message objects and handlers to a separate class library
project. The portable area application would reference the adapter
project so it knows about the message formats. I would then aim to
scan the adapter assembly (using StructureMap) from the main web
application and instantiate all instances of IMessageHandler.

Is this a good approach? Doing this would mean that I only ever have
to reference the one adapter assembly from the web application and
that deploying a new feature (portable area) would be a case of
dropping in the relevant dll and an updated adapter - without needing
to dive into Visual Studio and recompile.

Thanks.
Ben

--
Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project. Or go to http://mvccontrib.org

To unsubscribe from this group, send email to mvccontrib-disc...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/mvccontrib-discuss?hl=en

Eric Hexter

unread,
May 17, 2010, 12:47:31 PM5/17/10
to mvccontri...@googlegroups.com

You do not need to reference the pa for it to load.  This is the default behavior of the mvc2

sent from my mobile phone

ben

unread,
May 18, 2010, 4:16:01 AM5/18/10
to mvccontrib-discuss
Great Eric, thanks for your reply. Have just tested and yes it's
working without adding the reference.

What are your thoughts regarding my second point?

Thanks
Ben

On May 17, 5:47 pm, Eric Hexter <eric.hex...@gmail.com> wrote:
> You do not need to reference the pa for it to load.  This is the default
> behavior of the mvc2
>
> sent from my mobile phone
>
> On May 17, 2010 10:58 AM, "ben" <ben.fos...@retroviz.com> wrote:
>
> Hi,
>
> Am loving the Portable Area functionality in the MvcContrib project. I
> would like to lose the dependency that my main web app (entry point)
> has to have on the portable area project, so have a few questions.
>
> 1. How can I change InputBuilder.BootStrap() so that it loads
> additional assemblies that are not referenced by the project (for
> example, using StructureMap's assembly scanning features).
>
> 2. In cases where I need to communicate over the message bus I would
> move the message objects and handlers to a separate class library
> project. The portable area application would reference the adapter
> project so it knows about the message formats. I would then aim to
> scan the adapter assembly (using StructureMap) from the main web
> application and instantiate all instances of IMessageHandler.
>
> Is this a good approach? Doing this would mean that I only ever have
> to reference the one adapter assembly from the web application and
> that deploying a new feature (portable area) would be a case of
> dropping in the relevant dll and an updated adapter - without needing
> to dive into Visual Studio and recompile.
>
> Thanks.
> Ben
>
> --
> Contact Jeffrey Palermo or Eric Hexter with specific questions about the
> MvcContrib project.  Or go tohttp://mvccontrib.org
>
> To unsubscribe from this group, send email to
> mvccontrib-disc...@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/mvccontrib-discuss?hl=en
>
> --
> Contact Jeffrey Palermo or Eric Hexter with specific questions about the MvcContrib project.  Or go tohttp://mvccontrib.org
>
> To unsubscribe from this group, send email to mvccontrib-disc...@googlegroups.com
> For more options, visit this group athttp://groups.google.com/group/mvccontrib-discuss?hl=en

ben

unread,
May 18, 2010, 5:12:51 AM5/18/10
to mvccontrib-discuss
Just a further update.

I created a proof of concept app to test the points I raised on my
second question and am happy with the results.

I have the following projects:

Sample.Web - Main web application (entry point) - references
Sample.Core and Sample.Adapters
Sample.Core - Application services, interfaces, utils
Sample.Adapters - Portable area messages (e.g. LoginInputMessage),
handlers (e.g. LoginHandler) and any html extension methods specific
to the area e.g. Html.Login
Sample.LoginPortableArea - Portable area project. References
Sample.Adapters.

Based on Eric's earlier reply, the call to InputBuilder.BootStrap()
will include areas without explicitly referencing them from the main
web project.

I am using StructureMap to then scan the Sample.Adapters dll for
instances of IMessageHandler:

public AppRegistry() {
Scan(x =>
{
x.Assembly("Sample.Adapters");
x.AddAllTypesOf<IMessageHandler>();
});
}

In Global.asax I do the following:

protected void Application_Start()
{
Bootstrapper.Boot();

Bus.Instance.SetMessageHandlerFactory(new
IocMessageHandlerFactory());

foreach (var handler in
ObjectFactory.GetAllInstances<IMessageHandler>()) {
Bus.AddMessageHandler(handler.GetType());
}

...

This appears to work well and means that if I then add a new portable
area that should communicate via the bus, I need only to update the
Sample.Adapters dll and don't need to add any additional references to
the main web project.
> For more options, visit this group athttp://groups.google.com/group/mvccontrib-discuss?hl=en- Hide quoted text -
>
> - Show quoted text -

Eric Hexter

unread,
May 18, 2010, 7:26:35 AM5/18/10
to mvccontri...@googlegroups.com
That looks like a good approach.  Also, John Nelson has a fork that auto registers all of the handlers.  I just have not had a chance to land that patch yet but it is something worth looking at.
 

Eric Hexter

Director of OSS | Headspring | www.Headspring.com
email | ehe...@Headspring.com
blog | http://Hex.LosTechies.com
info | http://www.linkedin.com/in/erichexter


Reply all
Reply to author
Forward
0 new messages