Spring - Object Computing

Spring Object Computing-ppt Download

  • Date:29 Nov 2020
  • Views:5
  • Downloads:0
  • Size:251.50 KB

Share Presentation : Spring Object Computing

Download and Preview : Spring Object Computing

Report CopyRight/DMCA Form For : Spring Object Computing


Transcription:

Paul JensenPrincipal Object Computing Inc Spring Overview Lightweight Container Very loosely coupled.
Components widely reusable and separately Created by Rod Johnson Based on Expert one on one J2EE Design andDevelopment Currently on version 1 1 1.
Why Use Spring Wiring of components Dependency Injection Promotes simplifies decoupling design to interfaces TDD Declarative programming without J2EE Easily configured aspects esp transaction support.
Simplify use of popular technologies Abstractions insulate application from specifics eliminateredundant code and handle common error conditions Underlying technology specifics still accessible closures Why Use Spring .
Conversion of checked exceptions to Or is this a reason not to use it Not an all or nothing solution Extremely modular and flexible Well designed.
Easy to extend Many reusable classes Spring Framework Spring Application Spring Dependency Injection.
Inversion of Control IoC Hollywood Principle Don t call me I ll call you Container resolves injects dependencies ofcomponents by setting implementation object push .
As opposed to component instantiating or ServiceLocator pattern where component locatesimplementation pull Martin Fowler calls Dependency Injection Dependency Injection Variants.
Variations on dependency injection Interface based Avalon Constructor based PicoContainer Spring Setter based Spring BeanFactory provides configuration framework to.
initialize and wire JavaBeans org springframework beans andorg springframework context Typically use the XmlBeanFactory employing XMLconfiguration files.
Dependency Injection cont d BeanFactory configured components need haveno Spring dependencies Simple JavaBeans Beans are singletons by default.
Properties may be simple values or references toother beans Built in support for defining Lists Maps Sets and Properties collection types Custom PropertyEditors may be defined to.
convert string values to other arbitrary types XmlBeanFactory Example Property and constructor based IoC bean id exampleBean class examples ExampleBean property name beanOne ref bean anotherExampleBean proper... .
property name beanTwo ref bean yetAnotherBean property property name integerProperty 1 propert... bean id anotherExampleBean class examples AnotherBean bean id yetAnotherBean class examples YetAnotherBean bean id exampleBean class examples ExampleBean .
constructor arg ref bean anotherExampleBean constr... constructor arg ref bean yetAnotherBean constructo... constructor arg value 1 value... bean id anotherExampleBean class examples AnotherBean bean id yetAnotherBean class examples YetAnotherBean .
Bean Creation Direct instantiation bean id beanId class className BeanFactory instantiation Same syntax but class is subclass of BeanFactory.
getObject called to obtain Bean Static Factory bean id beanId class className factory method staticCreationMethod Instance Factory Method.
bean id beanId factory bean existingBeanId factory method nonStaticCreationMethod... Bean Creation Beans may be singletons or prototypes Attribute singleton false causes instantiation.
with each getBean lookup Singleton is default XmlBeanFactory pre instantiates singletons May be overridden on per instance basis by lazy init true .
Beans may also be marked abstract allowingreuse of attribute values through inheritance Autowiring Properties Beans may be auto wired rather than using ref Per bean attribute autowire.
Explicit settings override autowire name Bean identifier matches property name autowire type Type matches other defined bean.
autowire constructor Match constructor argument types autowire autodetect Attempt by constructor otherwise type Dependency Checking.
Ensures properties are defined Per bean attribute dependency check None required by default Verifies autowiring succeeded simple .
all but collaborators object collaborators only all Collaborators primitive types and collections.
Lifecycle Customization Can define init method called after properties set init method method name Can define destroy method as shutdown hook destroy method method name .
May alternatively implement InitializingBeanand or DisposableBean At cost of Spring dependency BeanFactory Miscellany BeanFactoryAware interface provides BeanFactory for.
setBeanFactory BeanFactory BeanNameAware interface provides bean name setBeanName String FactoryBean for beans which are themselves factories Object getObject .
Boolean isSingleton Class getObjectType BeanFactory UsageInputStream is new FileInputStream beans xml XmlBeanFactory factory new XmlBeanFactory is .
MyBeanClass bean MyBeanClass factory getBean m... ApplicationContext ctx newClassPathXmlApplicationContext... MyBeanClass bean MyBeanClass ctx getBean myBea... ApplicationContext.
Extends functionality of BeanFactory Pre instantiates singleton beans Detects and registers BeanPostProcessors andBeanFactoryPostProcessors Supports nesting of contexts.
ApplicationListener and ApplicationEvents Initialized and closed predefined Custom may be created MessageSource provides i18n messaging bean id messageSource .
class ResourceBundleMessageSou... Contains list of bundle base names Web Initialization Web applications may useContextLoaderListener to initialize Spring.
context param param name contextConfigLocat... param value WEB INF daoContex... WEB INF applicationContext xm... param value context param .
listener listener class org springfram... listener Automatically done by Spring DispatcherServlet Specialized Beans.
MethodInvokingFactoryBean Invokes method on registered beans or any static Stores return value SingletonBeanFactoryLocator andContextSingletonBeanFactoryLoc... .
Useful for sharing BeanFactories Eliminate duplication of beans in multiple similarfactories or contexts ApplicationContext customization Defined beans inheriting from.
BeanFactoryPostProcessor are detected and invoked CustomEditorConfigurer Registers custom PropertyEditors for convertingconfiguration string values to specific types AutoProxyCreators.
Wrap beans in proxies based on various criteria name metadata etc PropertyResourceConfigurer Sets from property file and or system properties ApplicationContext Example.
bean id propertyConfigurer class org springframework bean... property name location value database p... bean id dataSource class org springframework jdbc... .
property name driverClassName value database connection dri... property property name url value database connection url... .
property Spring AOP AOP Fundamentals Aspect oriented programming AOP provides forsimplified application of cross cutting concerns.
Transaction management Security Logging Auditing Locking.
AOP sometimes partially achieved via Decorators or CORBA Portable Interceptors Servlet Filters AOP Fundamentals Aspect Implementation of a cross cutting concern .
Spring Advisors or Interceptors Joinpoint Execution point to target Typically methods Advice Action taken at a particular joinpoint Pointcut A set of joinpoints specifying where advice.
should be applied e g Regular expression Introduction Mixin Adding methods or fields to anadvised class Weaving Assembling aspects into advised objects Spring AOP.
Generally applies aspects to beans using BeanFactory Uses Dynamic Proxies if interface availableotherwise CGLIB CGLIB creates derived class which proxies requests Bean class may not be final.
Less capable than AspectJ does not have field interception only runtime weaving solution is available Closer integration with AspectJ anticipated Spring Pointcuts.
Pointcut applicability to a class may be evaluatedstatically or dynamically Spring only creates proxies where necessarypublic interface Pointcut ClassFilter getClassFilter .
MethodMatcher getMethodMatcher public interface ClassFilter boolean matches Class clazz Pointcuts cont d Pointcut may be statically or dynamically.
evaluated based on isRuntime Abstract class StaticMethodMatcherPointcutrequires override of 1st method onlypublic interface MethodMatcher boolean matches Method m Class targetClass .
boolean isRuntime boolean matches Method m Class targetClass Object args Only called if isRuntime true Pointcuts cont d Spring predefined pointcuts.
In org springframework aop suppor... package RegexpMethodPointcut Union of multiple regular expressions Uses Jakarta ORO package ControlFlowPointcut.
Similar to AspectJ cflow Applied if call stack includes specific class and optionally UnionPointcut Merges pointcuts Spring Advice.
Can have per class or per instance Advice Spring provides several Advice types Around Advice AOP Alliance compliant Must call invocation proceed to call target.
public class MyAdvice implements AroundAdvice Object invoke MethodInvocation invocation change arguments start transaction lock etc invocation proceed change return value stop transaction unlock etc .
Spring Advice MethodBeforeAdvice void before Method m Object args Object target Cannot alter return type ThrowsAdvice.
Marker interface Implementors define methods of form afterThrowing Method args target subclassOfThrowable AfterReturningAdvice void afterReturning Object returnValue Method m .
Object args Object target Cannot modify return value Spring Advice IntroductionInterceptor provides ability to definepublic class RollbackAdvice extends DelegatingIntroductionIntercep... .
implements RollbackSupport Map map new HashMap void rollback Date date rollback to state at given timepublic Object invoke MethodInvocation invocation .
record change and time of change Injecting Advice bean id meetingTarget class ex DefaultMeeting singleton false property name topic Spring property .
bean id myAdvisor class ex RollbackAdvice singleton false bean id debugInterceptor class org springframework aop ... Injecting Advice cont d .
bean id meeting class org springframework aop ... property name proxyInterfaces All methods value ex Meeting value using CGLib property if none defined.
property name target ref local meetingTarget property property name interceptorNames list Advisors applied in order value myAdvisor value value debugInterceptor value .
property Autoproxying Autoproxy bean definitions automatically proxyselected beans BeanNameAutoProxyCreator.
Adds listed advisors interceptors to beanswith names matching regular expression DefaultAdvisorAutoProxyCreator Generic autoproxy infrastructure support Applies all advisors defined in the context to.
all beans proxying appropriately Metadata support Spring supports obtaining meta data Objectattributes at class method and field level Not yet argument level as JSR 175 .
Currently supports Jakarta Commons Attributes Support for JSR 175 in work Metadata support provided via Attributes Amenable to mocking unlike JDK reflection andCommons static methods.
Metadata autoproxying Configuration of autoproxying based on metadataattributes simplifies configuration Define custom attribute class Define Advisor with pointcut based on custom attribute.
Add Advisor in ApplicationContext with autoproxy Examples Transaction AttributesSpring Paul Jensen Principal, Object Computing Inc. Spring Overview “Lightweight Container” Very loosely coupled Components widely reusable and separately packaged Created by Rod Johnson Based on “Expert one-on-one J2EE Design and Development” Currently on version 1.1.1 Why Use Spring?

Related Presentations

Komputasi Berbasis Object Object Oriented Computing

Konsep Berbasis Object (Object-Oriented Concept) By suminten Materi Paradigma berbasis obyek (object-oriented/OO) Mengapa OO ? Pemrograman OO Konsep-konsep dalam OOP Kelas dan obyek Mekanisme OO: encapsulation, inheritance, dan polymorphism OO dan interoperabilitas Tools OO dalam komputasi terdistribusi OO Sebagai Paradigma Pemrograman Paradigma pemrograman: pandangan mendasar terkait tentang ...

25 Views0 Downloads

More nouns Nominative direct object and indirect object

Wednesday is concrete (it begins and ends) Nice that almost everyone tried the bonus question! Almost everyone got it right! Review: Last week’s quiz ... We gave Allen and Dominique our tape; the couple will preview our demo tonight. We=S, Allen, Dominique=IO, tape=DO, couple=S, demo=DO. 4. The trees are shedding their leaves.

22 Views0 Downloads

Overview of Distributed Object Computing

Foundations of Artificial Intelligence Intended role of knowledge representation in AI is to reduce problems of intelligent action to search problems. --Ginsberg, 1993 1. Devise an algorithm to solve the problem 2. Select a programming language in which the algorithm can be encoded 3. Capture the algorithm in a program 4. Run the program 1.

