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

Why this object invoke this method?

 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There is an question puzzled me all the time.The "HelloHome" is a interface extends javax.ejb.EJBHome and this interface has a method "public Hello create()...". The Hello is another interface extends javax.ejb.EJBObject and has a method "public String getHello()...".The HelloEJB is a class implements SessionBean and add a method "public String getHello(){ return new String("hello");" In testing code:"HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject narrow(objRef,HelloHome.class);Hello bean =home.create(); out.println(bean.getHello());".I really don't know why the "bean.getHello()" will work property.Because the bean is a interface and nobody implement it.Does the "home.create()" create a class that implements the "Hello" interface?Someone say that is the J2EE Container implements it.But the method "getHello()" is implemented by HelloEJB other than EJBObject.I think it easy to understand if the code is:
/* in implement class */
class HelloEJB implements Hello......
public String getHello(){
return new String("Hello");
.... ...... ........ ......
/* in testing class*/
Hello bean=new HelloEJB();
bean.getHello();
/* End */
But mycode doesn't use create method.So I think the "create()" method implements the code I write above and it's the Web Container implements the create method.It's right?Have someone help me?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic