Skip to main content

JTS, SWT, JFace Interview Questions

What is JTS?

Among the enterprise distributed computing specifications, Java Transaction Service is one. The interoperability is ensured along with sophisticated transaction resources such as transaction managers on the Java platform is ensured by Java Transation Service. The implementation of the transaction managers is specified by JTS which supports Java Transaction API. The JTS is the implementation of the OMG OTS specification.

What is a distributed transaction?

The involvement two or more network hosts for operations bundle, is called distributed transaction. The transactional resources are provided by the hosts and creating and managing the global transactions encompassing all operations against such resources is the responsibility of transaction manager. Similar to other transactions, distributed transactions must have all the ACID properties. The transactions among multiple participating databases are distributed among different physical locations.

Explain the types of isolation levels that J2EE supports.

TRANSACTION_READ_UNCOMMITTED:
A static final varibale / constant that specifies the non-repeatable reads, dirty reads and phantom reads occurances. This allows a specific row that is changed by one of the transactions to be reade by another specific transaction well before the changes in that row have been committed. In case of any roll backs, an invalid row will be retrieved by the second transaction.

TRANSACTION_READ_COMMITTED:
A static final varibale / constant that specifies the prevention of the dirty reads, non-repeatable reads and phantom reads occurances.

TRANSACTION_REPEATABLE_READ:
A static final varibale / constant that specifies the prevention of dirty reads and non-repeatable reads and the occurances of phantom reads.

The level indicates the prohibitions of reading a row with uncommitted changes in it, and also indicates the prohibition in specific situations where one transaction reads a row, a second transaction alters the row and the first transaction rereads the row.

TRANSACTION_SERIALIZABLE:
A static final varibale / constant that indicates the prevention of dirty reads, non-repeatable reads and phantom reads. This includes the prohibitions in TRANSACTION_REPEATABLE_READ.

It further prohibits the following situations :
- First transaction reads all rows that satisfy a WHERE condition
- A second transaction that inserts rows that satisfies the WHERE cndition and
- First transaction rereads for the same condition, retrieving the additional phantom row in the second read.

Explain the types of concurrency issues in the transaction processing that isolation levels attempts to address.

Dirty reads issue is as follows:
First transaction is reading the uncommitted changes which are performed by a second transaction. In this scenerio , if the second transaction is rolled back, the data read by the first transaction becomes invalid. The reason is, the roll back does not make any changes, and the first transaction is unware about the roll back done by the second transaction.

Phantom reads issue is as follows:
A new record is added to a database. A transaction started before the insertion, so this record can be detectable by this transaction. After starting the other transaction, the queries will include records added. In this situation the record inserted / added is a phantom record.

Unrepeatable reads issue is as follows:
A component which finds its previously read data which is being modified by other component. The problem of appearing a new set of data in a database between 2 database operations.

Explain the categories of exceptions in EJB.

Application Exception:
This is one of the exceptions which was declared on the method signature. The business work flow treats this as a special scenario, in the remote interface. If it is thrown a client is given an option called recovery option which entails the request processing in different way.

System Exception:
This is one of the exceptions which can not be recovered by an EJB method. It can be a checked exception or an unchecked exception. If it is treated an unchecked exception by the EJB conainer the transaction will be rolled back and perform the necessary cleanup, and the container throws an RemoteException to the client.

What are the advantages of JTA over JTS?

Java Transaction API provides simple and flexible environment for the developer. It offers high-level X / Open Call Level Interface and low-level XA Call Level Interface. Using JTA, needs the programmer to focus on high-level X/Open interface. The low-level XA CLI is handled by the server that provides the implementation to JTA. The indirect operations by the XA operations make the user simpler in order to manipulate the transactions.

Explain how Java transaction services (JTS) solve the problems encountered by distributed objects with transactions.

The transactional semantics participation into object oriented components needs an extension of the Transaction Control Model. In this model the transactions are the methods on the transactional objects. This process is just done by JTS. The distributed objects like CORBA are implemented by JTS. It acts the interface between the JTA and a low-level API. The advantage of using JTS over distributed objects is that, the object oriented components need not extend the Transaction Control Model.

Explain SWT and JFace.

Standard Widget Toolkit (SWT):

SWT is an open source widget tool kit for developing rich, efficient and portable GUI applications. It was originally developed by IBM and being maintained by Eclipse Foundation along with Eclipse IDE. It is an alternative to AWT and Swing. To display the elements, it implements the operating system GUI libraries by using Java Native Interface. The SWT applications are portable and unique for each platform.

The need of SWT is to provide a common API for accessing different operating system / platform specific widgets. The goal for designing of SWT is high performance, native OS look and feel, and platform integration. Swing on the other hand, designed to allow for a highly customizable look and feel that is common across different platforms.

JFace:
A User Interface project developed by Eclipse to handle most commonly used User Interface tasks. It is window based system independent in both implementation and API. It is designed to work with SWT. JFace is included with images, text, dialog, wizard, images, font registries and progress reporting for long running operations.

JFace has two mechanisms – namely action and viewing.

  • The mechanism of actions allows the commands to be defined independently by the user from the exactness of whereabouts in the User Interface.
  • The mechanism of viewing is based on the adapters for certain SWT widgets, which simplifies the application presentation data structured with lists, tables or trees.

Eclipse runtime kernel is connected with few classes that have JFace. It can be a common practice to extract JFace and SWT to be used for stand-alone java applications which is not based on the Eclipse runtime.

Explain the components offered by JFace.
i.e. Image and font registries
Dialogs and wizard
Action mechanism
Viewers and editors

ImageRegistry:
The mapping between symbolic image names and SWT image objects is maintained by the ImageRegistry class until the SWT image objects are needed. It owns all the images registered with it and automatically disposes them when the SWT Display that creates the images is disposed.

FontRegistry:
The FontRegistry maps between symbolic font names and SWT fonts. It owns all the fonts registered with it and automatically disposes them when the SWT Display that creates the fonts is disposed.

Dialog:
Dialogs are used to communicate the information from the user or to the user. The following are the different types of messages:

  • The MessageDialog displays information to the user
  • The InputDialog accepts the input from the user in the form of text
  • The ErrorDialog displays one or more errors to the user.

Wizard:
A wizard can be used to create new java classes, projects, files and folders. Wizards provide step by step process to create these elements. A well defined wizard is targeted to simplify user tasks and increase productivity. Wizard is meant to take out the hassle of creating repetitive and tedious tasks.

Action Mechanism:
Actions are tasks for various users operations such as clicks on menus, toolbars, status lines etc. In order to support these actions the action mechanism is implemented. There are listeners and managers for each of these actions.

Viewers:
Viewers are used to display objects using different SWT widgets. Types of viewers are as follows:

  • The ListViewer uses the SWT List widget to display the object. A simple list of elements can be created by using ListViewer.
  • The CheckboxTableViewer uses the SWT widget to display the objects of checkboxes.
  • The CheckboxTreeViewer uses the SWT table control with checkboxes on each node.
  • The CheckboxTreeViewer uses the SWT Tree control with checkboxes on each node.
  • The TableTreeViewer uses the SWT Table Tree control.
  • TableViewer, uses the SWT TableViewer control.
  • TreeViewer, uses the SWT TreeViewer control.

Editors: Using JFace Text framework, sophisticated editors such as XML editors and text editors can be developed. Any application needs editors to author the designated code. For example XML file needs tags to be written a flat text file. A program needs editor to author the code. By using different development template these editors can be plugged in and developed

What are the advantages offered by SWT/JFace?

Advantages of SWT:

  • Provides backend by providing native look with backend widgets by supporting Swing programming model.
  • SWT could run Swing native objects which enables SWT to run on any Swing support platform.
  • SWT based application loads faster compared to Swing applications
  • The memory usage is smaller in SWT as it uses the shared libraries. The shared library loads only once for all SWT applications.
  • Provides the exact platform look and feel. Even with the skinned desktop, it looks and feel is also skinned.
  • Provides different styles for different types of menus

Explain the Java Web Start technology.

Java Web Start (JavaWS) technology is a framework which is used to allow the user to run java platform specific application software directly from the internet. The Java Web Start applications do not run in a browser. Web start application provides a series of classes which provides various services to the applications. These classes are available in the package called javax.jnlp

Web start comes as a part of Java Runtime Environment without having separately installed. It comprises the portability of applets and maintainability of servlets and JSP technologies. Java Web Start allows the java client applications to be launched, updated, and deployed from a standard web server.

The Java Application Manager feature allows the end-users to organize the java applications and also provides different options such as specifying the use of multiple Java Runtime Environments, setting proxy servers for HTTP.

Explain the steps used to deploy SWT/JFace-based application with Java Web Start.

Some of the operating system specific libraries are to be loaded for SWT applications before they can execute. The combination of SWT application with Java Web Start provides powerful tools to deploy the client side applications.

To test a Java Web Start application the following are the prerequisites:

Microsoft Windows XP or Red Hat Linux V8
Java 2 SDK, Standard Edition V1.4 or later
Apache Ant V1.5.3 or later
Apache Jakarta Tomcat V4.1.24 or later

The steps for deploying:

  • 1. Install the application in the required directory
  • 2. Signing the code and security:
    SWT is tightly integrated with the operating system's native windowing environment. SWT uses a system libraries to manage the platform independent API and the supporting operating system. All the required JAR files deployed with Java Web Start must be digitally signed. Self-signed test certificate is needed to be created, as the specific application is not going to deploy for wide user base.
    2a). Creation of self-signed certificate:
    Execute the command in the directory where the application is to be deployed:
    keytool -genkey -keystore keystore -alias myself

    A prompt message will be displayed stating to enter the password,name, locality etc. During the ANT build process, the actual signing the JAR files will be completed.
    2b). To verify that the keystore was properly created, type the following command:
    keytool -list-keystore keystore
  • 3. Build the file using the ANT
    3a). To clean the environment, type: ant clean
    3b). To execute the build process type: ant
  • 4. Give a trial to execute the application using the command: ant run
  • 5. To deploy the application to Apache Tomcat web server:
    5a). Place the application's .war file into webapps directory under Tomcat.
    5b). Execute the script to start Apache Tomcat
    5c). Open the web browser and type http://localhost:8080/index.html. Now click on Launch application.
  • 6. Click on Start in the displayed dialog box to start the application.

Explain the model-view-controller pattern.

A pattern is defined as the structure / significant process for application development. The MVC pattern isolates the business logic for the user interface. The result of applying MVC pattern is to simplify the application development for visual appearance and the underlying business logic without affecting each other. A web application can be viewed as simple as that of consisting of only 3 parts irrespective of complexity. This gives the developers, web page authors and the database folks the flexibility to develop their individual goals or tasks.

As an architectural pattern it separates the presentation layer (the user interface), the domain logic and database access. The presentation layer is further divided into view and controller.

Explain the 3 main components of MVC architecture, i.e. Model, view and controller.

Model:
In the MVC pattern, the component," model" comprises the code that is to deal with the database (can be a simple java bean). It is built without appearance concerns at the time of presenting to the user. To perform its functionality, it implements the public functionality. A model in java application consists of one or more classes that extend the class java.util.Observable which provides the notified infrastructure needed to support a set of views.

View:
A view provides multiple graphical user interface components to interact with the model. The values that a querying process delivered by a model will be displayed by the model. At the time of user's updation of a model through view, the view communicates these updations to the controller to perform the desired modifications. The views must implement the java.util.Observer interface.

Controller:
The controller plays the role of updating the model through views as and when it is needed by the user interactions. The controller can invoke the model to perform the updations. The controller interprets the inputs from the user carry forward these inputs and maps these into common commands that are to be sent to the model.

Explain the benefits of MVC pattern.

1. Separation of concerns:
- The separation the three components, allows the re-use of the business logic across applications.
- Multiple User Interfaces can be developed without concerning the codebase

2. Developer specialization and focus:
- The developers of UI can focus exclusively on the UI screens without bogged down with business logic.
- The developer of Model / business can focus exclusively on the business logic implementations, modifications, updations without concerning the look and feel and it has nothing to with business logic.

3. Parallel development by separate teams:
- Business logic developers can build the classes, while the UI developers can involve in designing UI screens simultaneously, resulting the interdependency issues and time conservation.
- UI updations can be made without slowing down the business logic process
- Business logic rules changes are very less that needs the revision / updations of the UI.

Explain the disadvantages of MVC pattern.

  • 1. The complexity is high to develop the applications using this pattern.
  • 2. Not right suitable for small applications which has adverse effect in the application's performance and design.
  • 3. In terms of servlet and JSP, both often contains business logic and presentation tier.
  • 4. The isolated development process by UI authors, business logic authors and controller authors may leads to delay in their respective modules development.

Explain the 3 MVC framework that are within JFace, i.e. JFace viewers, JFace text

The implementation of MVC framework in JFace is done by using content provider and label provider.

JFace viewer:
The JFace viewer framework is an independent module for JFace which needs some knowledge of SWT. The abstract base classes for viewers comprise the framework. The base class is the Viewer which is an extension of a structured viewer. The Viewer acts as a widget container. It is the responsibility for the content provider to respond to the various modifications to the model by informing the viewer, what to change (using add () and remove () methods).

Each viewer registers with the label provider for identifying / notifying the changes that would affect the viewers display.

JFace Text:
The JFace text provides a framework for the creation and manipulation of text documents. IDocument is the major abstraction for the text model. The content management, position management using portion categories, document partition management, and change notification is provided by this text model.

The changes / notifications are identified by mandatorily implementing the IDocumentListener and registering with the document. The position and partition updating actions are implemented by using IDocumentPositionUpdater and IDocumentPartitioner.

Explain how SWT's event handling is different from that of Swing.

Swing: GUI tool kit for JSE.
SWT: Developed by IBM for Eclipse platform

Swing event handling:
Swing's events are thread based. An event dispatch thread is responsible for handling events. The container had to check the actual source for each event before processing. An event may be handled by one or more containers and may cause complexity while handling the situation.

SWT event handling:
The SWT components or their events are not thread safe.
The SWT events are based on the native application which increases performance. The SWT event handling loop reads and dispatches the concerned GUI events.
In SWT the UI-thread (ex. Display instance) handles the events from the operating system event queue by invoking the appropriate events.

Describe how Display class plays the most important role in SWT event handling.

The Display class instances are responsible for the complete management of connections between SWT and the underlying operating system. The implementation of the SWT event looping is the most important function of the Display class. The Display class has various methods to obtain information about the underlying operating system. This class controls the OS resources which were allocated by the SWT completely.

What are SWT Layouts?

A layout controls the display / appearance / look of a window. A layout controls the position of the GUI components.

Explain the four standard layouts and one custom layouts provided in SWT.

The following are the layouts that are supported in SWT.

FillLayout: It is the simple layout class. It arranges the widgets in a single row and a column with the same size. FillLayout can be used to arrange the buttons in a task bar, tool bar or to stack the checkboxes in a group.

RowLayout: This layout is used instead of FillLayout. The reason it is having the ability to wrap and provides the margins and spacing. It has no. of configurable fields and the height and width of each widget can be specified.

GridLayout: Using this layout, the widgets are placed / arranged in a grid. It has the features of RowLayout, in addition to it the widgets can have an associated layout data object called DataGrid. It is the power of GridLayout that the GridData can configure and controlled for each widget. The widgets are arranged in columns from left to right. A new row will be created when the no. of columns are increased by one than the size of the row.

FormLayout: FormAttachments creation for each side of the widget, and placing them in the layout data, makes the working of FormLayout. This layout provides the flexibility while arranging widgets because it allows to metion the placements of individual widgets within the layout.

StackLayout: StackLayout places the entire controls one on top of the another and makes all the controls to have the same size. The top most control is only visible and others will be hidden.

Comments

Popular posts from this blog

Asynchronous Vs. Synchronous Communications

Synchronous (One thread):   1 thread -> |<---A---->||<----B---------->||<------C----->| Synchronous (multi-threaded):   thread A -> |<---A---->| \ thread B ------------> ->|<----B---------->| \ thread C ----------------------------------> ->|<------C----->|

WebSphere MQ Interview Questions

What is MQ and what does it do? Ans. MQ stands for MESSAGE QUEUEING. WebSphere MQ allows application programs to use message queuing to participate in message-driven processing. Application programs can communicate across different platforms by using the appropriate message queuing software products. What is Message driven process? Ans . When messages arrive on a queue, they can automatically start an application using triggering. If necessary, the applications can be stopped when the message (or messages) have been processed. What are advantages of the MQ? Ans. 1. Integration. 2. Asynchrony 3. Assured Delivery 4. Scalability. How does it support the Integration? Ans. Because the MQ is independent of the Operating System you use i.e. it may be Windows, Solaris,AIX.It is independent of the protocol (i.e. TCP/IP, LU6.2, SNA, NetBIOS, UDP).It is not required that both the sender and receiver should be running on the same platform What is Asynchrony? Ans. With messag...

Advantages & Disadvantages of Synchronous / Asynchronous Communications?

  Asynchronous Communication Advantages: Requests need not be targeted to specific server. Service need not be available when request is made. No blocking, so resources could be freed.  Could use connectionless protocol Disadvantages: Response times are unpredictable. Error handling usually more complex.  Usually requires connection-oriented protocol.  Harder to design apps Synchronous Communication Advantages: Easy to program Outcome is known immediately  Error recovery easier (usually)  Better real-time response (usually) Disadvantages: Service must be up and ready. Requestor blocks, held resources are “tied up”.  Usually requires connection-oriented protocol