Win a copy of Terraform in Action this week in the Cloud forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

POJO + XDoclet -> DI (Dependency Injection)

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am adding xDoclet attributes to the POJO class. Is it like injecting dependency(DI) to the base code ?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No.
 
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:No.



Why?
 
Sheriff
Posts: 67601
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because it isn't. That's like asking "why isn't an apple blue?"
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bear Bibeault wrote:Because it isn't. That's like asking "why isn't an apple blue?"



That answer was a bit short or not? Now Bear maybe you can explain why we can't call it DI
 
Bear Bibeault
Sheriff
Posts: 67601
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because it's not blue.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DI is about how and where implementation dependencies are specified. XDoclet is about source code generation based on Javadoc tags.

If you were really perverse you could probably use XDoclet to implement DI and play unhealthy games with in-process compilation/loading.

So POJO + XDoclet = POJO + a bunch of generated source code, which could be used reasonably, or abused horribly--perhaps giving you a form of DI, but probably by accident.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:DI is about how and where implementation dependencies are specified. XDoclet is about source code generation based on Javadoc tags.

If you were really perverse you could probably use XDoclet to implement DI and play unhealthy games with in-process compilation/loading.

So POJO + XDoclet = POJO + a bunch of generated source code, which could be used reasonably, or abused horribly--perhaps giving you a form of DI, but probably by accident.



Thanks David for giving a better explanation than just No.

Do you agree with me that POJO and XDoclet is the way we used to annotate our POJO classes before the @ annotation era?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darya Akbari wrote:Thanks David for giving a better explanation than just No.


Like Bear said--you're comparing very different things. It's either a short answer to your specific question, or several paragraphs explaining things you either already know, or can learn on your own. Since you provided no information about what you know, why you were asking the question, or why you believe(d) they're equivalent, I gave the short answer rather than basically cut-and-pasting the definition of XDoclet and DI.

Do you agree with me that POJO and XDoclet is the way we used to annotate our POJO classes before the @ annotation era?


Not really, but it depends on the definition of "annotate" you're using: XDoclet tags are *an* annotation ("a note; a comment or instruction"), but not a *Java* annotation ("source-based syntactic metadata"). XDoclet tags and Java annotations behave differently, have different lifespans, etc. One's intention is to generate source code from XDoclet Javadoc tags, one's is to provide runtime information to the JVM, a library, etc.

How about this approach: tell us what you think DI is and how you use it, tell us what you think XDoclet is and how you use it, and finally tell us what (Java) annotations are and how you use them.

(Sometimes just the act of explaining something to someone else is enough to deepen the understanding, so we all win--we find out how we can best help you based on what you know, and you solidify your understanding of the things you're asking about. Plus it means you've gone to the trouble to ShowSomeEffort, which makes us more likely to do more than answer your specific question.)
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:It's either a short answer to your specific question, or several paragraphs explaining things you either already know, or can learn on your own. Since you provided no information about what you know, why you were asking the question, or why you believe(d) they're equivalent, I gave the short answer rather than basically cut-and-pasting the definition of XDoclet and DI.



I'm not the original one who put that question forward. The question is good but the answer No was disappointing. Now your all other answers are much more informative than your first one.

Actually your No is absolutely correct if we go by the letter of law. However as the question implicites the terms POJO, XDoclet and Dependency Injection can be in a relationship. I've seen them together with Java EE 5. Since Java EE 5, XDoclet became obsolete and we use Java Annotations instead and let the EE containers do the injection at runtime.

So in that case I don't go by the letter of law but by the spirit of law and would answer kri shan's question with Yes.

 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Darya Akbari wrote:However as the question implicites the terms POJO, XDoclet and Dependency Injection can be in a relationship. I've seen them together with Java EE 5. Since Java EE 5, XDoclet became obsolete and we use Java Annotations instead and let the EE containers do the injection at runtime.


But XDoclet was creating descriptor files, remote/home interfaces, and so on. I don't really see that it was doing the same work as DI in any meaningful way--maybe you could explain how they're similar, since I don't see it.
 
Darya Akbari
Ranch Hand
Posts: 1855
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

David Newton wrote:

Darya Akbari wrote:However as the question implicites the terms POJO, XDoclet and Dependency Injection can be in a relationship. I've seen them together with Java EE 5. Since Java EE 5, XDoclet became obsolete and we use Java Annotations instead and let the EE containers do the injection at runtime.


But XDoclet was creating descriptor files, remote/home interfaces, and so on. I don't really see that it was doing the same work as DI in any meaningful way--maybe you could explain how they're similar, since I don't see it.



I think we should ask kri first whether he had Java EE in mind or not.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure that it matters if it's EE or not--I just want to understand your, or the original poster's, reasoning behind believing they're equivalent--all I need is a DI example using XDoclet. I used it only briefly for a very narrow range of tasks--it could very well be that they *are* the same. But without an example, I don't see it.

Unless we're talking about some sort of "compile-time dependency injection" where implementations are decided at compile time--I'd concede it meets the requirements to be called "dependency injection", but I don't think that's what most people would think of first.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic