J
James Willans
I need to implement a simple J2EE application (in actual fact, I think
it is just a beans application). Unfortunately I have limited
understanding of the technologies surrounding J2EE and java beans. I
have read through bits of tutorials which have helped my
understanding, unfortunately there are still some loose ends which I
hope someone can help tie up.
The application I wish to implement involves the user being able to
create multiple instances of a bean (say "contact"), which they can
then display and edit (very simple!). I am using a session bean as a
facade so that the containership of the instances of "contact", which
is implemented as an entity bean, can be automatically managed.
Firstly here is the home interface for "contact":
public interface Contact extends EJBHome {
public Contact create(String id, String name,String phone)
throws CreateException, RemoteException;
public Contact findByPrimaryKey(String id)
throws FinderException, RemoteException;
public Collection findAll()
throws RemoteException, FinderException;
}
Question 1: I'm assuming that I don't need a remote interface for this
since it is always accessed via the facade (but see Question 2,
below). Is this correct?
Here is the entity bean logic:
public class Contact implements EntityBean {
private String id;
private String name;
private String phone;
public String getId() {
return id;
}
// getter and setter for "name" and "phone" removed
public void ejbCreate(String id,String name,String phone)
throws CreateException, RemoteException {
this.id = id;
this.name = name;
this.phone = phone;
}
public void setEntityContext(javax.ejb.EntityContext ctx)
throws RemoteException {}
public void unsetEntityContext() throws RemoteException {}
public void ejbRemove() throws RemoteException, RemoveException {
}
public void ejbActivate() throws RemoteException { }
public void ejbPassivate() throws RemoteException { }
public void ejbLoad() throws RemoteException { }
public void ejbStore() throws RemoteException { }
}
It is from the session facade that most of my questions stem:
Question 2: What types of values can a bean's remote interface return?
Could it return a Collection of Contact bean instances? If so, do I
need to do anything special (like making the Contact bean
serializable).
Question 3: I'm assuming that if 2 was possible, then a copy of the
instance would be returned, therefore changing its state would not
impact the original?
Many thanks.
James
it is just a beans application). Unfortunately I have limited
understanding of the technologies surrounding J2EE and java beans. I
have read through bits of tutorials which have helped my
understanding, unfortunately there are still some loose ends which I
hope someone can help tie up.
The application I wish to implement involves the user being able to
create multiple instances of a bean (say "contact"), which they can
then display and edit (very simple!). I am using a session bean as a
facade so that the containership of the instances of "contact", which
is implemented as an entity bean, can be automatically managed.
Firstly here is the home interface for "contact":
public interface Contact extends EJBHome {
public Contact create(String id, String name,String phone)
throws CreateException, RemoteException;
public Contact findByPrimaryKey(String id)
throws FinderException, RemoteException;
public Collection findAll()
throws RemoteException, FinderException;
}
Question 1: I'm assuming that I don't need a remote interface for this
since it is always accessed via the facade (but see Question 2,
below). Is this correct?
Here is the entity bean logic:
public class Contact implements EntityBean {
private String id;
private String name;
private String phone;
public String getId() {
return id;
}
// getter and setter for "name" and "phone" removed
public void ejbCreate(String id,String name,String phone)
throws CreateException, RemoteException {
this.id = id;
this.name = name;
this.phone = phone;
}
public void setEntityContext(javax.ejb.EntityContext ctx)
throws RemoteException {}
public void unsetEntityContext() throws RemoteException {}
public void ejbRemove() throws RemoteException, RemoveException {
}
public void ejbActivate() throws RemoteException { }
public void ejbPassivate() throws RemoteException { }
public void ejbLoad() throws RemoteException { }
public void ejbStore() throws RemoteException { }
}
It is from the session facade that most of my questions stem:
Question 2: What types of values can a bean's remote interface return?
Could it return a Collection of Contact bean instances? If so, do I
need to do anything special (like making the Contact bean
serializable).
Question 3: I'm assuming that if 2 was possible, then a copy of the
instance would be returned, therefore changing its state would not
impact the original?
Many thanks.
James