close

Вход

Забыли?

вход по аккаунту

?

Spring.net - Chris Donnan

код для вставкиСкачать
The Peer Frameworks Series - .Net and Java
SpringFramework.Net Developer Session
Chris Donnan
Copyright В© 2005 Finetix LLC
All Rights Reserved
0
SpringFramework.net 50,000 Ft View
Web
AOP
Desktop
Windows Services
Services
3rd Party
Integration
Data Access
Core
Copyright В© 2005 Finetix LLC
All Rights Reserved
1
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.
Copyright В© 2005 Finetix LLC
All Rights Reserved
2
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.
Copyright В© 2005 Finetix LLC
All Rights Reserved
3
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.
Copyright В© 2005 Finetix LLC
All Rights Reserved
4
Spring.net Demo
пЃµ DEMO.
– Building a complex business object with many dependencies
– Prototypes and singletons
– Populating collections
Copyright В© 2005 Finetix LLC
All Rights Reserved
5
Aspect Oriented Programming
пЃµ Cross Cutting functionality
–
–
–
–
Logging
Transactions
Security
Other code that tend to repeat across an application
Copyright В© 2005 Finetix LLC
All Rights Reserved
6
AOP
Basic code – nothing special
Copyright В© 2005 Finetix LLC
All Rights Reserved
7
AOP
Copyright В© 2005 Finetix LLC
All Rights Reserved
8
AOP
Code to invoke programmatically
Output from execution
Copyright В© 2005 Finetix LLC
All Rights Reserved
9
AOP XML Conifguration
Same as programmatic usage – XML Configuration
Copyright В© 2005 Finetix LLC
All Rights Reserved
10
AOP
Copyright В© 2005 Finetix LLC
All Rights Reserved
11
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
Copyright В© 2005 Finetix LLC
All Rights Reserved
12
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
Copyright В© 2005 Finetix LLC
All Rights Reserved
13
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>
Copyright В© 2005 Finetix LLC
All Rights Reserved
14
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!
Copyright В© 2005 Finetix LLC
All Rights Reserved
15
Hibernate Code Examples
public class NHTestObjectDao : HibernateDaoSupport, ITestObjectDao
{
[Transaction()]
public void Create(TestObject to)
{
HibernateTemplate.Save(to);
}
}
Copyright В© 2005 Finetix LLC
All Rights Reserved
16
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>
Copyright В© 2005 Finetix LLC
All Rights Reserved
17
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"));
Copyright В© 2005 Finetix LLC
All Rights Reserved
18
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
Copyright В© 2005 Finetix LLC
All Rights Reserved
19
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
Copyright В© 2005 Finetix LLC
All Rights Reserved
20
The Peer Frameworks Series - .Net and Java
пЃµ 1) Spring Framework Developer Session - SpringFramework.net,
SpringFramework.org
2) Test Drive Development Developer Session - NUnit, JUnit;
Rhino Mocks in .net and Easy Mock in Java
3) Db4o Developer Session - Open Source Object Database in .net
and Java
4) ORM Developer Session - Hibernate, NHibernate / IBatis
Copyright В© 2005 Finetix LLC
All Rights Reserved
21
Ruby does IoC
Concrete Implementations
Copyright В© 2005 Finetix LLC
All Rights Reserved
22
Документ
Категория
Презентации
Просмотров
15
Размер файла
178 Кб
Теги
1/--страниц
Пожаловаться на содержимое документа