File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes package and class question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "package and class question" Watch "package and class question" New topic
Author

package and class question

MaxPwr Pow
Greenhorn

Joined: Mar 18, 2004
Posts: 14
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

Joined: Apr 11, 2002
Posts: 203
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


Weerawit<br />SCJP 1.4, SCWCD 1.2, SCWCD 1.4, SCBCD 1.3, SCBCD 5.0, SCMAD 1.0, SCJA 1.0, SCDJWS, SCJD, SCEA, SCDJWS 1.5
Sudhir V
Ranch Hand

Joined: Dec 25, 2002
Posts: 143
http://www.theserverside.com/discussions/thread.tss?thread_id=22


Sudhir V<br />(SCJP 1.2, SCWCD, OCA, SCBCD)
MaxPwr Pow
Greenhorn

Joined: Mar 18, 2004
Posts: 14
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

Joined: Mar 18, 2004
Posts: 14
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

Joined: Mar 18, 2004
Posts: 14
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

Joined: Apr 23, 2004
Posts: 41
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

Joined: May 06, 2004
Posts: 68
Check out the explanation here

http://www.coderanch.com/t/159323/java-EJB-SCBCD/certification/EJB-must-not-define-class


Suman A Sarker<br />SCJP, SCWCD, SCBCD<br /> <br />If You Can't Beat Them ... Join Them!
Girija Siva
Ranch Hand

Joined: Apr 23, 2004
Posts: 41
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

Joined: Sep 29, 2002
Posts: 1683
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 ...


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
 
subject: package and class question