From the course: Java EE 8 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Scopes

Scopes - Java EE Tutorial

From the course: Java EE 8 Essential Training

Start my 1-month free trial

Scopes

- [Instructor] When using CDI, it is important to understand the concept of scopes. Scopes allows us to associate a bean with a context which determines the visibility of the bean and helps manage its lifecycle. The default scope for a bean is dependent. Since we have not provided a scope for our LocalInventoryService bean, it is dependent scope and will assume the scope of the bean it is injected into. So if we take a look at our CatalogItemFormbean where we are injecting our inventoryService, you'll notice that it is SessionScoped and that will cause our inventoryService to be SessionScoped as well. Now, we can see this in action if we open the application in two browsers. So let me just expand our console and then we're going to go ahead and enter a product into our application running in Internet Explorer. So we'll use Gloves and we'll say it's produced by SuperGloves and then provide a date and then just a…

Contents