Units 5-8 Flashcards
Briefly describe the conditions under which optimistic concurrency control might be more suitable, and one possible advantage of using it.
The optimistic approach is suitable when:
- the likelihood of clients accessing the same data is very low
- fast response is important, such as in interactive applications.
It aims to avoid the overheads and problems associated with locking mechanisms, such as lock management and deadlock detection/prevention.
A Java client can make use of distributed objects using Remote Method Invocation (RMI). It is also possible for Java clients to access Enterprise Java Beans (EJBs) and invoke methods on those. Describe three significant ways in which these two ways of using remote objects resemble one another.
- Both are action-oriented rather than data-oriented.
- Both take advantage of loose coupling.
- Both are examples of remote object invocation.
- Both run inside JVMs.
- Both are homogenous.
What are session beans and what purpose do they serve?
- They are a type of EJB that handles an interactive session between a client and the application server.
- Neither persistent nor shared.
- Encapsulate the business logic.
- Session beans access and modify entities, shielding data from clients
Name the two types of session beans and explain the main difference between the two types.
- Stateful bean: the state (value of the bean’s instance variables) is kept across multiple calls to the bean’s methods, e.g. an online shopping cart.
- Stateless bean: the state is discarded after each method call - a session with a stateless bean lasts only for the duration of a single method call, e.g. a database query. A single stateless bean can provide multiple methods, each one implementing an independent query.
Both servlets and JavaServer Pages (JSP) are mechanisms used to generate web pages. Explain when one would use JSP and when one would use servlets.
- JSP would be used when the output of the webpage is mainly static HTML/XML, with some dynamically generated content.
- Servlets would be used for more complex processing, where the static content of the response is very limited or is delegated to another component.
Explain the following statement: “Java’s RMI is a form of communication that follows the distributed object paradigm”.
The distributed object paradigm extends the object-oriented paradigm to a distributed setting, so that local and remote objects are treated in the same way and have the same capabilities.
RMI is effectively extending the way that objects invoke methods on other objects to a distributed setting, and hence belongs to the distributed objects paradigm. RMI works by adding an additional layer that deals with the lower level details of the communication, such as data marshalling and sockets. To use RMI requires the existence of a registry so that objects can look up where other objects are located, in order to invoke methods on them.
Explain what is meant by ‘conflicting operations’.
Operations are conflicting if the order in which they are carried out affects the result.
What are the three main categories of components in the MVC approach and what are their roles? Illustrate your answer with an example for each category.
- Model: the abstraction of all the domain data in the system, e.g. the shopping cart in an e-commerce system.
- **View: **the visualisation of the model, e.g. HTML/JSP pages.
- Controller: the set of components that manage the communications between model and view, e.g. a servlet.
Using a diagram or otherwise, name the standard tiers of a Java EE application and indicate the type of components associated with each tier.
- Client Tier: Browser, applet, application client
- Web Tier: Servlet, JSP, JavaBean
- Business Tier: EJB, Entity class
- Database / EIS Tier: DBMS
Explain how HTTP servlets deal with handling concurrent requests from multiple clients.
For the standard situation of a multi-threaded servlet, the Web container will create and run a separate thread for the service method that is invoked in response to each request. The helper methods such as doGet or doPost which will be invoked by the service method must be written to take account of this.
Explain how HTTP servlets deal with avoiding problems with concurrent access to shared data.
Data stored in variables declared locally to servlet methods is threadsafe, because each thread has its own copy of local variable data.
By contrast, instance variables or static variables are not thread-safe as they are shared between any threads being run concurrently by the servlet. Code that updates instance data or static data, must use synchronization, so that at most one thread at a time can be carrying out an update. It is best to synchronize as little of the servlet code as possible, to maximise performance.
What is meant by a heterogeneous system?
A heterogeneous system is one implemented using more than one kind of computer, operating system, software or communication protocol.
Why are heterogeneous systems of particular interest in distributed computing?
- Distributed computing in a wide context inevitably involves heterogeneity, due to the variety of systems in existence.
- Legacy systems may exist or systems may have been developed by different parties at different locations and times, leading to heterogeneity.
Give a definition of middleware.
- Any software that provides an intervening layer between two communicating systems, providing the ability to make communication between the systems transparent
- *OR**
- Software that masks the heterogeneity of an underlying system
Explain what is meant by homogeneous and heterogeneous middleware, and give an example of each.
- Homogeneous: middleware in which all parties are assumed to be implemented in the same language and running on the same platform, e.g. Java RMI
- Heterogeneous: middleware in which no assumptions are made about a shared language/common platform, e.g. CORBA.
Heterogeneous middleware is more flexible than homogeneous middleware, but has higher overheads. Give two examples of such overheads.
- Additional communication overheads due to their flexibility and the requirement to translate between heterogeneous representations.
- Requires the use of an IDL (interface definition language)** **representing features of multiple languages.
Give two reasons for using JSP Expression Language or Tag Libraries in JSP pages in preference to Java scriptlets and expressions.
- Separates processing (Java code in servlets) from presentation (JSP pages using tags and EL). Helps with maintenance in complex applications.
- Allows web designers familiar with HTML and XML, but not with Java, to produce and maintain JSP pages without any Java programming.
- (unit 8, p 42)*
How does the RPC mechanism take care of robustness?
The use of timers (at points A and D in diagram). If time-out occurs, this indicates that something has gone wrong.
Remote Method Invocation (RMI) has three steps: binding, lookup and method call. Explain briefly what happens during each step.
- The server application binds the server object to a symbolic name in a registry, a naming service that associates objects to unique names. The location of the registry and the symbolic name are known to client and server.
- The client object looks up the symbolic name in the registry and obtains a reference to the server object.
3 The client object uses that reference to make a remote method call.