380 likes | 573 Views
Enterprise Library Overview. Tom Hollander Product Manager Microsoft Edward Jezierski Architect Microsoft. Kyle Huntley Architect Avanade Ron Jacobs Product Manager Microsoft. Architectural Guidance from patterns & practices Application Blocks Enterprise Library Vision
E N D
Enterprise Library Overview Tom HollanderProduct ManagerMicrosoft Edward Jezierski Architect Microsoft Kyle HuntleyArchitectAvanade Ron JacobsProduct ManagerMicrosoft
Architectural Guidance from patterns & practices Application Blocks Enterprise Library Vision Enterprise Library Application Blocks Configuration Cryptography Data Access Security Demonstration Questions Logging & Instrumentation Exception Handling Caching Agenda
D A D I A D I patterns & practicesArchitecture Guidance for the Enterprise ProvenBased on field experience Authoritative Offer the best advice availableAccurateTechnically validated and testedActionableProvide the steps to success RelevantAddress real-world problems based on customer scenarios Available online: http://www.microsoft.com/practices Books available: http://www.amazon.com/practices Patterns Application Blocks Reference Architectures Atomic solutions to recurring problems Sub-system-level guidance for common services System-level guidance for common customer scenarios D A D I D A D I A A D D I I Guides Guidance for broad horizontal topics such as security, performance, deployment and operations
Sound familiar? • Writing a component to make it simpler to call stored procedures • Building a component that allows you to log errors to different sources • Building framework / infrastructure components to generally simplify app development • Searching on the internet thinking • Most applications need something like this • People must have written hundreds of things like this • I wish I could find a solution for this that I could reuse • …wishing Microsoft had done some of this for you?
App Block History • Application blocks have been around for a couple of years • The block program evolved over time with many different teams • Blocks range from very simple helpers like the original data access block to powerful frameworks like UIP • It’s a good start but you can always do better...and you have been telling us what you want
Application Block Feedback • Make blocks consistent • Make blocks work well together • Minimize dependencies • On other blocks • On infrastructure • Make it easier to configure blocks • Make evaluation and understanding of blocks easier • Make using blocks easier
Enterprise Library Philosophy • Consistency • Apply consistent design patterns and implementation approaches • Extensibility • Include extensibility points allowing developers to customize the behavior of the blocks by plugging in their own code or customize by directly modifying source code • Ease of Use • Leverage a graphical configuration tool • Provide a simpler installation procedure • Include clear and complete documentation and samples • Integration • Application blocks should be designed to work well together and tested to make sure that they do. But it should also be possible to use the application blocks individually
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Customer Y library Partner X library p&p Enterprise Library Customer Z library Enterprise Library Vision p&p blocks Partner blocks Customer blocks Block Specification Community blocks
Enterprise Library is… A library of application blocks which solve common challenges A set of helper classes which work in any architectural style Architectural guidance embodied in code which ships with full source allowing you to modify and extend Available as a free download Enterprise Library is not… A part of the .NET Framework An application framework that imposes an architectural style A Microsoft product with support, compatibility and localization For sale Enterprise Library
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Configuration Scenarios • Application needs to read and/or write complex configuration data at runtime • Application which must store sensitive data (password) in configuration • Application or block with design time support in the form of property pages, wizards and validation to assist developers in getting configuration right • Administrator deploying an application needs to change configuration and you want to provide a better experience than using notepad to edit XML configuration files
Configuration Application Block (Runtime) Improves integration Supports pluggable storage providers and transformations Improves ease of use Read & Write Model Supports object graphs Notifications when config store changes Improves Security Supports Encryption Configuration Tool (Design-time) Uses Configuration Application Block Improves ease of use Wizards Property Sheets Validation Improves Security Supports Encryption Masking Configuration Application Block • Provides a general purpose configuration runtime which allows applications to easily read and write configuration data from configurable storage locations
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Cryptography Scenarios • You need to encrypt sensitive data using a symmetric key before storing in the database and decrypt when reading • You need to encrypt information (without using keys) for use on a single machine • You need to create a hash of a password to store in a database and be able to compare that hash with a user supplied hash to see if you have a match without storing the user password
Cryptography Application Block • Improves Security • Provides a simplified approach to implementing common cryptography scenarios • Improves Ease Of Use • Provides operations on both strings and byte streams • CreateHash • CompareHash • EncryptSymmetric • DecryptSymmetric • Improves Integration • Supports all .NET crypto algorithms out of the box, or implement your own • Supports DPAPI for keyless crypto on a single machine • Algorithms and keys can be managed through the configuration tool
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Data Access Needs • A simple and efficient way of working with commonly used databases • Transparency when developing for multiple types of databases • A way to place an indirection between a logical database instance and a physical database instance • An easy way to adjust and validate the database configuration settings
Data Access Application Block • Provides access to the most often used features of ADO.NET with applied best practices • Improve Consistency • Write code that works against multiple database brands (caveats apply!) • Improve Security • Leverages the crypto block and configuration system to securely store connection strings • Improve ease of use • Easily call a stored procedure with one line of code
Data Access - Example Public Function GetProductsInCategory(ByRef Category As Integer) As DataSet ' Create the Database object, using the default database service. The ' default database service is determined through configuration. Dim db As Database = DatabaseFactory.CreateDatabase() ' Invoke the stored procedure with one line of code! return db.ExecuteDataSet("GetProductsByCategory", Category) ' Note: connection was closed by ExecuteDataSet method call End Function
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Security Scenarios • You need to authenticate users • Using one or more security systems or mechanisms • You need to authorize users • Using one or more security systems or mechanisms • You need to determine which roles a user is in • Using one or more security systems or mechanisms • You need to store and retrieve user profile information • Using one or more security systems or mechanisms • You need to cache authentication or authorization data for the duration of a logon session
Encapsulate common application security tasks Present a standard, provider model for common security tasks Minimize the need for custom security-related code Incorporate best practices for application security Security Application Block
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Logging Needs • You need to log business and operations data to various destinations, which are externally configurable • You need to provide tracing to support production debugging • You need to provide auditing for increased security • You need to be able to specify which messages go where, and how they are formatted • You need to be able to log messages to a wide variety of destinations
Logging & Instrumentation Application Block • Provides a simple model for logging events • Replaces the Enterprise Instrumentation Framework and the existing Logging Application Block • Configuration driven – you decide what messages are logged where at runtime. • Sinks provided include • Event Log • Database • Text File • MSMQ • Email • WMI • Create your own…
Logging - Example Dim log As LogEntry = New LogEntry log.Message = “Your message here…” log.Priority = 1 log.EventId = 100 log.Category = "Debug" Logger.Write(log) // Or if you prefer one line... Customer cust = GetCustomer(123); // Log the customer – will call // cust.ToString() for the log entry Logger.Write(cust, Category, Priority);
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Exception Handling Needs • You need consistent exception handling behavior throughout your application • You need to implement best practice guidance for exception handling • Don’t inadvertently disclose security sensitive information to remote callers • Add context to exceptions by wrapping or replacing exceptions with more relevant exceptions • You need to make it simple to add exception management boilerplate code
Exception Handling Application Block • Provides simple mechanism that allows you to consistently deal with exceptions throughout your application • Define “Exception Policies” which link an exception to an action • Exceptions of type ApplicationException should be logged • Exceptions of type SqlClientException should be caught and wrapped with an exception of type DataLayerException and re-thrown • Exceptions of type SecurityException should caught and replaced with an AccessDeniedException which will be thrown • Actions provided include • Logging • Wrapping one exception with another • Replacing one exception with an other • Create your own actions…
Exception Handling - Example Try ' some code that may throw Catch Ex As Exception If ExceptionPolicy.HandleException(ex, “DataLayer”) _ Then Throw End Try
Enterprise Library v1 Caching Exceptions Legend Security Data Access Logging Dependency Plug-in Crypto Configuration Config Tool
Caching Scenarios • You are creating a smart client application that uses locally cached reference data to create requests and support offline operations • You are creating a Windows Service or Console application which needs a cache to improve performance
Caching Application Block • Provides a flexible and extensible caching mechanism that can be used at all layers of an application • Supports backing stores that persist cache data into a database or isolated storage, so the data can survive app restarts • Easy to use • Easy to configure, using the Enterprise Library Configuration Tool • Thread-safe • Ensures that the states of the in-memory cache and the backing store remain synchronized.
Using Enterprise Library • Enterprise Library is provided “as-is” • You are free to extend or modify it to suit your needs • Using Enterprise Library is no different than using code that you wrote yourself • If you have used previous versions of application blocks you have some options • Leave the code alone • Add new functionality using Enterprise library and use it side by side with the old application blocks • Rewrite to use the new application blocks, if they provide enough value to justify the extra development time
Announcing: Enterprise Library 1.0 Download it Today! http://www.microsoft.com/practices
Future plans • We will continue to invest in blocks and block libraries • Additional capabilities and scenarios • New blocks, such as Validation • Updating existing application blocks, such as UIP • Scenarios such as Smart Client • Enablement • Visual Studio tooling and wizards • Deeper community penetration • .NET 2.0 / Visual Studio 2005 release • Blocks revved to adhere to best practices of new platform • Integration with new VS2005 experiences
http://www.microsoft.com/practicesEnterprise Library Communityhttp://go.microsoft.com/fwlink/?linkid=39209&clcid=0x09