Spring.Net Steinar Dragsnes email: steinar.dragsnes at viz.no.

Slides:



Advertisements
Similar presentations
Chapter 13 Review Questions
Advertisements

Apache Struts Technology
Spring, Hibernate and Web Services 13 th September 2014.
Copyright © 2008 Accenture All Rights Reserved. Accenture, its logo, and High Performance Delivered are trademarks of Accenture. Andrew Stone Common Security.
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB JavaForum.
© 2005, Cornell University. Rapid Application Development using the Kuali Architecture (Struts, Spring and OJB) A Case Study Bryan Hutchinson
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Introduction to EJB INFORMATICS ENGINEERING – UNIVERSITY OF BRAWIJAYA Eriq Muhammad Adams J
The Spring Framework: A brief introduction to Inversion of Control James Brundege
Intro to Spring CJUG - January What is Spring? “The Spring framework provides central transaction control of various objects.” This means that any.
UNIT-V The MVC architecture and Struts Framework.
Spring Roo CS476 Aleksey Bukin Peter Lew. What is Roo? Productivity tool Allows for easy creation of Enterprise Java applications Runs alongside existing.
Dependency Injection and Model-View-Controller. Overview Inversion of Control Model-View-Controller.
Java Frameworks Indy Java Users Group January 29, 2003.
Introduction to the Enterprise Library. Sounds familiar? Writing a component to encapsulate data access Building a component that allows you to log errors.
Copyright , Interface21. Copying, publishing, or distributing without expressed written permission is prohibited. Introduction to Spring.NET Mark.
1 INTRO TO BUSINESS COMPONENTS FOR JAVA (BC4J) Matt Fierst Computer Resource Team OracleWorld Session
Introduction to the Spring Framework By: Nigusse A. Duguma Kansas State university Department of Computer Science Nov 20, 2007.
Spring Overview, Application demo -Midhila Paineni 09/23/2011 Spring Overview, Application demo9/8/20151.
ASP.NET Web API Udaiappa Ramachandran NHDN-Nashua.NET/Cloud Computing UG Lead Blog:
Traditional Web Based Application Structure Frameworks define how the application is designed, organised and deployed across various tiers.
Todd Snyder Development Team Lead Infragistics Experience Design Group.
Aspect Oriented Programming (AOP) in.NET Brent Krueger 12/20/13.
95-843: Service Oriented Architecture 1 Master of Information System Management Service Oriented Architecture Lecture 10: Service Component Architecture.
6st ACS Workshop UTFSM ACS Course Component, Container, Lifecycle Management 6st ACS Workshop UTFSM, Valparaiso, Chile H. Sommer, G. Chiozzi.
Enterprise Java Beans Part I Kyungmin Cho 2001/04/10.
Parsley Introduction Kui Huang Oct. 13, Topics Background Dependency Injection Object Lifecycle Message Bus Sample FW Extensions.
Spring core v3.x Prepared by: Nhan Le. History v3.0 Spring Expression Language Java based bean metadata v3.1 Cache Abstraction Bean Definition Profile.
Dependency Injection in Action Jan Västernäs. CADEC2006, DI, Slide 2 Copyright 2006, Callista Enterprise AB Agenda (DI=Dependency Injection) Background.
Final presentation Simon Zambrovski Tutor: Muhammad Farhat Kaleem Design choices and strategies for implementing WS-BusinessActivity.
Opus College - overview. OpusCollege - background First project: ICT Capacity Building Mozambican Higher Education Institutions Partners: RUG Groningen,
Copyright © 2005 Finetix LLC All Rights Reserved 0 SpringFramework.Net Developer Session Chris Donnan The Peer Frameworks Series -.Net and Java.
Spring Framework. Spring Overview Spring is an open source layered Java/J2EE application framework Created by Rod Johnson Based on book “Expert one-on-one.
Introduction to Spring Matt Wheeler. Notes This is a training NOT a presentation Please ask questions Prerequisites – Introduction to Java Stack – Basic.
Inversion Of Control & Dependency Injection Break Apart The Dependencies Oren Eini Senior Developer We! Consulting Group
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Component frameworks Roy Kensmil. Historical trens in software development. ABSTRACT INTERACTIONS COMPONENT BUS COMPONENT GLUE THIRD-PARTY BINDING.
Introduction to Web Dimitar Nenchev Ivan Nakov
A Presentation By V AIBHAV S AHARAN Web-enHanced Information Management COMS E6125.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
Distributed Information Systems. Motivation ● To understand the problems that Web services try to solve it is helpful to understand how distributed information.
Alternative Architectures: Inversion of Control Mike Hadlow mikehadlow.blogspot.com.
آرمان حسين‌زاده آذر  Access to data varies depending on the source of the data.  Access to persistent storage, such as to a database, varies greatly.
Introducing Allors Applications, Tools & Platform.
Java EE Patterns Dan Bugariu.  What is Java EE ?  What is a Pattern ?
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
1 Spring Framework April, 2012 Lam Ho Lam To. © 2010 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2 1.Spring Overview 2.Framework.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Introduction to Data Access with Spring.
Kansas City Java User’s Group Jason W. Bedell July 12, 2006
Component Patterns – Architecture and Applications with EJB copyright © 2001, MATHEMA AG Component Patterns Architecture and Applications with EJB Markus.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Overview of the Spring Framework Introducing.
EJB Enterprise Java Beans JAVA Enterprise Edition
L’origine dei mali: le dipendenze tra componenti Stefano Leli 14° Workshop DotNetMarche Venerdì 16 aprile
Text 16 de mayo de 2009 Spring Framework Part III. Portable Service Abstractions and Spring MVC Buenos Aires, June 2009.
Google Code Libraries Dima Ionut Daniel. Contents What is Google Code? LDAPBeans Object-ldap-mapping Ldap-ODM Bug4j jOOR Rapa jongo Conclusion Bibliography.
Understanding Dependency Injection… and those pesky containers Miguel A. Castro Architect -
Building J2EE Applications Based on Design Patterns with Business Components for Java Olivier LE DIOURIS Principal Product Manager Oracle Corporation.
Introduction to Inversion Of Control (IOC). IOC Definition (based on Wikipedia)  Consider the way in which an object obtains references to its dependencies.
Creative Commons Attribution- NonCommercial-ShareAlike 2.5 License Sakai Programmer's Café Sakai Montreal CRIM Workshop Introduction to Spring Framework.
Leveraging ColdSpring to build a robust Flex applications Chris Scott, Cynergy Systems.
CS520 Web Programming Spring – Web MVC Chengyu Sun California State University, Los Angeles.
J2EE Lecture 6: Spring – IoC and Dependency Injection
Chengyu Sun California State University, Los Angeles
By Ru Shen Department of Computer Science UAlbany, 2008
Distributed System Using Java 2 Enterprise Edition (J2EE)
SAMANVITHA RAMAYANAM 18TH FEBRUARY 2010 CPE 691
Component Technology Bina Ramamurthy 2/25/2019 B.Ramamurthy.
Developing and testing enterprise Java applications
CS520 Web Programming Spring – Aspect Oriented Programming
Leveraging ColdSpring To Make Better Applications
Presentation transcript:

