« Top 5 Posts Of Novem... |
Main
| Java EE 6 And The... »
What Is The Relation Between JSR-299 and JSR-330 In Java EE 6? Do We Need Two DI APIs?
There was/is a lot of confusion, as JSR-330 (Dependency Injection for Java) led by Rod Johnson (SpringSource) and Bob Lee (Google Inc.) became a part of Java EE 6. JSR-330 is very simplistic. It comes with own few annotations from the package: javax.inject
. The package contains the following elements: Inject, Qualifier,
Scope, Singleton, Named
and Pro
vider
. Its the definition of the basic dependency injection semantics.
JSR-299 (Java Contexts and Dependency Injection), with Gavin King as lead, uses JSR-330 as base and enhances it significantly with modularization, cross cutting aspects (decorators, interceptors), custom scopes, or type safe injection capabilities. JSR-299 is layered on top of JSR-330.
It is amusing to see that the built-in qualifier @Named
is not recommended and should be used only for integration with legacy code:
"The use of @Named as an injection point qualifier is not recommended, except in the case of integration with legacy code that uses string-based names to identify beans."
[3.11 The qualifier @Named at injection points, JSR-299 Spec, Page 32]
The relation between JSR-299 and JSR-330 is comparable to the relation between JPA and JDBC. JPA uses internally JDBC, but you can still use JDBC without JPA. In Java EE 6 you can just use JSR-330 for basic stuff, and enhance it on demand with JSR-299. There is almost no overlap in the practice. You can even mix JSR-299 / JSR-330 with EJB 3.1 - to streamline your application.
dam Bien,
| Views/Hits: 1469
NEW live, virtual workshops: Persistence Patterns for Serverless Java on AWS, July, 11th, 2024 and Serverless Generative AI with Java on AWS, July, 18th are open for registration. Also via: meetup.com/airhacks
>500 Java Shorts Daily www.youtube.com/bienadam/shorts
airhacks.fm the podcast: ![](https://adam-bien.com/images/apple_podcast_listen.svg)
You are invited to: airhacks discord server.
Stay in touch: airhacks.news.
Comments:
When voting No in Final Approval Ballot for both JSRs IBM left comments like "The current state of JSRs 330 and 299 do not provide a single extensible programming model.", and "The current lack of portability between JSR 330 and JSR 299 applications will create significant difficulties for the community.".
Their further comments like "..applications written for SE will require a porting effort to run them in an EE environment.." and "Application developers ... will experience integration issues" sound scary too.
Was/is IBM wrong?
Posted by
Stevo Slavic
on January 07, 2010 at 03:45 PM CET
#
Hi Stevo,
look at the JSR-330 RI - it shows what is needed to run JSR-330 outside the container. JSR-299 comes with a lot more functionality, so you will need a kind of container outside - so there is more effort. I was not a part of the JSR-299/330 EG - so it is hard for me to explain the statement. Right now I see no issues for an average enterprise project. I guess IBM wrote the comment from the application server-provider perspective...
thanks for your comment!,
adam
Posted by
Adam Bien
on January 07, 2010 at 04:48 PM CET
#
Just to clarify, @Named should not be used as "an injection point qualifier" meaning that you shouldn't match injection points with beans based on name. You should instead use type safe annotations for qualifiers instead of string based names.
However, @Named is very relevant and should be used for naming beans for access using EL such as with JSF.
The 'legacy' thing is probably referring to the Spring and Seam practice of naming beans and binding injectables with injection points by name instead of the new CDI way of type safe matching.
Posted by
Andy Gibson
on January 07, 2010 at 06:40 PM CET
#
@Andy,
exactly - I used @Named for EL also in the sample mentioned in the post (http://www.adam-bien.com/roller/abien/entry/ejb_3_1_killed_the). It is nothing legacy about the EL.
In Java EE 6, however, injection can be qualified in type-safe manner. @Named works with String-matching.
Thanks for the clarification!,
adam
Posted by
Adam Bien
on January 07, 2010 at 08:10 PM CET
#
Post a Comment:
Number of posts: 2438
Number of comments: 6163
Yesterday's hits: 20409
Today's hits: 2128
Post reads / hour: 649
Top posts:
about.adam-bien.com
blog archives
...the last 150 posts
Project Valhalla: Value Types, Nullability and Float16--airhacks.fm podcast
OpenRewrite: Transforming Java Code at Scale--airhacks.fm podcast
Interviewed by a Recruiter: "Java and AWS Cloud: Building Scalable Enterprise Solutions"
Dying Java DBs, EJB Migrations, Kubernetes, Serverless Java, Maven, Gradle, Native Images--Questions for 124th airhacks.tv
JVector: Cutting-Edge Vector Search in Java--airhacks.fm podcast
Object-Oriented Programming (OOP) vs. Data-Oriented Programming (DOP) in Java--airhacks.fm podcast
From JSP to Rife and From Kotlin to Java--airhacks.fm podcast
Live from JCON Europe 2024: "Serverless Java #slideless"
The bld Power User--airhacks.fm podcast
Lambda Communication, EDAs, Step Functions and llama--Questions for 123rd airhacks.tv
Observability-Driven Development with Digma, Serverless and Java--airhacks.fm podcast
Exploring ONNX, Embedding Models, and Retrieval Augmented Generation (RAG) with Langchain4j--airhacks.fm podcast
High-Performance Java, Or How JVector Happened--airhacks.fm podcast
Modern Java in the Cloud or OnPrem--BaselOne Keynote
LLama2.java: LLM integration with A 100% Pure Java file--airhacks.fm podcast
Serverless Java with Quarkus, Parallel Streams, and Epsilon GC--122nd airhacks.tv
Serverless Java, Lambda Load Balancer, Serializable--Questions for 122st airhacks.tv
How Kotlin Happened--airhacks.fm podcast
How Azul Happened--airhacks.fm podcast
Pure Java AI--airhacks.fm podcast
How to Quickly Switch Between JDKs Without Tools
How OpenRewrite Happened--airhacks.fm podcast
bld vs. Apache Maven--Or Pure Java vs. XML
bld: The Hypersonic Java Build Tool
Spring / Summer 2024 Conferences, Events and Workshops
Java 22, System Tests, Applets, 500 Java Shorts--Questions for 121st airhacks.tv
Underscore, Pattern Matching, Java LTS And When Previews Are Stable--airhacks.fm podcast
Integrating AI with Java: Quarkus and Langchain4j--airhacks.fm podcast
How Linkblog Happened--airhacks.fm podcast
A Better JNI: Project Panama--airhacks.fm podcast
How LangChain4j Happened--airhacks.fm podcast
Framework-less,Real World Java EE (Patterns) in 2024, VSCode and Java, Kubernetes Platform, Session Management--Questions for 120th airhacks.tv
No Dependencies--Or How Rife 2 and Bld Happened--airhacks.fm podcast
From Hexagonal Architectures to Data Oriented Programming--airhacks.fm podcast
TornadoVM, Paravox.ai: Java, AI, LLMs and Hardware Acceleration--airhacks.fm podcast
Java and eBPF--airhacks.fm podcast
OIDC, WASM, Java as Windows Service, Secrets Management, Authentication, Eclipse Store, Event Bridge--119th airhacks.tv
WASM, Java as Windows Service, Uncanny Valley, Secrets Management, Authentication, Staging--Questions for 119th airhacks.tv
Virtual Threads and Scoped Values with Jose--airhacks.fm podcast
Java, Continuations and How Rife Happened--airhacks.fm podcast
First Events and Conferences in 2024
Java at Azul: The Interesting Features--airhacks.fm podcast
Project Babylon--airhacks.fm podcast
Java and Gaming, Optionals, Paper Engine vs. Spigot, ESBs--118th airhacks.tv
A Compiler Nerd Builds a Tiny Profiler--airhacks.fm podcast
A Helidon Conversation--airhacks.fm podcast
Work Smart, Take Responsibility and Xmas in Brazil--airhacks.fm podcast
The Long Road to Java and Kotlin--airhacks.fm Podcast
Minecraft Influenced JSON-B Design--airhacks.fm podcast
From Image Recognition to CoffeCast--airhacks.fm podcast
Lambda Monoliths, Hypermedia Systems, Java Template Engine, Snapstart and CraC--117th airhacks.tv
JUG Vienna, Ya!vaConf, airhacks.tv and Airhacks Workshops
Not Injectable Principals, Quarkus, MicroProfile and Smallrye--airhacks.fm podcast
Why Kotlin is Better Than Java--airhacks.fm podcast
How Han Solo wrote SteelSeries--airhacks.fm podcast
Late 2023 JUGs, Workshops and Conferences
M2M Authentication, Quarkus and CraC, OIDC--or Questions for the 116th airhacks.tv
Money API, Virtual Threads, Jakarta Data, Lambdas, Dynamo--115th airhacks.tv
Instrumenting, Probing and Asynchronous Profiling--airhacks.fm podcast
Java, Microsoft and Software Development with AI--airhacks.fm podcast
How JProfiler Happened--airhacks.fm podcast
Profilers, Probing, Sampling and Instrumentation--airhacks.fm podcast
How JAX-RS Happened--airhacks.fm podcast
Devoxx Belgium: Java Patterns and Practices for Serverless Applications
Money, Authentication, Formatters, Jakarta Data, Serverless, ULIDs, Events--Or Questions for 115th airhacks.tv
The IBM Certified Presenter and XML Evangelist--airhacks.fm podcast
JCON Europe Cologne 2023: "Serverless" Is What J2EE Was Meant To Be
JAX-RS, OAuth, OpenID Connect (OIDC), Authentication, Authorization and Quarkus--airhacks.fm podcast
Autumn 2023: Upcoming Java Conferences, Java User Group Events and Online Workshops
How BTrace Happened--airhacks.fm podcast
How Boundary Control Entity, UML and Components Happened--airhacks.fm podcast
Cloud Native CI/CD, Trunk Based Development, Sockets, Cloud Test Stacks, Test Data, XA, Handling Exceptions--Or 114th airhacks.tv
How FlywayDB Happened--airhacks.fm Podcast
Why MicroStream is Faster--airhacks.fm podcast
Virtual Threads, Parallel Streams, Concurrency and Parallelism--airhacks.fm podcast
A Deeper Dive Into Debugging--airhacks.fm podcast
How JavaPolis and Devoxx Happened--airhacks.fm podcast
Real World BCE, Modularization, Jigsaw, BPMN, Minio Integration, Schema Evolution--Or 113th airhacks.tv
Java on Azure and a Nailless Java Champion--airhacks.fm podcast
BDD: Bug Driven Development vs. Continuous Observability--airhacks.fm podcast
From CORBA, over RPC to REST ...and Back?--airhacks.fm podcast
FPGAs, GPUs or Data Science with Java--airhacks.fm podcast
A Freakonomic Guide to Jakarta EE with a Guardian--airhacks.fm podcast
Break Your Limits and the Java Challengers--airhacks.fm podcast
A Gentle Introduction to Debugging--airhacks.fm podcast
How Log4j, SLF4j, Jakarta Commons Logging, Logback and Reload4j Happened--airhacks.fm podcast
From OpenShift to Azure App Service--airhacks.fm podcast
Java EE 6: Migration: From Application Servers over MicroProfile to Serverless AWS Lambda
Monoliths, Microservices, Auth, API Gateways, Schedulers-111th airhacks.tv
The Reset Boy--airhacks.fm podcast
Microservices vs. Monoliths, Schedulers, Lightweight vs. Heavyweight, Time Derived Properties, Groovy, JavaScript--Or 111th airhacks.tv
Understanding and Practising Quarkus--an airhacks.fm podcast
2023 Spring / Summer: Upcoming Conferences, Streams and Workshops
Java FX, Codename One, Swing, Flutter and a Bit Android--airhacks.fm podcast
Simplicity is a Good Incentive--airhacks.fm podcast
Reactive programming, 12factors, gRPC,SPAs, openJDK choices--Questions for 110th airhacks.tv
Serverless Java (17) on AWS--airhacks.fm podcast
Low-Code, No-Code with Java--airhacks.fm podcast
The History of Mobile Java and Codename One--airhacks.fm podcast
Hooked on Java--airhacks.fm podcast
...the last 10 comments
Aldo Lushkja wrote:
Thanks Adam to you reply on 88th Airhacks TV to this question, migrating to Quarkus 2+ version solved the issue.
Only this little change was [...]
Aldo Lushkja wrote:
Hi Adam,
i've tried what you have done in your video, but no test was executed.
I've download the mocked project and launch the[...]
Ananth Raghuraman wrote:
I am a fan of your blog!
Is Netbeans even used anymore (outside of Oracle or their non-IT customers)?
I know several people are [...]
Kevin Farnham wrote:
Amazingly, strings are a problem throughout so many languages, C, C++, Java, Python... How could something so simple as a bunch of characters repr[...]
David Kant wrote:
Thanks for this really useful post. The activemq-cli is a great tool for testing JMX on the local server.
I was able to get the rmohr/act[...]
Arend v. Reinersdorff wrote:
An option without hardcoding src/test/resources:
try (InputStream inputStream = ReadResourceTest.class.getResourceAsStream("test.fil[...]
Christian Stein wrote:
"It is recommended to obtain a Path via the Path.of methods instead of via the get methods defined in this class as this class may be depreca[...]
Simplifier wrote:
Too many lines of code for such a simple thing.
wrote:
I think `Path.of` is preferred to `Paths.get`
Pao wrote:
can you give an example of how to test click a radio button and also clicking the submit button on the form?
License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 2.0 License.