1 / 23

SpringFramework.Net Developer Session

SpringFramework.Net Developer Session. The Peer Frameworks Series - .Net and Java. Chris Donnan. Desktop. Windows Services. 3 rd Party Integration. Web. AOP. Services. Data Access. Core. SpringFramework.net 50,000 Ft View. Application Context. “One Singleton to rule them all”.

tyrone
Download Presentation

SpringFramework.Net Developer Session

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SpringFramework.Net Developer Session The Peer Frameworks Series - .Net and Java Chris Donnan

  2. Desktop Windows Services 3rd Party Integration Web AOP Services Data Access Core SpringFramework.net 50,000 Ft View

  3. Application Context “One Singleton to rule them all” • The IApplicationContext is the ‘normal’ top level entry point to use • SpringFramework.net • Inside you will find (along with other stuff) implementation of: • IObjectFactory • IResourceLocator • These are the interfaces that are most used in day to day programming • With Spring.

  4. Spring ObjectFactory • The center of it all… Since the Application Context is an IObjectFactory – you can use it To act as a ‘dynamic factory’ for your objects. You simply ask the factory for your object – and you use it as you normally Would use any “new’d” object. The real beauty is that Spring manages assembling that object for you – Giving it whatever dependencies it needs.

  5. Spring Resource Abstractions You can also use the IApplicationContext’s IResourceLocator interface: This allows you to get your resources from wherever they may be. This could Be at a URL, a File, an Embedded Resource, etc.

  6. Spring.net Demo • DEMO. • Building a complex business object with many dependencies • Prototypes and singletons • Populating collections

  7. Aspect Oriented Programming • Cross Cutting functionality • Logging • Transactions • Security • Other code that tend to repeat across an application

  8. AOP Basic code – nothing special

  9. AOP

  10. AOP Code to invoke programmatically Output from execution

  11. AOP XML Conifguration Same as programmatic usage – XML Configuration

  12. AOP

  13. Spring Web • Bidirectional data binding • Via attributes • Master Pages in .Net 1x • Dependency Injection for ASP.NET pages/ web services • Result Mapping • MVC Framework for ASP.Net

  14. Data Binding public class UserRegistration : Spring.Web.UI.Page { [Binding("Text", "UserInfo.Email")] protected TextBox email; [Binding("Text", "UserInfo.Address.PostalCode")] protected TextBox postalCode; ……. } *Notice it uses Expression synatax

  15. Result Mapping Used to externalize the mapping of action results to target pages: <object id="homePageResult" type="Spring.Web.Support.Result, Spring.Web"> <property name="TargetPage" value="~/Default.aspx"/> <property name="Mode" value="Transfer"/> <property name="Parameters"> <dictionary> <entry key="literal" value="My Text"/> <entry key="name" value="${UserInfo.FullName}"/> <entry key="host" value="${Request.UserHostName}"/> </dictionary> </property> </object>

  16. Spring Data Access and Transactions • ADO.Net • Hibernate • IBatis.net • Basic patterns and utility classes/ base classes to speed up creating DAO and templated data access classes. • Transaction support • The goal is to reduce code needed to get rolling!

  17. Hibernate Code Examples public class NHTestObjectDao : HibernateDaoSupport, ITestObjectDao { [Transaction()] public void Create(TestObject to) { HibernateTemplate.Save(to); } }

  18. Hibernate Config Example <object id="DbProvider" type="Spring.Data.Support.SqlProvider, Spring.Data"> <property name="ConnectionString" value="Data Source=(local);Database=Spring;User ID=springqa;Password=springqa;Trusted_Connection=False"/> </object> <object id="SessionFactory" type="Spring.NHibernate.LocalSessionFactoryObject, Spring.NHibernate"> <property name="DbProvider" ref="DbProvider"/> <property name="MappingAssemblies"> <list> <value>Spring.NHibernate.Integration.Tests</value> </list> </property> <property name="HibernateProperties"> <dictionary> … </dictionary> </property> </object>

  19. Spring Expressions Evaluation of text expressions against live objects. Sort of like XPath for objects. Simple Example: Inventor tesla = new Inventor("Nikola Tesla", new DateTime(1856, 7, 9), "Serbian"); tesla.PlaceOfBirth.City = "Smiljan"; string evaluatedName = (string) ExpressionEvaluator.GetValue(tesla, "Name"); string evaluatedCity = (string) ExpressionEvaluator.GetValue(tesla, "PlaceOfBirth.City"));

  20. Expressions Continued This can get more complex. You can evaluate objects sub parts, sub parts, etc. Inventor pupin = (Inventor) ExpressionEvaluator.GetValue(ieee, "Officers['president']"; string city = (string) ExpressionEvaluator.GetValue(ieee, "Officers['president'].PlaceOfBirth.City"); ExpressionEvaluator.SetValue(ieee, "Officers['advisors'][0].PlaceOfBirth.Country", "Croatia"); In the latest Spring.net release- there is support of literals, logic, properties, indexers, arrays, types, and lots more

  21. SpringFramework.net DAF • Desktop Application Framework • Pub/ Sub like events • UI Application Container • Injection of dependencies into Controls/ Forms • Model/ View/ Controller | Presenter infrastructure • UI Services Model (ways to GET UI services in a consistent way) • Toolbars • Docking Managers • Status Bars - etc • Databind binding framework • Grid Binding • Expression based simple binding • Object Views (alternative to attributes) • Expression based validation

  22. The Peer Frameworks Series - .Net and Java • 1) Spring Framework Developer Session - SpringFramework.net, SpringFramework.org2) Test Drive Development Developer Session - NUnit, JUnit; Rhino Mocks in .net and Easy Mock in Java3) Db4o Developer Session - Open Source Object Database in .net and Java4) ORM Developer Session - Hibernate, NHibernate / IBatis

  23. Ruby does IoC Concrete Implementations

More Related