Spring.Net Steinar Dragsnes steinar.dragsnes at viz.no

Agenda Dependency Injection (IoC) Spring.Net Services AOP Declarative Transaction Management through AOP Additional Spring.Net components  Spring.Web (out of scope)  Spring.Integration -NHibernate

Dependency Injection Problem:  How to put the various components and layers together without creating a too tightly coupled system?  How to allow for flexibility and technology changes (also plugging in modules/components)? IoC is not a new concept. DI is a reaction to the heavyweight complexity in the mainstream J2EE world (such as EJB framework). Similar patterns; Service Locator, Factory.

Dependency Injection vs. Service Locator Service Locator forces you to be dependent on the locator. With service locator the application class asks for a service by an explicit message to the locator.  PULL With injection there is no explicit request, the service appears in the application class.  PUSH Dependency Injection, less/no configuration of dependency in your source.

Sample Application Architecture Data Repository Domainobjects DAO implementations Service implementations Web interface Otherinterfaces PresentationLayer ServiceLayer Data Access Layer DAO interfaces Service interfaces

Defining objects in the containter Spring.Net uses XML to wire dependencies.  Programmatic (C#)  Annotations The syntax is quite simple and straigth farwards: Within the object tags you can specify constructor args and properties, just as you would do in a normal factory.

Example, UserService public class UserService : IUserService { private IUserDao dao; public UserService(IUserDao dao) { this.dao = dao; }... }

Defining the service in the IoC container public class UserService : IUserService { private IUserDao dao; public UserService(IUserDao dao) { this.dao = dao; }... }

Defining the service in the IoC container......

Container configuration <section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core"/> IApplicationContext context = ContextRegistry.GetContext(); IUserService service = (IUserService) context.GetObject(“userService");

