Free Essay

Spring

In:

Submitted By ankz23
Words 1559
Pages 7
SPRING
Link:
http://static.springsource.org/spring/docs/2.5.4/reference/index.html
Packages to remember:
BeanFactory:
org.springframework.beans.factory.BeanFactory Interface.
XmlBeanFactory:
org.springframework.beans.factory.xml.XmlBeanFactory Class.
It implements BeanFactory Interface.
Application Context: org.springframework.context.ApplicationContext Interface.
It is a sub interface of BeanFactory.
ClassPathXmlApplicationContext:
org.springframework.context.support.ClassPathXmlApplicationContext class.

BeanFactory

ClassPathXmlApplicationContext
XmlBeanFactory
ApplicationContext

implements extends

implements

Spring Core Container:
Spring core container is an IOC implementation in java.
IOC is an architectural pattern describing to have an external entity to wire the objects.
Here the wiring is done using dependency injection.
IOC pattern describes to have an external entity to perform DI.
IOC – Inversion of Control DI – Dependency Injection.
Dependency Injection is a mechanism of making the dependencies available to the object.
The other 2 approaches to do the same are,

1. Creating the dependencies 2. Pulling the dependencies.
In Dependency Injection mechanism the dependencies are pushed into the object.
This approach helps us in creating the object more cleanly, as the code for creating or pulling the dependencies is excluded from the object.
However identifying the objects in which the DI is to be implemented is a difficult task and further implementing those objects is complex.
IOC describes a solution for this problem.
As per this solution we want to create a special entity only for this responsibility, such entity is generally considered/referred as IOC container.
The spring framework implements this pattern for managing java objects; this implementation of IOC is named as Spring Core Container.
Initializing the Spring Core Container:
To initialize a spring core container we just need to create a BeanFactory Object.
Spring Core Container can be started on any java platform such as directly on JRE, Applet Container, Web Container and EJB Container.
Spring Framework includes few implementations for Bean Factory that can allow us to create, to initialize Spring Core Container such as XmlBeanFactory, AutoProxyBeanFactory etc.
The Spring Framework includes a sub-type for Bean Factory which supports additional functionality over the Bean Factory.
The application context interface is the sub-type of Bean Factory interface.
Bean Factory takes less time to start compared to Application Context, as the Bean Factory will initialize the resources on request instead at start-up.
Using Bean Factory To Initialize Container:
BeanFactory beans = new XmlBeanFactory(new FileSystemResource (“mybeans.xml”));
FileSystemResource – FileInputStream or any input reading mechanism.
Using Application Context:
ApplicationContext ac = new ClassPathXmlApplicationContext (“mybeans.xml’);
This ClassPathXmlApplicationContext supports to specify multiple xml documents. new ClassPathXmlApplicationContext(new String[] {“mybeans1.xml”, “mybeans2.xml”});
Types of Dependency Injection:
The most common approaches to push the dependencies are, 1. Constructor injection 2. Setter method injection
Constructor Injection:
The process of pushing the dependency into an object through its constructor argument is referred as Constructor Injection.
The dependency that is mandatory for the object to exist is recommended to be injected through constructor.
If our dependency is to be injected only once into the object and need not be changed throughout the lifetime of this object, we are recommended to use constructor injection.
Setter Method Injection:
In this case we inject the dependency through the method argument of the object. In general these methods are setXXX methods.
This approach supports us to inject the dependencies into an object later after the object is instantiated.
This supports to change the dependency of an object for multiple times within the lifetime of the object.
Spring Beans Xml configuration document:
From Spring 2.0 the spring beans xml document elements are defined using xml schema.
The basic set of tags that can be used to create this document are described into spring beans xml schema document.
This schema definition is accessed using the following namespace, http://www.springframework.org/schema/beans <beans> tag:
This is the root element for the spring beans xml document.
This supports to define spring beans, import other spring beans documents and define aliases for spring beans.
The following 3 tags are supported as child tags, 1. import 2. alias 3. bean
In addition this tag supports few attributes for configuring default values of the respective parameter for all the spring beans defined in this document.
<bean> tag:
This tag is used to define a spring bean.
Managing spring bean includes 1. instantiating 2. initializing 3. manage the lifetime for the object.
Spring Container supports to instantiate a java object for a spring bean in 3 styles, 1. using class constructor 2. using static factory method 3. using non-static factory method using class constructor to instantiate spring bean: package com.acc.spring; public class TestBean{…..} config in xml file as follows for above bean:
<bean id= “tb” class= “com.acc.spring.TestBean”/>
To describe the spring container to instantiate spring bean using the class constructor we use class attribute.
The class attribute takes a qualified name of the class whose constructor is to be used for instantiating a spring bean.
We can define multiple spring bean’s in the context, thus we may want to describe a unique identity for the spring bean in the context.
We use “id” attribute to specify a unique identity for spring bean. package com.acc.spring; public class TestBean
{
Public TestBean(String s) { }
}
Config as follows:
<bean id= “tb” class= “com.acc.spring.TestBean”>
<constructor-arg><value>Hello</value></constructor-arg>
</bean>
How to describe to use argumented constructor ?
We use constructor-arg tag to describe an argument of the constructor to use for instantiating this spring bean.
Child tags of <constructor-arg>:
The <constructor-arg> tag supports the following child tags that can be used to describe the value for this constructor argument. 1. <value>
The value tag supports text as child content. Value tag supports one attribute named type. The type attribute specifies the type to which the enclosed string based value is to be converted.
Eg:
<value type= “int”>10</value> 2. <ref>
It describes a spring bean reference. It is an empty tag. It supports 3 attributes. 1. Local 2. Bean 3. Parent
Local:
Used to refer a spring bean using the id of spring bean.
Eg:
public class TestBean1{……} public class TestBean2
{
public TestBean2(TestBean1 tb1) {}
}

<bean id= “tb1” class= “com.acc.spring.TestBean1”/>
<bean id= “tb2” class= “com.acc.spring.TestBean2”> <constructor-arg><ref local= “tb1”/></constructor-arg>
</bean>
3. <null>
Eg:
<bean id= “tb2” class= “TestBean2”> <constructor-arg><null/></constructor-arg>
</bean>
4. <list>
To describe any array or java.util.List type of object.
Supports 0 or more child elements.
The list tag supports the following as child tags i. <value> ii. <ref> iii. <null> iv. <list> v. <set> vi. <map> vii. <props> viii. <bean>

All of these can occur for zero or more times in any order
Each child tag in this tag describes one element of this list or array
Eg:
Public class TestBean { Public TestBean(String s[]){} } <bean id= “tb” class= “com/acc.spring.TestBean”> <constructor-arg> <list> <value>v1</value> <value>10</value> </list> </constructor-arg> </bean> 5. <set>

It is used to describe java.util.set type of object. this supports the same child tags as list.

6. <map>
The map tag is used to describe java.util.map type of object
This tag supports zero or more entry tags, the entry tag supports 2 child tags. 1.key 2.can be any of the following <value> <ref> <null> <list> <set> <map> <props> <bean>

the key tag supports any one of the above listed tags as the child tags. eg: <map> <entry> <key><value>k1</value></key> <value>v1</value> </entry> <entry> <key><value>k1</value></key> <value>v1</value> </entry> </map> 7. <props>
It is used to describe java.util.Properties object where the key and value are considered as String. The props tag supports 0 or more prop tag.
Eg:
<props> <prop key= “k1”>v1</prop> <prop key= “k2”>v2</prop>
</props>
8. <bean>
Eg:
class TestBean2
{
TestBean2(TestBean1 t1) { }
}
<bean id= “t2” class= “TestBean2”> <constructor-arg> <bean class= “TestBean1”/> <constructor-arg>
</bean>

Spring Web MVC
This part of spring frame work implements infrastructure that is required for creating web based MVC applications in java.
The spring web MVC infrastructure is built on top of the Servlet API so that it can be integrated into any java web application server
This uses the spring IOC container to access the various framework and application objects

Similar Documents

Free Essay

Spring

...Hopkins’s poem focuses on the beauty of the spring season, using examples of how life blossoms during the spring. Everything comes to life, the new array of colors paint a colorful world. All of God’s little creatures come to life. Birds fill the air soaring through the bluest sky, they build nest for little newcomers. The spring showers clean the air and everything smells clean and fresh to the poet. This world emerged from a dreary place called winter. Hopkins expresses how spring brings God’s paradise alive once again; and he is elated. Hopkins shows God his appreciation through his expression of how the spring must be similar, to the Garden of Eden. The world feels clean and bright to the Hopkins. Almost seems like a prayer request asking God to make it last forever, unlike the Garden of Eden which brought sorrow and despair. Analysis: Hopkins focuses on bright colors, like the "descending blue, that blue is all in a rush" and also uses similar "like lightning" to reinforce the power of spring. The image he gives the reader catches the reader off guard, a small distraction small distraction. Hopkins states “weeds and wheels” and “long lovely and lush,” this little distraction changes the readers’ visual. However, almost immediately he regains the reader’s attention. With his illustration it only gives the reader the meaning as his imaginary wheel makes you focus on his expression of the spring season here, Hopkins hits a note, he questions nature “”all this...

Words: 384 - Pages: 2

Free Essay

The Last Spring

...The last spring I remember once I had someone very dear to me, someone that left deep traces in my life, someone that would live in my heart forever, someone that I will never forget. In order to preserve the memory of this angel, a divine human creature, I devote this story to my friend because her innocence and her fragility has been inspiring me for years. I hope that many people will understand the hidden message once they've read the story. It was a wonderful spring dawning. The air was poisoned with nothing else but the strong smell of the spring flowers and the joy of the birds' songs. We were holding our hands and happily as happy can two little girls be, we were bouncing and jumping in the park. Spring could be seen in our eyes, sunshine could be recognized in our smile. It seemed to us like we were flying in the air as two colourful butterflies from a flower to a flower, each of them more and more beautiful, each of them more and more attracting, as if they were the last days of our lives and each of them was more and more challenging. Smiling faces everywhere, people could envy our happy childhood reflected in the deepness of our sight. We were so excited in those spring rainbows above our heads without knowing that this would be our last spring together, remembered afterwards as the coldest one and the darkest one in my life. It's funny how Marta and I met at a beach resort. We could never imagine that we were going to be inseparable friends. Although...

Words: 1290 - Pages: 6

Free Essay

Spring Motion

...Title: How different springs behave under the influence of same mass depending on the spring constant (k) and connection types (parallel or series)? Summary: This experiment will be carried out to investigate spring constants of different springs by measuring the length of springs under the influence of same mass and different masses, and observe how overall spring constant changes depending on connection types of springs by measuring amount of extension when springs are connected in series and parallel. Different springs with different constant, different masses, weighing machine and a measuring ruler will be used. Research: The course textbook and different textbooks (S.Beichner, Fizik1, Ankara: Palme Yayınevi, 2002.), some laboratory experiments, which retrieved from the Internet, some lectures and videos comprise sources for the theoretical analysis of the experiment. -Prof. Walter Lewin (1999), Hooke's Law, Simple Harmonic Oscillator (online) (http://ocw.mit.edu/courses/physics/8-01-physics-i-classical-mechanics-fall-1999/video-lectures/lecture-10), -Combination of springs (online) (http://engineeronadisk.com/V2/book_modelling/engineeronadisk-10.html) -Sal Khan (2008), Intro to springs and Hooke's Law (online) (http://www.youtube.com/watch?v=ZzwuHS9ldbY) -Forces and elasticity (online) (http://www.bbc.co.uk/schools/gcsebitesize/science/add_aqa/forces/forceselasticityrev2.shtml) -Deformation of materials (online) (http://qatemplates.everythingscience.co.z...

Words: 546 - Pages: 3

Free Essay

Spring Making

...Order By Phone 1-800-741-0015 Shopping Cart Help Submit A Question | FAQs | Cheat Sheets | Sight Height Calculator | How-To's | Gun Parts Source | Matches & Shows BenchTalk Articles | Brownells Product Instructions Search Gift Certificates Go keyword or stock# parts + materials Gun Parts Scopes & Electronic Sights Scope Rings & Bases Reamers & Chamber Gauges Recoil Pads & Buttstock Parts Stockmaking & Finishing Stock Bedding & Adhesives Metal, Springs & Screws Factory Parts Return to List Print Friendly Version Springmaking Without Tears By: Steve Ostrem Everyone who has worked on guns for a long time knows the awful truth. Sooner or later, a customer is going to bring in an unusual firearm for which spare parts, especially springs, are nonexistent. Or, maybe itâ ™s an interesting antique that you got a deal on at the last gun show or at a farm auction and would like to shoot if only the mainspring(s) werenâ™t broken. Dozens of phone calls get you nowhere. Your usual reliable sources for parts have never heard of the thing and have no idea where to direct you. At this point desperation sets in. Doubling or tripling the price will deter all but the most determined customers. But we all know there is always at least one person out there that wants his one of a kind blunderbuss made to work again no matter what the cost. Their reasons are usually tied to a strong sentimental attachment to the thing. ✠My (grandfather, great uncle, wifeâ™s sisterâ™s niece...

Words: 3626 - Pages: 15

Premium Essay

Healthy Spring Water Company

...Tiffany Elliott November 14, 2012 MKT 2100 – Case #5 HEALTHY SPRING WATER COMPANY Summary: The Healthy Spring Water Company sells bottled water, priced at $20 per 10 gallon bottles, to homes and offices. On average, the company sells about 2000 units per day. With its current pricing, the demand for the water is stable, but management is always looking for new ways to shake things up and increase profits. The company has thought about repositioning their water as a premium product, which would increase the unit price; and in return increase profit. If this idea goes the way the company predicts, they could charge 20% more for its water. Questions: 1. What is the maximum sales loss (in % and units) that Healthy Spring could tolerate before a 20% price increase would fail to make a positive contribution to its profitability? (That is, what is the basic break-even sales change?) Answer: 25% sales loss (1500 break-even sales change) -.20 divided .8 = .25 (12/20+.20=.8) __________________________________________________________________________________________________________________ 2. By how much would Healthy Spring's contribution increase if its sales declined by 15% following the price increase? Answer: -1.54 __________________________________________________________________________________________________________________ 3. In order for Healthy Spring to reposition itself as premium water, management believes that it will have to upgrade the packaging...

Words: 575 - Pages: 3

Free Essay

Spring Shortening

...Spring shortening.... Many of us, “Springer” airgun enthusiasts have at some time, needed to replace a main spring in our guns. Some would leave the job to a gunsmith, which is always the best plan if you don’t feel confident or competent to do the job yourself, but there is a certain feeling of deep gratification when YOU work on YOUR rifle, to set it apart from the others. Fitting an aftermarket spring isn’t a difficult job for anyone with some general handyman skills, the right tools and a little knowledge about how the spring gun is put together. The replacement spring will undoubtedly change the shooting characteristics of the gun, not least the muzzle energy. You will see the disclaimers on the spring packaging, saying that in fitting this spring the muzzle energy may exceed the 12ft.lb legal limit....! So, if this happens with your new spring, you will need to shorten it. Before we look at how to do that, perhaps we should try to understand a little more about the spring material and how it responds to the inevitable application of heat at the shortened end. Spring Steels. There are many different types of material that can be used in spring production. Each material has different compositions and properties. Steel spring material is typically 0.45 – 0.90% Carbon, with additions of Manganese, Silicon, Chromium and Vanadium. In general, the more the alloy content, the larger the diameter of wire or rod can be hardened through the entire section. Because...

Words: 1489 - Pages: 6

Premium Essay

Silent Spring

...English 101.11 4 October 2013 Rhetorical Analysis: Exigence: When Rachel Carson’s Silent Spring was published in September 27, 1962, it triggered a storm of disputes over the use of chemical pesticides. Her book helped raise awareness for the environment, warn humans of the dangers of using pesticides such as DDT, preserve several plant and animal species, and make the atmosphere cleaner. Her intent in writing Silent Spring was to warn the public of the dangers related with pesticide use. Throughout her book are countless case studies documenting the harmful effects that chemical pesticides have had on the environment. Along with these facts, she explains how in many occasions the pesticides have done more harm than good in eliminating the pests they were supposed to destroy. Carson points out that many of the long-term effects that these chemicals may have on the environment, as well as us humans, are still unknown in addition to her report. The argument in Carson’s Silent Spring led to the passing of environmental legislation and the establishment of government agencies to better regulate the use of these chemicals (Griswold 2012). Kairos: While working for the U.S. Bureau of Fisheries, Miss Carson first became aware of the effects of chemical pesticides on the natural environment. Her main concern was the government’s use of chemical pesticides such as DDT, a colorless substance used as an insecticide that is toxic to humans and animals when swallowed or absorbed...

Words: 1655 - Pages: 7

Premium Essay

Silent Spring Analysis

...Silent Spring Analysis Silent Spring is a book that makes just about everyone think, except for the major chemical companies that it was attacking. This is definitely one book that help shaped how we look at the environment today and also how we approach it. Rachel Carson aimed for a book that was going to open peoples eyes to what really was happening and who and what was doing it. She nailed this right on the head, while the book was very technical when it came to talking about the details of DDT, it was written at a level that everyone could understand and relate too. Easily this could be one of the most important books written in American history, where would we be without it and how would our future have turned out. While this book was aimed for the public to be able to understand, it also directly attacked the companies who were manufacturing the chemicals that people were using, especially DDT. If one were to try to explain how DDT worked at the chemistry level, most people would think your insane, but Carson is able to explain the devastating effects of this chemical in a way that everyone can understand. She does this by explaining the process chemically first, but then switches gears into how it is hitting people at home. This starts in the first chapter where she begins with “There once was a town…”. This is the beginning of the account that shaped Americans way of looking at the environment, especially when it came to using chemicals and other harmful substances...

Words: 1771 - Pages: 8

Free Essay

Silent Spring Ra

...Silent Spring RA Renowned biologist and author Rachel Carson, in her book, Silent Spring, describes a harmonic and beautiful town which experiences a plague over time. Carson’s purpose is to warn the world that if we continue to abuse the environment, we could very well end up like this town. She uses imagery and tone to convey that this can be the outcome of our actions. Throughout the text, Carson’s tone shifts from reminiscent and joyful to dark and lifeless to show that the people had caused this plague by abusing nature. Her tone is lively as she describes this town as a beautiful and harmonic place where life is flourishing.“THERE WAS ONCE a town in the heart of America where all life seemed to live in harmony with its surroundings.” Carson uses this joyful tone to convey the reader that this town truly was a place of beauty and life. As she concludes describing this beautiful town, her tone suddenly shifts. Her tone becomes dark and lifeless as she describes a “strange blight” that the town experienced. Carson explains how “Some evil spell had settled on the community… and there was a strange stillness.” She also explains how the people were confused as the plants, animals, and even some townspeople had died. Then, she explains how there was, “No witchcraft…. The people had done it themselves.” The people were confused as to why the town was withering away, however, they had abused the environment so much that they had caused this blight. This relates to...

Words: 525 - Pages: 3

Premium Essay

Rhetorical Analysis Of Silent Spring

...Hersheys bars. Cherrios. Coca cola drinks. All deadly delicious; every one of them loaded genetically manipulated ingredients that planted in a monocrop manner and sprayed with carcinogenic pesticides, causing a detrimental effect on the environment, biodiversity and the sustainability of all species--to the oblivion of many Americans. Biologist Rachel Carson reveals the consequences of similar poisons purging on the natural world in her book, Silent Spring, in which she uses a myriad of rhetorical strategies such as diction, syntax, and pathos in order to convey the gravity of Earth’s current situation to her readers. From the opening passage, Carson is quick to jump to the tone of the disgust when she immediately correlates the words...

Words: 534 - Pages: 3

Premium Essay

Silent Spring: An Effect On The Environment

...An Effect On the Environment I believe “Silent Spring” is inspiring people just because how bad the problem is. In the story “Silent Spring it is explaining how pesticides can be very dangerous. Not only does pesticides kill it hurts the environment and nature. These chemicals are very deadly to everything in range of it killing lots of things off. Animals, plants, and humans as well. For example, it killed off the town in “Silent Spring.” In paragraph three it states “A strange blight crept over the area and everything began to change.” This shows how sudden and quick the town changed and illness spreading. Along the roadsides vegetation was withered. There was also a strange stillness, showing how there are no more birds chirping. Everything...

Words: 340 - Pages: 2

Premium Essay

Catastrophic Crisis In Silent Spring By Rachel Carson

...Here on Earth many people are destroying our environment and that can cause dire situations. Our planet faces a potentially catastrophic crisis. As Rachel Carson explains in “Silent Spring,” we have been mistreating the Earth by carelessly using chemicals without knowing the possible repercussions. Her writing inspires us to take action before it is too late. To begin, animals can become extinct when we are not careful we can have many unwanted consequences. Carson states that when one chemical was used, it caused “no chicks to hatch.” The farmers complained that they were unable to raise any pigs the litters were too small and the young only survived for a few days. What she means is that the pesticides being used, stop the animals from growing. The farmers were both losing crops and animals just because of those pesticides. This should inspire us to take action because if certain animals become extinct, the entire ecosystem could fail. If the pesticides were never used these farmers wouldn;t be experiencing horrible things happening to their plants and animals....

Words: 492 - Pages: 2

Premium Essay

Silent Spring: A Journey To A Radical New World

...Silent Spring: A Journey to a Radical New World Synopsis Silent Spring, written by Rachel Carson, describes the catastrophic effects of humanity’s interference with nature. The novel focuses on the overuse of pesticides and the toxic contamination it can cause. Carson highlights the damage done to wildlife, livestock, domestic animals, and humans; at both a visible and molecular level. She explains the futility of chemical methods in controlling insects and gives examples of effective biological alternatives. This book was instrumental in banning the insecticide DDT, as well as in raising public awareness of environmental needs. Agreement with the author I agree with the majority of the opinions that Carson expresses, and particularly...

Words: 1339 - Pages: 6

Premium Essay

What Is The Use Of Pesticides In Rachel Carson's Silent Spring

...Silent Spring was written by Rachel Carson. It was published by Houghton Mifflin Harcourt Company in 1962, containing 378 pages. It’s a nonfiction book about widespread pesticides use and its dangers on both wildlife and humans. This book contains a lot of evidence about these serious charges for these pesticides and is recommended for anyone who is interested in the environment and is ready to take heed. This book is mainly about DDT and how it has caused damage to the plants, insects, birds, agricultural and domestic animals, and even humans. There are many examples from where communities are effected from the use of pesticides. The author was trying to raise important questions about human’s impact on nature with chemicals....

Words: 958 - Pages: 4

Premium Essay

Environmentally Historical Book Review: Silent Spring By Rachel Carson

...Keith Lyman Professor Patrick Welsh AMH2020 – 218620 21 October 2016 Rachel Carson’s Silent Spring Book Review In the environmentally historical book Silent Spring, by Rachel Carson, the horrific consequences of insecticide use on the environment and ecosystem are chronicled. Carson’s novel was originally published as a three-part journal article in the New Yorker in June followed by the publication of the book in September of 1962. The book is known for beginning the modern environmental movement, which eventually led to the banning of “the domestic production of DDT and the creation of a grass-roots movement demanding protection of the environment through state and federal regulations” (Carson/Lear 9). Carson used her widespread knowledge...

Words: 1221 - Pages: 5