Weblog

All | Personal | Sun
« Previous day (Nov 3, 2005) | Main | Next day (Nov 4, 2005) »
20051104 Friday November 04, 2005

Send a E-mail in EJB I would like to reveal how the code that sends a e-mail might be coded in NetBeans 5.0. It will take about 20 seconds.
Let's start to write simple staless session bean that has one processOrder(String orderId) business method that process order and then sends a notification. Here are steps to implement send e-mail in EJB:

    • Select project node in project tab and invoke New - Sun Resources - JavaMail Resources
      On next panel specify all required info. Note, since mail resource should be in mail subcontext start your JNDI name with mail/... After finishing wizard, new Sun resource should displayed under Server Resources node.
      Open bean implementation class in editor. Invoke pop-up menu in editor and choose Enterprise Resources - Send E-mail
      In dialog specify JNDI name for for mail resource and Service locator class. Click OK and two new methods and appropriate entries in deployment descriptors should be created.

      Now, implement business method:
           public void processOrder(String orderId) throws Exception{
              sendMail("petr.blaha@sun.", "Your order " +  orderId +" is completed", EMAILBODY);
          }
        
      Deploy and test new functionality of your bean.
  • Posted by pblaha ( Nov 04 2005, 05:20:30 PM CET ) Permalink Comments [0]

    Calendar

    RSS Feeds

    Search

    Links

    Navigation

    Referers

    Older blog entries