users@glassfish.java.net

Re: inheritance in session beans

From: <glassfish_at_javadesktop.org>
Date: Mon, 22 Oct 2007 17:26:17 PDT

I have had success with the following way:

@Local
public interface LocalA
{
  public void default();
}

@Stateless
public class Default extends LocalAImpl implements LocalA
{
  // nothing in here except attributes/private functions/and other
  // code specific to default
}


** SpecA interface and implementation ***

@Local
public interface SpecALocal extends LocalA
{
  public void specAMethod();
}

@Statelss
public class SpecA extends LocalAImpl implents SpecALocal
{
  public void default()
  {
    //something more
    super.default();
  }

  public void specAMethod()
  {
    // specific method to SpecA EJB
  }
}

** implementation class no stateless annotations on the class! ***
public class LocalAImpl implements LocalA
{
  public void default()
  {
  // implementation of default
  }
}


This will give you two EJBs - one that implements LocalA and one that extends LocalA and implements SpecA. Hope it makes sense... A diagram would be easier!

Works for me!

Cheers
Cameron
[Message sent by forum member 'cameronr' (cameronr)]

http://forums.java.net/jive/thread.jspa?messageID=241597