Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Where does the ejbCreate definition come from

 
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you all know, every bean class must declare at least one ejbCreate() method (unless it's a stateful session bean whose home interface has no create() method).

You must declare this according to some rules. As an example, this is what you must do for message-driven beans.


The method name must be ejbCreate.

The method must be declared as public.

The method must not be declared as final or static.

The return type must be void.

The method must have no arguments.

The throws clause must not define any application exceptions.


It's almost as if the bean class is implementing a hidden interface which has this method declared:


public void ejbCreate() throws EJBException


Is there some good reason ejbCreate() is not declared in javax.ejb.MessageDrivenBean?
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Roger
I did not get what ur saying but ...


As you all know, every bean class must declare at least one ejbCreate() method (unless it's a stateful session bean whose home interface has no create() method).

create is mandetory for SessionBean , optional for EntityBean and no create as there is no home interface for MessageBean Is it not.? Am i missing something fundamental here in understanding what ur trying to say???

 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A misstype, I meant ejbCreate() is optional for Entity beans. It's after midnight, I've been at my PC all day .

Anyway, the question remains: where is ejbCreate() defined?
 
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
In the bean 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
The ejbCreate is in bean class and for other beans it has got matching create() in the home interface for the client to initiate the creation. But in case of MDB there is no matching as there is no client and no HOME. Observe even in case of Staless SessionBean even if there is matching create it has nothing to with the ejbCreate() in the bean class.

This is a very nice point you raised Roger. I did not looked at ejbCreate() and create() this way before.
This is what My understanding is ..IF anyone has more to add......
 
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


It's almost as if the bean class is implementing a hidden interface which has this method declared:




Is there some good reason ejbCreate() is not declared in javax.ejb.MessageDrivenBean?



The way I look at it is the developers only way to participate in beans creation. Obtain resources that are required or do things like that if business needs it. Without this method there is no way for the developer to say a word in beans creation
 
Oh, sure, you could do that. Or you could eat some pie. While reading this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic