SCBCD - Client View of an Entity
1)Identify how a client can obtain a reference to an existing entity object's remote interface? [Select all correct answers]
1)Invoke the findByPrimaryKey()
finder method.
2)Invoke the getHandle()
method on the remote interface.
3)Call a create()
method on the remote interface.
4)Execute a home business method that returns the reference.
5)Call the getRef()
method on the remote interface.
2)How can a client application test whether two entity object references refer to the same entity object?
1)By using the isIdentical()
method.
2)By using the == operator.
3)By using the compareTo()
method.
4)By using the equals()
method.
3)Which of the following declarations for a remote home interface finder method is correct? [Select all correct answers]
1)public Collection findAccounts() throws RemoveException, RemoteException
2)public Collection findIvlAccounts(Date from) throws FinderException, RemoteException
3)public void find(Date from) throws FinderException, RemoteException
4)public Account findAccount(String accNumber) throws FinderException, RemoteException
5)public Account findAccount(String accNumber) throws FinderException
4)Which of the following code fragments will locate an entity bean's remote home interface correctly?
Assume the InitialContext was created and the correct packages has been imported.
InitialContext ctx = new InitialContext();
// set properties
1)
PartyHome pHome = (PartyHome) PortableRemoteObject.narrow(ctx.lookup("java:comp/env/parties"),PartyHome.class);
2)
PartyHome pHome = (PartyHome) PortableRemoteObject.narrow(ctx.lookup("java:comp/env/parties"));
3)
PartyHome pHome = (PartyHome)ctx.lookup("java:comp/env/parties");
4)
PartyHome pHome = (PartyHome) PortableRemoteObject.lookup(ctx.narrow("java:comp/env/parties"),PartyHome.class);
5)
PartyHome pHome = (PartyHome) PortableRemoteObject.create(ctx.lookup("java:comp/env/parties"),PartyHome.class);
5)How many create() methods can an entity bean's local home interface define?
1)0
2)Exactly 1
3)atleats 1
4)0 or more
5)1 or more
6)Which of the following Exceptions must be included in the throws clause of every create<METHOD> in the following code fragment? [Select all correct answers]
4. public interface PartyHome extends javax.ejb.EJBHome {
5. public Party create(String firstName) throws ...
6. }
1)
javax.ejb.FinderException
2)
javax.ejb.CreateException
3)
java.rmi.RemoteException
4)
java.rmi.NoSuchObjectException
5)
javax.ejb.NoSuchObjectLocalException
7)Which of the following names can be used to identify legally an entity bean remote home business method? [Select all correct answers]
1)
getCustomer
2)
createCustomer
3)
removeCustomer
4)
findCustomer
5)
CreateCustomer
8)Which of the following statements are true regarding the narrow() method for an entity bean's home interface?
1)The
narrow()
method must be used to locate a remote home interface.2)The
narrow()
method must be used to locate a local home interface.3)The
narrow()
method must be used to locate a local home interface or remote home interface.4)The
narrow()
method must be used to lookup in the JNDI space the entity bean.9)How many create() methods can an entity bean's remote home interface define?
1)0
2)Exactly 1
3)atleast 1
4)0 or more
5)1 or more
10)Which of the following operations on an entity object's local reference are defined in the EJBLocalObject interface? [Select all correct answers]
1)Remove the entity object.
2)Obtain the local home interface for the entity object.
3)Obtain the entity object's primary key.
4)Obtain the entity object's handle.
5)None of the above.
Answers:
1)1,2,4
-
Answers 1, 2 and 4 are correct. Answer 3 is incorrect, the
create()
method will not return a reference to an existing entity object's remote interface. Answer 5 is incorrect, this method does not exists.A client can get a reference to an existing entity object's remote interface in any of the following ways:
- Receive the reference as a parameter in a method call.
- By using a finder method defined in the entity bean's remote home interface.
- By obtaining the reference from the entity object's handle.
2)1
-
A client can test if two entity object references refer to the same entity object by using the
isIdentical()
method.If a client obtains two entity object references from the same home interface, it can determine if they refer to the same entity by comparing their primary keys using the
equals()
method.The
isIdentical()
method defined on theEJBObject
interface returns true if the given EJB object is identical to the invoked object, false otherwise.
3)2,4
-
Answers 2 and 4 are correct.
Answer 1 is incorrect, the throw clause of every finder method on the remote home interface must include the
javax.ejb.FinderException
and thejava.rmi.RemoteException
.Answer 3 is incorrect, the return type of a finder method on the remote home interface must be the entity bean's remote interface or a collection of objects that implements the entity bean's remote interface, but not void.
Answer 5 is incorrect, the remote home interface finder method must contain the
RemoteException
in the throw clause.
4)1
-
Answer 1 is correct.
A client locates an entity bean's home interface using JNDI. A client's JNDI name space may be configured to include the home interfaces of enterprise beans deployed in multiple EJB Containers located on multiple machines on a network. The actual location of an EJB Container is, in general, transparent to the client.
Answer 3 is used to lookup the entity bean's local home interface. The lookup of a local home interface does not involve the API's for remote access.
5)4
An entity bean's remote home interface and local home interface can define 0 or more
create()
methods, one for each way to create an entity object. The arguments of the create()
methods are typically used to initialize the state of the created entity object. The name of each create()
method starts with the prefix "create". The return type of a create()
method on the remote home interface is the entity bean's remote interface.6)2,3
Answers 2 and 3 are correct. The remote home interface of the entity bean is presented in the exhibit. The throws clause of every
create<METHOD>
method on the remote home interface must include the java.rmi.RemoteException
and the javax.ejb.CreateException
. It may include additional application-level exceptions.7)1,5
-
Answers 1 and 5 are correct. Home methods on the remote home interface can have arbitrary method names, but they cannot start with the prefix: "create", "find" or "remove".
The arguments of a home business method are used by the entity bean implementation in computations that do not depend on a specific entity bean instance. The arguments and return type of a business method on the remote home interface must be legal types for RMI-IIOP (i.e. Serializable, primitives, arrays or collection of objects).
8)1
-
Answer 1 is correct. The
narrow()
method fromjavax.rmi.PortableRemoteObject
class checks to ensure that an object of a remote or abstract interface type can be cast to the desired type. After you have received the object through a JNDI lookup thenarrow()
method ensure that you will have an object that really implements the home interface.The
narrow()
method locates the remote home interface of the entity bean.Locating the local home interface does not require the use of the
narrow()
method, it does not involve the API's for remote access.
9)4
An entity bean's remote home interface and local home interface can define 0 or more
create()
methods, one for each way to create an entity object. The arguments of the create()
methods are typically used to initialize the state of the created entity object. The name of each create()
method starts with the prefix "create". The return type of a create()
method on the remote home interface is the entity bean's remote interface.10)2,3
-
Answers 1, 2 and 3 are correct. The
javax.ejb.EJBLocalObject
interface defines the methods that allow the client to perform the following operations on an entity object's local reference:- Obtain the local home interface for the entity object. (
getEJBLocalHome()
) - Remove the entity object. (
remove()
) - Obtain the entity object's primary key.(
getPrimaryKey()
)
The entity object's handle (
getHandle()
) is defined in theEJBObject
for remote home interfaces. - Obtain the local home interface for the entity object. (
No comments:
Post a Comment