why? EnterpriseBean extend Serializable...


EJB programming & troubleshooting: why? EnterpriseBean extend Serializable...

  1. why? EnterpriseBean extend Serializable... (4 messages)

    I don't know...

    we should not implement this interface; rather, implement
    either javax.ejb.EntityBean or javax.ejb.SessionBean,
    which both extend this interface.

    public interface javax.ejb.EnterpriseBean
         extends java.io.Serializable
    why? Extend Serializable?
  2. Why is an EnterpriseBean and hence an EntityBean serializable?
    1. Be extensible to support simple persistence of objects.
    2. Have a simple yet extensible mechanism.
    3. Maintain the Java object type and safety properties in the serialized form.
    4. Be extensible to support marshaling and unmarshaling as needed for remote objects.
    But its upto the container to decide when to serialize a particular entity or reconstruct it. The bottom line is better usage of memory in case of heavy duty bean access scenario.

    Any comments?
  3. the main thing here is to support the Activation and passivation and since this is not controlled by the developer,rather by the contianer it sely ot should always implemt this inteface .

    1- pasivation is when you persisit your bean from the temporery cash to hard media ,passivation is the oppesite opration,so it is clear that when an object should be store into the disk it must implement this interface .
  4. hey look at the statement... it's extends Serializable.... not implements Serializable!!!.... i don't thing the compiler lets us do that... i don't get it!
  5. You can extend an interface if you are also an interface. In fact you can extend many interfaces, since Java supports multiple interface inheritence. Hence the following is valid.

    public interface Bar {
      void doBar() throws BarException;

    public interface Foo extends Bar, Serializable {
      void doFoo() throws FooException;

    public class Blah implements Foo {
      public void doBar() throws BarException {};
      public void doFoo() throws FooException {};

    That make it clearer?