DI and Application Wiring Through this very basic example you can get an idea on how you can configure and wire your application together. Tips:  Consider when you want to use DI and apply it where it gives you most ”bang for the buck”.  In the beginning, debugging the XML configuration can be difficult.  Whenever experiencing difficulties, do not hesitate to ask for help at the Spring.Net user forum [

DI brings advantages Easy to switch implementations without the need for a recompile. Easy to facilitate testing, unit testing, integration testing. Better separation of concerns. Less dependencies within your application. Easier to write plugin modules. Encourages best practices such as TDD, decoupling, seperation of concerns, design by contract.

Spring.Net Services Portable Service Abstractions (PSA)  Write plain service classes (PONO)  Decide later how you will distribute your objects  Specify distribution technology through configuration..Net Remoting.Net Enterprise Services Web Services

Spring.Net Services How is this achieved?  Spring.Net creates a proxy at runtime that meets the implementation requirements of a specific distributed technology

Enterprise Services … Demo App ApplicationComponent Admin : Administrator role SpringApp.Com.UserService

Accessing the service from the client Administrative type registration is performed using the wellknown element in the client configuration section Seperate service interface and implementation in different assemblies Thus clients can obtain a proxy to a specific implementation with only a reference to the interface assembly. IApplicationContext context = ContextRegistry.GetContext(); IUserService service = (IUserService) context.GetObject(“userService");

Aspect Oriented Programming Problem, an operation that is done repeatedly across many classes and in the same class. Logging, security, transaction management to name a few. Extract the logic of these operations (aspects) into it’s own class. Apply this logic at various locations in your code (pointcut). Terminology  ‘what’ = advice, ‘where’ = pointcut

Aspect Oriented Programming Spring.Net provides an aspect library:  Logging  ExceptionHandling  Caching  Transaction  Parameter Validation Easy to create own aspects.  Create a class that implements one of the interceptor contracts (e.g. IMethodInterceptor)  Create a custome attribute  Either connect attribute and advice programmatic or preferably in the Spring.Net container.

<object id="transactionAdvisor" type="Spring.Transaction.Interceptor.TransactionAttributeSourceAdvisor, Spring.Data"> Configuring Aspects

<entry key="Viz.Core.Aop.Attributes.Log4NetLoggingAroundAttribute,Viz.Core” value="Viz.Core.Aop.Advice.Log4NetLoggingAroundAdvice,Viz.Core"/> <entry key="Viz.Core.Security.Attributes.AccessPriviligesAttribute,Viz.Core" value="Viz.Core.Security.Advices.AccessPriviligesAdvice,Viz.Core"/> <entry key="Viz.Core.Persistence.nHibernate.Session.Attributes.SessionScopeAttribute,Viz.Core.Persistence" value="Viz.Core.Persistence.nHibernate.Session.Advices.SessionScopeAdvice,Viz.Core.Persistence"/>

How this turns out in code [Transaction(ReadOnly = true)] public IList LoadAll(Type entityType) { return dao.LoadAll(entityType); } [Logging] [Permission(Permissions = Permission.ContentManager, Permission.PortfolioManager) [Transaction] public object SaveOrUpdate(object entity) { return dao.SaveOrUpdate(entity); }

Spring.Net Data Access API Provides a consistent programming model across different transaction APIs such as ADO.NET, Enterprise Services, System.Transactions, and NHibernate. Declarative transaction management with any of the above data access technologies (AOP) You can keep the same API across different data access technologies. Changing the underlying transaction implementation is a matter of configuration or a centralized programmatic change as compared to a major overhauling.

Spring.Net NHibernate Integration Spring.Net provides integration with NHibernate in terms of  Resource management DbProvider SessionFactory Sessions, SessionScope, OSIV  DAO implementation support  Transaction strategies You can use Spring's support for NHibernate without using the full Sprting.Net stack or Spring’s transaction management