Unit 7 Flashcards

1
Q

Exercise 1

Which data is marshalled (or unmarshalled) by the runtime support layer and where does this take place?

A

The method arguments are marshalled on the client side and unmarshalled on the server side. The return value is marshalled on the server side and unmarshalled on the client side.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

SAQ 1

What is similar and what is different between the implementation of remote methodcalls and remote procedure calls as presented in Unit 5, Subsection 7.1?

A

Both remote method calls and RPC are blocking forms of communication: the caller cannot proceed with its execution until the called method or procedure has returned. Moreover, as with RPC, the method call has to go through various layers that abstract away data marshalling and the low-level network protocols. For example, the runtime supportlayerin Figure1 correspondstothe RPC service layer. The discussion on what cango wronginan RPC call(e.g. network disruption) also appliesinthe distributed object context and has therefore been omitted from the presentation above.

The main difference is that in RPC a procedure is called directly, while in an object-oriented approach a method is called through a particular object that was created at runtime. The implementation of remote method calls therefore requires a registry and a unique name to look up the object reference.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

SAQ 2

What are a remote object, a remote interface and a remote method? How can they be detected in the server-side code?

A

Aremote objectisan instanceofaclass thatimplementsatleast one remoteinterface.A remote interface is an interface that declares one or more remote methods. A remote method is a method that can be called from another JVM.

In the code one has to look for the following: a remote interface extends Remote,a remote method throws a RemoteException and a remote object’s class usually extends UnicastRemoteObject.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

SAQ 3

We have previously said that the default registry implementation provided by the Java library requires the registry to run on the same host as the server application. Does this contradict the above sentence stating that the registry’s services are remote methods?

A

There is no contradiction: remote methods may be called from a different JVM not necessarily from a different host. To simplify the presentation of RMI, in this course we create the registry from within the server application, but there are ways to have the registry run on its own JVM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

SAQ 4 - A

Explain how the registry must be set up.

A

A registry service is started on a port known to the client and server applications. The service may runin its own JVMbut,for security reasons, it must be on the same host as the server application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

SAQ 4 - B

Explain how the server makes the remote object available to clients and the purpose of proxies.

A

The server application creates a remote object and exports it, so that it is ready to receive incoming calls. The server application then asks the registry to bind (i.e. associate) a unique symbolic name to a remote reference, i.e. a reference to the remote object. The symbolic name is given by the server application and is somehow (e.g. on a public website) made known to the clients. The remote reference is a stub object, i.e. a proxy that acts as a representative of the remote object. The stub object implements the same interfaces as the remote object, but the implementation of each method just forwards the call and the arguments to the remote object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

SAQ 4 - C

Explain how the client obtains a reference to the remote object.

A

When the client wishes to make the remote call, it looks up the name in the registry. The registry returns (using serialisation) a copy of the stub object. The clientnow has a local reference to a stub object residing on the same JVM heap.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

SAQ 4 - D

Explain how a call to a remote object method is executed.

A

The client makes a normal call to a method of the stub object, passing other objects or primitive data as arguments. The client thread executing the call then blocks, as it cannot continue until the call completes. The runtime support layer serialises the object arguments and uses the network support layer to send everything to the server. On the server JVM, the network and runtime support layers reverse the process, unmarshallingthe arguments and making alocal calltothe corresponding method of the remote object. The return value or exception object is serialised and then passed back to the caller, which resumes execution.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SAQ 4 - E

Explain how and why security managers are used.

A

If a JVM receives a serialised object of an unknown class (i.e. a class that is not on the JVM’s class path), it must use a security manager to check whether the user-defined security policy allows downloading and executing of the code from the location given in the java.rmi.server.codebase property set by the JVM that sent the object.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

SAQ 5

Describe, in the correct sequence, the main steps in developing a simple client–server application using RMI. Identify in each step the interfaces or classes to be extended, the methods to be called, and, if applicable, the exceptions to be raised.

A

See page 21 of unit 7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Exercise 4

For the one-to-one example given above, involving customers and credit cards, what would each table need to include in order for the relation to be (a) unidirectional and (b) bidirectional?

A

If thecredit cardrecord containsaforeign key to the customer but the customer record does not includea foreignkeytothecredit card, thentherelationis unidirectional:it can be navigated from the card to the customer but not vice versa. The relation is also unidirectional if the customer record includes a foreign key to the credit card but the creditcarddoesnothaveaforeignkeytothe customer.Ifeach recordhasaforeignkey to the other one, then the relation is bidirectional.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

SAQ 6

Summarise how entity classes are related to the relational schema and how they are defined

A

An entity class corresponds to a table, each instance of it to a record in the table and each column to an instance variable. To define an entity class for table T1, declare one private instance variable per column and access it through a pair of setter and getter methods.Ifa columnisa foreignkey to table T2,the corresponding variableistypedby the class corresponding to T2.If T1 has a one-to-many relationship to T2, then the class may have an additional instance variable holding a collection of instances of the class corresponding to T2.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

SAQ 7

Explain whether the following declaration is correct or not. @Column(name = “MODEL_ID”)
private InstrumentModel model;

A

It is incorrect because the annotation and the type of model are incompatible. The @Column annotation implies that model must hold the string contained in the MODEL_ID column, while the InstrumentModel type implies that model must hold the record (i.e. entity)referred to by the MODEL_ID column.In other words, the annotation indicates that the MODEL_ID column should be interpreted as a normal string, while the type indicates that it should be interpreted as a key.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

SAQ 8

What is the rationale for using a pool of stateless beans?

A

The rationale for using pools of resources is always the same: performance. Requests can be serviced faster by an already available and reusable resource, instead of creating a new one when the request arrives and then garbage collecting it after the request terminates.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

SAQ 9

What do the terms remote access and local access mean?

A

If access is remote, client and bean are executing on different JVMs; if access is local, they are executing within the same JVM.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

SAQ 10

In this unit we assume that the client is a separate application – web clients are covered in the next unit. How will session beans be annotated?

A

They will be annotated with @Remote, because separate client applications do not run on the same JVM as the server, as stated under the ‘Client type’ bullet item above.