17 Views0 Downloads

J2EE Design patterns Object Computing

J2EE connector architecture References Design Patterns , Elements of Reusable Object-Oriented Software - GOF Core J2EE Patterns, Best Practices and Design Strategies. - Deepak Alur, John Crupi , Dan Malks EJB Design Patterns - Floyd Marinescu Enterprise Java Beans - Richard Monson-Haefel J2EE Design patterns Sharath Sahadevan August 8 , 2002 St ...

15 Views0 Downloads

The Eclipse IDE Object Computing

The Eclipse IDE Gareth Davies

2 Views0 Downloads

Spring Summer Fall Winter and Spring

A 2003 South Korean film about a Buddhist monastery which floats on a lake in a forest. The story is about the life of a Buddhist monk as he passes through the seasons of his life, from childhood to old age. The movie was directed by Kim Ki-duk, and stars Su Oh-yeong, Kim Young-min, Seo Jae-kyung, and Kim Jong-ho.

19 Views0 Downloads

CS5412 Spring 2012 Cloud Computing Cornell University

Load-balancing router: Role is to spray requests over available first-tier service instances. Desirable properties include proximity (use the right data center for this user), affinity (if possible, requests from a given client should route to the same server), load balancing, effective use of elasticity. First-tier services are limited to using soft-state or running without any state at all ...

14 Views0 Downloads

CS5412 Spring 2012 Cloud Computing

High assurance. Real-time control. ... Weakens consistency to achieve faster response times: the cloud is “inconsistent by design” ... Yet they run Linux on their servers, build programs in C++ using gcc, allow employees to install their favorite browser add-ons, use Mono to create Linux versions of their Windows applications.

12 Views0 Downloads

GPU Computing Examples Caltech Computing Mathematical

General-purpose parallel computing platform for NVIDIA GPUs. Vulkan/OpenCL (Open Computing Language) General heterogenous computing framework. Both are accessible as extensions to various languages. If you’re into python, checkout . Theano, pyCUDA. Upcoming GPU programming environment: Julia . Language

38 Views0 Downloads

Mobile Computing Models Mobile Computing CNT 5517 5564

With the advent of location-based services and peer-to-peer computing, service discovery is taking on new importance as a critical middleware for mobile computing, and is enabling “opportunistic” new models of programming and application development.

32 Views0 Downloads

EDM Council Object Management Group Semantic Standards

Derivatives (part) Operational Ontology. Over the coming months the EDM Council and OMG FDTF will work towards aligning all the moving parts of the FIBO universe. Will hold off release until we have something of demonstrable value. Use Case: LEI information requirements. Determine the sub-set of FIBO-BE required for these

38 Views0 Downloads

A Tutorial on Object Detection Using OpenCV

A Tutorial on Object Detection Using OpenCV Introduction The goal of object detection is to find an object of a pre-defined class in a static image or video frame. Methods Simple objects Extracting certain image features, such as edges, color regions, textures, contours, etc. Complex objects Learning-based method: Viola and Jones, “Rapid ...

42 Views0 Downloads