Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java EE - who implement the specification? [duplicate]

I have some experience in core Java and Java EE. I read the various question on SO to understand what exactly Java EE is? And few answers in SO are: what-exactly-is-java-ee , what-is-java-ee

I have some doubts:

1) If Java EE is just a specification, who does implement them? Do Application Servers (like JBOSS, GlassFish) implement these specifications?

2) If I am correct the EJB specification is implemented by EJB container, and I believe EJB Container is part of Application Server. Now, when we as developers write an EJB code, what are we actually doing? The doubt I have is, EJB container implements the EJB specification, so are we overriding some "specification part" of the EJB? How come, some part of EJB is implemented by the EJB container and some thing which developers are writing? OR is it that some part of the EJB have to be provided by EJB container and some part to be developed by developers? I am having difficulty in undestanding this.

Please can anyone help in understanding this?

like image 542
CuriousMind Avatar asked Jun 23 '16 06:06

CuriousMind


Video Answer


3 Answers

Anybody can implement the java ee specification (JSR342), or any jsr that's part of it. When they do, they can (after buying and passing Compatibility Test Suite) claim to be compatible with the specification. There is a number of vendors with their application servers which are compatible with java ee, but no vendor implement full java ee specification. For instance, glassfish (the java ee reference implementation) uses Red Hat's CDI implementation. Sometimes, the vendor does not implement any part of the java ee specification, they grab glassfish, add their vendor specific libraries, and release it under their name. To claim compatibility, they still need to go through the certification process and run CTS.

To find out all the vendors who implement the specification is not so easy, since not all of them go through the certification process. For instance, Apache CXF is not certified on its own, rather it gets certified as part of Red Hat's JBoss.

Each specification has an API and a written pdf, both of which define the mandatory behaviour of each implementation. That is what you use when write EJB code. For instance, when you create an ejb:

import javax.ejb.Singleton;
@Singleton
public class MySingleton{
   ... 
}

@Singleton annotation is part of the specification, but MySingleton class is your EJB code, it's not part of the specification. The EJB container then knows what to do with the class.

like image 157
jan.supol Avatar answered Oct 26 '22 17:10

jan.supol


In Java specifications' cases (Java EE, JSF, other JSRs) you usually have a reference implementation created while drafting the spec (Glassfish in case of Java EE), then you have other providers who may create their own implementation of the spec (often claiming it's "better" in some way).

You as a developer then write code that can use the facilities provided by the spec, which would run correctly on any compliant implementation.

like image 20
Kayaman Avatar answered Oct 26 '22 16:10

Kayaman


Yes, EJB container (application server) vendors like RedHat implement the J2EE specification in their products (like JBoss).

What they don't do is implement any business logic (just the "plumbing" if you will). That is where application developers come in.

Just like Apache HTTPD or nginx implement the HTTP protocol specification, but that does not a website make.

like image 33
Thilo Avatar answered Oct 26 '22 18:10

Thilo