Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
A High-Level View of Spring4:37 with Chris Ramacciotti
During this video, I'll give you an overview of what each part of the Spring Framework offers to us for developing web apps.
JavaBeans vs. Spring Beans
Spring beans typically adhere to the requirements of the JavaBean specification. Independent of Spring, a JavaBean is any object that meets the following requirements:
- has a public, default constructor,
- has fields that are accessed through public getters & setters, which follow the standard naming convention of getFieldName (or isFieldName for boolean fields) and setFieldName, and
In general, Spring beans follow this convention, except that Spring beans do not need to implement
In general, Spring beans are any object constructed and managed by the Spring Framework. Spring beans are the objects eligible for injection with the
@Autowired annotation, as you'll see later in the course.
[MUSIC] 0:00 Writing a Java application that can run on a web server is tricky business. 0:04 This is where the Spring frame works swoops in to save the day. 0:08 In the last stage, I mentioned that crafting a response to a browser request 0:12 to the web server would be the job of our application, and 0:16 it is this very application that we'll be talking about and creating. 0:20 That is, we'll be using the Spring Framework to write the Java code necessary 0:24 to respond to requests that come to GIFLIB. 0:28 The entire Spring Framework consists of many different components, 0:32 some of which we won't be using in this course. 0:35 And what is a component exactly? 0:38 A component is simply a set of related functionality that, 0:41 in the case of Spring, resides in a JAR file of its own. 0:45 With that said, let's take a look at the components that we'll be using, and 0:48 see how they'll help us accomplish the task of writing a Web application. 0:52 The core component contains lots of the gears that turn the spring engine. 0:56 Most of the classes you won't directly use, 1:00 even though it's all being used by other pieces of the spring framework. 1:03 The beans component is the part of the spring framework that allows 1:07 any Java object to be created and used in what's called the Servlet Container, 1:10 which is the container of your entire running application on the web server. 1:15 You want to use all that object-oriented business you've learned in previous 1:20 Treehouse courses, right? 1:23 Well, the beans component will load your objects in a way that makes them usable, 1:25 and even reusable, while your application is up and running on the web server. 1:30 Those objects are called beans. 1:34 All right, cool beans. 1:37 [SOUND] In addition to other functionality, 1:38 the Context Component gives us a bunch of annotations that will leverage in 1:40 configuring our application including, the Configuration Annotation 1:45 which will apply to classes that application configuration code, 1:49 the Controller Annotation which will be applied to a class that we write to handle 1:53 requests to specific URIs, and the ComponentScan annotation, which will tell 1:58 the spring framework to scan our Java classes for things like controllers. 2:03 SpEL stands for Spring Expression Language, and is a language that we'll 2:07 put to use in our HTML templates that will allow us to iterate over, 2:12 perform operations with, and format Java data for display. 2:17 AOP stands for Aspect-Oriented Programming, this component allows us to 2:22 cleanly apply functionality to many, or all parts of our web application. 2:27 Such as adding a security check to verify that a user is logged-in before performing 2:31 certain tasks like uploading new GIFs, or marking or unmarking GIFs as favorites. 2:36 Now on to the web container starting with the servlet component. 2:42 If you remember in the first stage we used cradle to download the spring web mvc 2:47 library, in fact what spring web mvc refers to is the servlet component, it is 2:51 this component that contains a key player in the functioning of our web application. 2:58 What is this key player? 3:03 It's called a Dispatcher Servlet. 3:05 Think of the Dispatcher Servlet as our application's usher, 3:08 who is there to receive requests from the web server, and usher or 3:12 dispatch them according to our configuration and code. 3:15 When our code is done processing the request, 3:19 the dispatcher servlet ushers the response to the door, 3:22 handing it back to the web server to send it back to the client. 3:25 [SOUND] Finally, there's the web component, from which we'll get 3:28 the ability to capture a request to a specific resource and 3:33 take action accordingly. 3:37 For example, in our GIFLib application, a visitor might click on a navigation link 3:39 for categories, the URI for which we could capture, 3:43 then respond with the page that shows them all the categories. 3:47 Or from the homepage, they could click on a specific GIF, the URI for 3:51 which we could capture and then respond with the page that shows 3:55 all the details for that GIF, including the date uploaded, and a sharable URL. 3:59 [SOUND] That's a lot of information. 4:05 I realize at this point that discussing the organization of this 4:08 powerful framework might seem a bit abstract and confusing now. 4:11 Don't worry, we'll continue to revisit these components as we use each of them. 4:16 And, kind of like your favorite coding books, or 4:20 bookmarked websites, feel free to come back to this video and rewatch. 4:23 Next, we'll look at how exactly we're going to use Java code 4:28 to incorporate the components of the spring framework into our application. 4:32
You need to sign up for Treehouse in order to download course files.Sign up