• 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

Help for the creation of a simple stateless EJB 3.1 and its client

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I read a bit of theory about EJBs 3.1 but now that I'm trying to create one in practice I have some doubt, and I don't know how to proceed.
Is there anyone that can give me some help?

Ok, I would like to create a stateless EJB with a single public method that perform some operation and returns an int. And I would like to access it Locally, Remotely, via SOAP and via REST.
I also would like to follow all the best practices and code/naming conventions.

This is the EJB that I created: (Please correct me if something is wrong or if I didn't follow some convention/best practice in naming, packaging, interfaces references, etc.)



And those are the local and remote interfaces that I created:




And here "some" question:
1. How can I invoke the method doProcess from a remote client? Must the client make use of the remote interface or there is a way to make a call passing the method name as parameter? for ex.   int result = lookup("..").call("doProcess", {1,3,5,7,9});
1.1 If the use of the bean interface in the client is mandatory this means that the EJB remote interface should be defined in an external project (otherwise the client must have a dependency to the whole EJB project to use the interface)?

2. When I do the JUnit tests should I create the EJB instance using "ProcessorLocal instance = new ProcessorBean();" or using an annotation like "@EJB ProcessorLocal instance;"
2.1 If the answer to the previous question is using the "new" keyword does the validator work in this case (being the EJB instance created outside the container that should provide the services)?
2.2 If otherwise the answer to the question 5 is using the "@EJB" annotation, this means that the JUnit test can be executed only running the EJB into the server to have CDI etc?

3. The @NotNull validator is active by default or have I to update the bean.xml descriptor?

4. How can I have the same EJB method available also through SOAP and REST? It is sufficient to create two new interfaces with the annotations relative to SOAP and REST?

Thanks in advance!

 
The problems of the world fade way as you eat a piece of pie. This tiny ad has never known problems:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic