About the CDI Web Project

Asked 1 years ago, Updated 1 years ago, 47 views

It's very vague, but let me ask you a question.I was just told to study CDI, and I'm busy doing my own thing, but violently?To put it bluntly, is it like a framework that extends the technology of Servlet & JSP?

"Select ""CDI Web Project"" from Eclipse, and just move the entire program created by Servlet and JSP to work normally, but is the point still to use annotations and xml?"Also, would you like to replace the JSP file with XHTML?

I've personally touched on the framework (Spring, Struts) and I've gradually taken various elements from the technology of the servlet...but I got the impression that it doesn't look like any of them.

I'm sorry.Let me clarify my question.

J Is it an XHTML file because you cannot enjoy the flavor of the JSP file?Can't I use JSP?

Ser Is it correct to understand that the servlet class exists and that the model in MVC is now called Bean?

要In short, is it the biggest advantage (scope management) to be able to handle Servlet & JSP's things that I put out in the scope every time I had to do it more easily?

It may be difficult to answer (or because I am too ignorant to answer the question itself) because I cannot tell you the situation and what I study for, but I would appreciate it if you could answer if you have ever used it.

Thank you for your cooperation.

java

2022-09-30 21:38

3 Answers

To put it bluntly, is it like a framework that extends the technology of Servlet & JSP?

No, but maybe that's a good idea at first.
The Contexts and Dependency Injection for the Java EE Platform (CDI) is one of the standard specifications of Java EE, which is very simply a feature specification that provides a scope-specific dependency injection (DI).

Java EE is a standard specification collection that summarizes the capabilities for developing enterprise applications ( Webweb applications) in Java.Therefore, CDI is exactly a specification and has no substance.Implementing this specification will enable CDI functionality.This is actually implemented by WildFly, such as Weld.

CDI is adopted from Java EE 6, but Java EE also has a "Dependency Injection for Java" specification in addition to CDI.The main purpose of both is DI, but I think the difference is that you can specify the scope you want to manage.

Are the key points still the use of annotations and xml?

We use annotations and xml for definitions, but that's not the point, I think the point is DI.So, I think you should start with the concept of DI.

Also, would you like to replace the JSP file with XHTML?

No.
The CDI specifications can be found below, but they do not mention replacing it with XHTML.

https://download.oracle.com/otn-pub/jcp/cdi-1_1-fr-eval-spec/cdi-spec.pdf

J Is it an XHTML file because you cannot enjoy the flavor of the JSP file?Can't I use JSP?

XHTML is not directly related to CDI, so please forget about it.

Ser Is it correct to understand that the servlet class exists and that the model in MVC is now called Bean?

No, it's not.

要In short, is it the biggest advantage (scope management) to be able to handle Servlet & JSP's things that I put out in the scope every time I had to do it more easily?

Hmm. I don't know if it's wrong, but... I've listed the pages below that might be helpful, so please study them.

[Reference]
Getting Started with JavaEE7 (10) - CDI Overview
http://enterprisegeeks.hatenablog.com/entry/2015/06/08/072843

Touch the CDI, one of the most convenient features in JavaEE
https://cloudear.jp/blog/?p=1945

Qiita-JavaEE Usage Notes (CDI)
https://qiita.com/opengl-8080/items/431de9175dca33a09ba8


2022-09-30 21:38

The CDI Web Project generated from the Eclipse wizard (more precisely the JBoss Tools plug-in in Eclipse) also defaults to Java Server Faces (JSF).
Enter a description of the image here
In addition to the CDI, there are other questions that you might think are related to JSF (the XHTML file is probably called JSF).
I don't know much about JSF, so I will focus on CDI and try to answer.

I've personally touched on the framework (Spring, Struts) and I've gradually taken various elements from the technology of the servlet...but I got the impression that it doesn't look like any of them.

CDI is like @Component and @Autowired as we call it in Spring.
The fact that they don't look alike is probably the part of JSF.

J Is it an XHTML file because you cannot enjoy the flavor of the JSP file?Can't I use JSP?

JSF is not required to use CDI. CDI and JSP can also be combined.In this case, the XHTML file does not appear.

Ser Is it correct to understand that the servlet class exists and that the model in MVC is now called Bean?

That's right. When using a combination of servlet and CDI, most of them are C->Servlet, M->CDI Bean (V is JSP or JSF).

要In short, is it the biggest advantage (scope management) to be able to handle Servlet & JSP's things that I put out in the scope every time I had to do it more easily?

It's easier to get in and out of scope objects, but I think it's mainly because EJB is no longer required for model implementation.

Note: How to distinguish between CDI and EJB - Stack overflow

If you want to learn about CDI, you should read the documentation for Weld which is the de facto standard implementation.
spec itself is not that difficult.
Also, I have the impression that there are many people (around JavaEE) who write explanations in Japanese such as Qiita (so I think there are many things you can get by googling).


2022-09-30 21:38

CDI is part of the Java EE framework.

Is it like a tool that specifies the Context スコープ scope by annotation instead of implementing it by Dependency Injection= code?(Maybe not at all...)

xhtml is irrelevant.
I think it's the model of MVC.The architecture of the server site Java is the business logic layer.However, since CDI has a wide range of use, it seems to be connected to other areas such as the presentation layer.
Please refer to https://builder.japan.zdnet.com/sp_oracle/35079781/

The CDI container ( アプリケーション application server) manages the scope, so you don't have to generate it in new, and you can automatically discard it after the specified scope.

Other benefits include easy scope changes and resource benefits as they are automatically discarded.

I have the impression that it was created to avoid problems with EJB within the framework of JavaEE, but if you look into JavaEE, you may see from a bird's-eye view that CDI is not a good idea.


2022-09-30 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.