Top Banner
Copyright © 2005 Finetix LLC All Rights Reserved 1 SpringFramework.Net Developer SpringFramework.Net Developer Session Session Chris Donnan The Peer Frameworks Series - .Net and Java
23

Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Dec 31, 2015

Download

Documents

Antony Francis
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 1

SpringFramework.Net Developer SessionSpringFramework.Net Developer Session

Chris Donnan

The Peer Frameworks Series - .Net and Java

Page 2: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 2

SpringFramework.net 50,000 Ft ViewSpringFramework.net 50,000 Ft View

Core

AOP Services Data Access

Web Desktop Windows Services 3rd Party

Integration

Page 3: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 3

Application ContextApplication 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 programmingWith Spring.

Page 4: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 4

Spring ObjectFactorySpring ObjectFactory

The center of it all…

Since the Application Context is an IObjectFactory – you can use itTo act as a ‘dynamic factory’ for your objects.

You simply ask the factory for your object – and you use it as you normallyWould use any “new’d” object.

The real beauty is that Spring manages assembling that object for you –Giving it whatever dependencies it needs.

Page 5: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 5

Spring Resource AbstractionsSpring Resource Abstractions

You can also use the IApplicationContext’s IResourceLocator interface:

This allows you to get your resources from wherever they may be. This couldBe at a URL, a File, an Embedded Resource, etc.

Page 6: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 6

Spring.net DemoSpring.net Demo

DEMO.– Building a complex business object with many dependencies

– Prototypes and singletons

– Populating collections

Page 7: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 7

Aspect Oriented ProgrammingAspect Oriented Programming

Cross Cutting functionality– Logging

– Transactions

– Security

– Other code that tend to repeat across an application

Page 8: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 8

AOPAOP

Basic code – nothing special

Page 9: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 9

AOPAOP

Page 10: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 10

AOPAOP

Code to invoke programmatically

Output from execution

Page 11: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 11

AOP XML ConifgurationAOP XML Conifguration

Same as programmatic usage – XML Configuration

Page 12: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 12

AOPAOP

Page 13: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 13

Spring WebSpring 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

Page 14: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 14

Data BindingData 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

Page 15: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 15

Result MappingResult 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>

Page 16: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 16

Spring Data Access and TransactionsSpring 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!

Page 17: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 17

Hibernate Code ExamplesHibernate Code Examples

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

Page 18: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 18

Hibernate Config ExampleHibernate 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>

Page 19: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 19

Spring ExpressionsSpring 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"));

Page 20: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 20

Expressions ContinuedExpressions 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

Page 21: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 21

SpringFramework.net DAFSpringFramework.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

Page 22: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 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

Page 23: Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.

Copyright © 2005 Finetix LLCAll Rights Reserved 23

Ruby does IoCRuby does IoC

Concrete Implementations