Home » Tag Archives: CDI (page 3)

Tag Archives: CDI

Java EE CDI dependency disambiguation example

java-logo

In this tutorial we shall show you how to avoid dependency disambiguation in CDI beans. In CDI we can achieve dependency injection for multiple implementations of an interface to different clients in an application. The problem of dependency disambiguation is how a client can call a specific implementation among different ones, without any errors occurring. To see how we can ...

Read More »

Java EE CDI Dependency Injection (@Inject) tutorial

java-interview-questions-answers

In this tutorial we shall show you how to achieve Dependency Injection in CDI managed Beans. In particular, we shall make use of the @Inject annotation provided by the CDI API to inject a CDI bean to another bean. In this way the bean can be used in an application, such as a JavaServer Faces application. CDI provides several ways ...

Read More »

Asynchronous CDI Events

java-logo

Few days ago, during our regular code review, one of my colleagues raised a question what would happen — and if it’s even possible — when a CDI Observer (so a method with parameter annotated @Observes) would be invoked multiple times at the same time for different event instances. In other words, after producing few events, is it possible that ...

Read More »

Java EE CDI Disposer methods example

java-logo

This is a tutorial of CDI Disposer methods. In CDI, since a Producer method generates an object that can then be injected in an application, the Disposer method is used so that the object is removed when its work is completed. A Disposer method is always matched to a Producer method. An example of the Disposer method use is when ...

Read More »

Java EE CDI Producer methods tutorial

java-interview-questions-answers

This is a tutorial of CDI Producer methods. In CDI, a Producer method generates an object that can then be injected. Producer methods can be used when we want to inject an object that is not itself a bean, when the concrete type of the object to be injected may vary at runtime, or when the object requires some custom ...

Read More »

Java EE CDI ConversationScoped example

java-interview-questions-answers

In this tutorial we shall show you how to create and use a ConversationScoped Bean in a web application. In CDI, a bean is a source of contextual objects that define application state and/or logic. A Java EE component is a bean if the lifecycle of its instances may be managed by the container according to the lifecycle context model ...

Read More »

Java EE CDI bean scopes

java-interview-questions-answers

Contexts and Dependency Injection (CDI) for the Java EE platform is a feature that helps to bind together the web tier and the transactional tier of the Java EE platform. CDI is a set of services that, used together, make it easy for developers to use enterprise beans along with JavaServer Faces technology in web applications. In CDI, a bean ...

Read More »

JSF – Eager CDI beans

jsf-logo

Everybody knows eager managed beans in JSF 2. @ManagedBean has an eager attribute. If eager=’true’ and the scope is application, then this bean must be created when the application starts and not during the first reference to the bean. This is a nice feature when you want to load application scoped data (e.g. some select items for menus) during application ...

Read More »

Custom error pages for expired conversations involving CDI and JSF

jsf-logo

It’s been a while since I last blogged. I keep thinking of blogging something technical but end up getting busy with other things. This last week there was a very interesting discussion at the coderanch forums. It was even more interesting because it involved JBoss. Developers familiar with Java EE web applications would know that the web application deployment descriptor ...

Read More »

Configure timeout for CDI conversations

apache-myfaces-logo

CDI conversation scope is a nice feature when developing JSF applications. Imagine you have large data tables which take a long time to be loaded. You normally don’t want to place the loaded data in session scoped beans by reason of high memory consumption. And you can’t place the loaded data in view scoped beans because you wouldn’t like always ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials