• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

package and class question

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.theserverside.com/discussions/thread.tss?thread_id=22
 
MaxPwr Pow
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the explanation here

https://coderanch.com/t/159323/java-EJB-SCBCD/certification/EJB-must-not-define-class
 
Girija Siva
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.......
 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ...
 
joke time: What is brown and sticky? ... ... ... A stick! Use it to beat this tiny ad!
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic