Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

"..EJB must not attempt to define a class in a package"

 
Ryan Fernandes
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the programming restrictions goes like this:
"The enterprise bean must not attempt to define a class in a package."
Maybe I'm reading it wrong but I have no clue what this means!
Can anyone explain this to me, please?
Many thanks,
Ryan
[ January 09, 2004: Message edited by: Ryan Fernandes ]
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only thing I can think of is that the spec is saying you can't do what JSP containers do... generate classes on the fly. If that were the rationale it would make some sense; it could be hard for a container to know what to undeploy if you were dynamically generating stuff. Could also make it hard for a container to manage class loaders.
[ January 14, 2004: Message edited by: Reid M. Pinchback ]
 
Keith Rosenfield
Ranch Hand
Posts: 277
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Ryan,
Funny thing. I read the spec in its entirety and finished yesterday. That restriction is towards the end of the spec, and when I read the restriction I said to myself "What the heck does that mean?"
Reid, I appreciate your effort to clear things up but I have to say that I am just a confused as ever. Maybe you could explain it so that a dummy like me can understand it.
Does any one else have any ideas?
Thanks,
[ January 14, 2004: Message edited by: Keith Rosenfield ]
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Keith, no problemo. I haven't yet read the EJB spec carefully yet, so I'm definitely just tossing out an educated guess here.
A JSP container typically compiles JSP pages into java classes - specifically, into classes that extend HttpServlet. When you deploy a web application, each time a JSP page is hit for the first time by some user, the container dynamically generates a servlet .class file. Some JSP (emphasis, "JSP", not "EJB") containers allow you to specify the package those classes are generated within.
If you futz around enough with class loaders and resource I/O, you can sometimes find a way to write read and files via any location. I'm just raising the hypothesis that the EJB spec writers were trying to say "don't do it, because we aren't going to standardize whether or not it would work in a portable manner". Imagine how ugly it would be for container vendors if a public bean method could dynamically spawn helper classes to do stuff the container didn't know about when the ejb-jar was deployed!
[ January 15, 2004: Message edited by: Reid M. Pinchback ]
 
calvin zhu
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please look this thread, I think it answers the question.
http://www.coderanch.com/t/158164/java-EJB-SCBCD/certification/EJB-spec
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That reason makes more sense than my guess.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic