PIAB/Interception guidance for new Entlib 5.0?

Topics: Policy Injection Application Block
Apr 23, 2010 at 5:04 PM

What is the recommended approach for combining EntLib and Unity Interception in the brave new world of EntLib5/Unity2? The current Entlib 5 documentation has broken links for topics that talk about Interception and Unity. :(

I haven't used PIAB for a while, but I remember correctly, in previous releases PIAB was clearly documented as an application block, hence you configured it like any other application block.  It worked and I understood it.

Now that the interception mechanism is Unity's domain, I'm a bit confused as to best practices in blending the two together?

Should we still use the call handlers like AuthorizationCallHander, ExceptionCallHandler, etc. with Unity 2.0 Interception? Or are they for backwards compatibility only?

Should we be using the Entlib graphical configuration tool to add Policy Injection Settings in new applications? Can/should we add PIAB settings in the config tool backed by Unity 2.0 interception (not using the backwards compatible PIAB facade, but still applying policy and matching rules?).

Do Matching Rules, Policies, and Call Handler all still apply? (i.e. or are matching rules and policies only something in PIAB, now lost since Entlib has jettisoned PIAB except for "backwards compatibility?) In other words, is the concepts of "policy injection" still useful on top of "raw interception" as per Unity 2.0?


Apr 25, 2010 at 12:47 PM


All good questions. Unity and Interception are two topics in the documentation which are being finalized now. That's the reason the current doc set is labeled as "Pre-release" and posted on Codeplex only and not MSDN. As soon as the final editorial and content pass on these are completed, we'll release the full set of docs on MSDN (hopefully next week).

In v5,  the interception mechanism is provided by Unity and PIAB now is mainly a collection of handlers.  So, yes, you can still use the AuthorizationCallHandler, ExceptionCallHandler and the like. Interception can be configured both programmatically and through the Policy Injection settings in the config tool. All Matching Rules, Policies and Call Handlers still apply in PIAB.

While the Policy Injection Application Block is still included in this release of Enterprise Library, it is (with the exception of one call handler - Performance Counter Handler) a set of legacy components such as the PolicyInjection facade that supports backwards compatibility with applications that use versions of Enterprise Library prior to version 5.0.

Also be aware that, even if you decide to continue to use the call handlers included in the Policy Injection Application Block, you must still make some changes to your existing application. The location of  the call handlers has changed, so you must ensure that you reference the appropriate assemblies and namespaces in your code (see the Migration guide).

Notice that the Unity interception is more powerful than earlier versions of PIAB and supports both instance and type interceptors.

For new, custom call handlers and interceptors, you should consider the "raw interception"  of Unity 2.0.

Hope this helps.

Also, I'd like to mention that the EntLib team is working on a new set of hands-on labs, and the topic of interception is certainly included in it with detailed walk-throughs and exercises. We plan to release these shortly.

- Grigori



Apr 25, 2010 at 11:57 PM
Edited Apr 26, 2010 at 12:05 AM

Thanks for the response Grigori.  Combining your response and what I could glean from the beta Unity 2 docs, are the folliwng true: 

  1. The call handlers embedded in each block's library (e.g. LogCallHandler in the Logging library assembly) are current and meant to be used in the new Unity2 based interception world. Call handlers are the only thing left from PIAB (non legacy) that live in Entlib. I shouldn't have to create custom call handlers or interceptors for basic integration between Unity interception and Entlib5 (e.g. easily using Logging or Exception handling blocks with Unity interception).
  2. Unity takes over the other PIAB functions, now called "Interception", "Behaviors" and "Call Handlers".
  3. The PIAB policy and matching rules are now contained in Unity as a 'behavior' called PolicyInjection
  4. When configuring Policy Injection with the Entlib Configuration GUI, it produces config output only suitable for the legacy PIAB. I cannot use the Entlib GUI to configure policy injection behavior settings for use by the native Unity "policy injection" behavior/matching rules. To configure Unity policy injection I must do so by hand in the config file or programatically. Unlike Entlib, Unity provides no graphical tool for ANY of its configuration.