File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

package and class question

 
MaxPwr Pow
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
one of the EJB restriction is
"EJB must not attempt to define a class
in a package". What does this mean?
Does that mean we can't do this:-
package myPackage;
import ...
public class MyBean implements SessionBean{
:
:
}
that doesn't sound right, does it?
 
Weerawit Maneepongsawat
Ranch Hand
Posts: 203
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is in section 24.1.2 Programming restrictions
but i don't know why..

� The enterprise bean must not attempt to define a class in a package.
This function is reserved for the EJB Container. Allowing the enterprise bean to perform this function

Help me too...Thank you
 
Sudhir V
Ranch Hand
Posts: 143
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.theserverside.com/discussions/thread.tss?thread_id=22
 
MaxPwr Pow
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got some leads from ejbcertification but huh?
Question from ejbcertification (check out answer 5)

Identify correct programming restrictions that a Bean provider must follow to ensure that the enterprise bean is portable and can be deployed in any compliant EJB 2.0 Container. [Check all correct answers]
Feedback:
Answer 1, 3 and 5 are correct.
Answer 1 is correct. This rule is required to ensure consistent runtime semantics because while some EJB Containers may use a single JVM to execute all enterprise bean's instances, others may distribute the instances across multiple JVMs.
Answer 3 is correct. Most servers do not allow direct interaction between an application program and a keyboard/display attached to the server system.
Answer 5 is correct. This function is reserved for the EJB Container. Allowing the enterprise bean to perform this function would create a security hole.
Answer 4 is incorrect. It is possible to create an interface and implement the interface to make available in the enterprise bean business method.
Answer 2 is incorrect. The enterprise bean can make use of the JavaMail API.
 
MaxPwr Pow
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oppss, here are the answers from ejbcertificate:-
1. The enterprise bean cannot define read and write to static fields.
2. The enterprise bean cannot make use of the Sun JavaMail API.
3. The enterprise bean cannot make use of the Java Swing API.
4. The enterprise bean cannot make use of interfaces to define business methods.
5. The enterprise bean must not attempt to define a class in a package.
 
MaxPwr Pow
Greenhorn
Posts: 14
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sudhir,
thanks for the answer. I just came across some other articles that 'link' the ejb spec to ClassLoader usage. thanks again
 
Girija Siva
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Spec says that and the page 18 of headfirst book the bean is defined in a package.
Can somebody throw some light on it
Thanks
 
Suman Sarker
Ranch Hand
Posts: 68
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out the explanation here

http://www.coderanch.com/t/159323/java-EJB-SCBCD/certification/EJB-must-not-define-class
 
Girija Siva
Ranch Hand
Posts: 41
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suman
There is no explanation there
If you are thinking of what Roger wroteI would have thought that this is about disallowing the use of definePackage() and defineClass() of ClassLoader
Was that not covered in spec seperately on page 495 of spec , the second bullet point??
I am still not clear what the spec meant by that point. Can someboby help.......
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is my understanding. You must not do anything relating to a class loader. So, you cannot "create a class loader; obtain the current class loader; set the context class loader".

We are also told that the "enterprise bean must not attempt to define a class in a package". My belief is that this refers to the use of the defineClass() and definePackage() methods being disallowed. This is consistent with the class loader being disallowed.

Arguably, there was no need to disallow the definition of a class in a package as all methods of the ClassLoader class are banned, but I guess the EJB spec writers just wanted to make things a bit clearer. Of course, you could well argue that they should have written this particular programming restriction in much better English ...
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic