Monday, May 10, 2010

FAQs related to Application Server, JMS

What is the job of Application Server?
The role of Application Server is to process business logic components deployed as EJB (Java / J2EE applications).

Which are the prominent Application Servers available in market?
Oracle Application Server, IBM Webshphere Application Server, BEA Web Logic

What do you mean by OC4J ?
Oracle Container for Java - OC4J is J2EE certified and provides all the containers, APIs, and services that J2EE specifies

What is a Web Service?
The term Web services describes a standardized way of integrating Web-based applications using the XML, SOAP, WSDL and UDDI open standards over an Internet protocol backbone. XML is used to tag the data, SOAP is used to transfer the data, WSDL is used for describing the services available and UDDI is used for listing what services are available. Used primarily as a means for businesses to communicate with each other and with clients, Web services allow organizations to communicate data without intimate knowledge of each other's IT systems behind the firewall.


What is WSDL ?
WSDL is a document written in XML. The document describes a Web service. It specifies the location of the service and the operations (or methods) the service exposes.

What is XSD ?
XSD (XML Schema Definition), a Recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. This description can be used to verify that each item of content in a document adheres to the description of the element in which the content is to be placed. An XML schema represents the interrelationship between the attributes and elements of an XML object
XSD has several advantages over earlier XML schema languages, such as document type definition (DTD) or Simple Object XML (SOX). For example, it's more direct: XSD, in contrast to the earlier languages, is written in XML, which means that it doesn't require intermediary processing by a parser. Other benefits include self-documentation, automatic schema creation, and the ability to be queried through XML Transformations (XSLT)

What is RPC?
Remote Procedure Call. The ability to call a procedure residing on remote system from local system.

What do you mean by STUB ?
There is CLIENT STUB and SERVER STUB. RPC's essential concept is hiding all the network code in the stub procedures. "RPGGen" . Sun RPC offers a program called rpcgen, which takes a specification of a remote procedure and converts it to C programs containing all the network information to process the request.

What is Orion Server?
Orion is an Application Server

What is JNDI?
The Java Naming and Directory Interface (JNDI) is a Java API for a directory service that allows Java software clients to discover and look up data and objects via a name. Like all Java APIs that interface with host systems, JNDI is independent of the underlying implementation.

What is JMS?
Java messaging service is the standard API for sending and receiving messages. JMS is the standard messaging API for passing data between application components and allowing business integration in heterogeneous and legacy environments.
JMS provides two messaging domains, each associated with a JMS destination type, and a domain-specific set of Java interfaces:
Point-to-Point—Messages are sent to a single consumer using a JMS queue.
Publish/Subscribe—Messages are broadcast to all registered listeners using a JMS topic.
JMS destination objects are bound in the JNDI environment and made available to J2EE applications.

What does a JMS application typically consist of?
A JMS application is composed of the following parts:
JMS Provider - a messaging system that implements the JMS API in addition to the other administrative and control functionality required of a full-featured messaging product
JMS Clients - the Java language programs that send and receive messages
Messages - objects that are used to communicate information between the clients of an application
Administered Objects - provider-specific objects that clients look up and use to interact portably with a JMS provider
Non-JMS Clients - clients that use a message system's native client API instead of the JMS API. If the application predated the availability of the JMS API, it is likely that it will include both JMS clients and non-JMS clients.
How does JMS client execute?
A typical JMS client executes the following setup procedure:
Use JNDI to find a ConnectionFactory object
Use JNDI to find one or more Destination objects
Use the ConnectionFactory to create a JMS Connection with message delivery inhibited
Use the Connection to create one or more JMS Sessions
Use a Session and the Destinations to create the MessageProducers and MessageConsumers needed
Enable the Connection to start delivering messages to MessageConsumers

What is the difference between Quartz and Flux?
Java developers embed Flux in their applications to enable Job Scheduling, File Transfer, and Workflow. Flux is an embeddable, pure Java solution that increases productivity by meeting the challenges of Job Scheduling, File Transfer, and Workflow. By combining Flux's APIs and user-friendly graphical interfaces, Flux becomes the "engine" that enables highly scalable solutions. It is used in a variety of applications by customers across multiple industry sectors. Examples:
In banking operations, end of day reports need to be run after the close of the stock exchange. Flux can be used to schedule the time the report is to be run, kick off the report generation, and then email the report to the appropriate people

What is Context Factory?
There are two initial context factories that are used for OC4J. They are ApplicationClientInitialContextFactory, RMInitialContextFactory.
The ApplicationClientInitialContextFactory is used when looking up remote objects from standalone application clients. It uses the refs and ref-mappings found in application-client.xml and orionapplication-client.xml. It is the default initial context factory when the initial context is instantiated in a Java application. It can be used for looking up remote EJBs in the same application. It can also be used for looking up EJBs with local interface.

The RMIInitialContextFactory is used when looking up remote objects between different containers. It is also used when browsing the complete JNDI namespace and not using the application context.

What is Connection Factory?
A ConnectionFactory object encapsulates a set of connection configuration parameters that has been defined by an administrator. A client uses it to create a connection with a JMS provider ( eg IBM MQ Series).
A ConnectionFactory object is a JMS administered object and supports concurrent use.
JMS administered objects are objects containing configuration information that are created by an administrator and later used by JMS clients. They make it practical to administer the JMS API in the enterprise.
Although the interfaces for administered objects do not explicitly depend on the Java Naming and Directory Interface (JNDI) API, the JMS API establishes the convention that JMS clients find administered objects by looking them up in a JNDI namespace.
All Known Subinterfaces:
QueueConnectionFactory, TopicConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory


What is difference between Managed and Native Data Source?
A managed data source is one where OC4J provides critical system infrastructure such as global transaction management, connection pooling, statement caching and error handling. A native data source is one that implements the java.sql.DataSource interface and does not make use of OC4J's connection pooling or statement caching capabilities. A native data source can only participate in local transactions.

What is difference between XA and non XA Datasource ?
XA Datasource represents Managed Connection , Connection pool creation is required when an XA Datasource is to be created.
An XA data source is a data source that can participate in an XA global transaction.
A non-XA data source generally can't participate in a global transaction.
An XA transaction, in the most general terms, is a "global transaction" that may span multiple resources. A non-XA transaction always involves just one resource. An XA transaction involves a coordinating transaction manager, with one or more databases (or other resources, like JMS) all involved in a single global transaction. Non-XA transactions have no transaction coordinator, and a single resource is doing all its transaction work itself (this is sometimes called local transactions).

What is the purpose of importing/exporting shared library oracle.xml in different modes of gateway deployments?
A shared library consists of a set of code-sources from which Java classes can be loaded by a class loader. A shared library has a name and a version. By default, an application deployed to OC4J inherits a number of pre-defined shared-libraries. Oracle.xml is a shared library


What is the use of Resource Adapter?
A resource adapter is a driver that an application server or an application client uses to connect to a specific EIS. Examples of resource adapters are a JDBC driver to connect to a relational database, an ERP resource adapter to connect to an ERP system, and a transaction processing (TP) resource adapter to connect to a TP monitor. The J2EE 1.3 specification requires application servers to support both standalone and embedded resource adapters.


What protocols can I use to access an EJB remotely?
You can use three protocols to access EJBs remotely. You can use ORMI (Oracle's implementation of RMI
Protocol) for Java clients, ORMI over SSL, RMI-IIOP for CORBA clients or ORMI tunneling over HTTP to
access EJBs from remote client through firewall. See the OC4J Services Guide for more information.

What is the use of ra.xml file?
The ra.xml descriptor is the standard J2EE deployment descriptor for resource adapters

What is oc4j-ra.xml?
The oc4j-ra.xml descriptor provides OC4J-specific deployment information for resource adapters. The file contains one or more elements.
You can do the following using oc4j-ra.xml:
Configure and bind instances of connection factories.
Connection factories are used by application components to obtain connections to the EIS. The name of the connection factory class is specified in the connectionfactory-impl-class element, defined in ra.xml. OC4J allows the deployer to configure instances of this class and to bind them to the Java Naming and Directory Interface (JNDI) name space.
The deployer can do this by creating elements and assigning a JNDI location to each using the location attribute. The deployer can also configure each instance using elements.
The list of configurable properties is specified in ra.xml, as elements. The deployer can either specify or override values for these properties in oc4j-ra.xml, using elements.

How many Deployment Descriptors are there for Resource Adapter?
OC4J supports three deployment descriptors: ra.xml, oc4j-ra.xml, and oc4j-connectors.xml. The ra.xml descriptor is always supplied with the resource adapter. Whenever you deploy a resource adapter, OC4J generates oc4j-ra.xml if the file doesn't already exist in the archive. In addition, for an embedded resource adapter, OC4J generates oc4j-connectors.xml if it doesn't exist in the archive.


What do you mean by administered objects?
There are two types of JMS administered objects:
ConnectionFactory - the object a client uses to create a connection with a provider
Destination - the object a client uses to specify the destination of messages it is sending and the source of messages it receives
· Administered objects are placed in a Java Naming and Directory InterfaceTM (JNDI) namespace by an administrator. A JMS client typically notes in its documentation the JMS administered objects it requires and how the JNDI names of these objects should be provided to it.

Java Servlet

Java servlets
Servlets are protocol and platform independent server-side software components, written in Java. They run inside a Java enabled server or application server, such as the WebSphere Application Server. Servlets are loaded and executed within the Java Virtual Machine (JVM) of the Web server or application server, in much the same way that applets are loaded and executed within the JVM of the Web client. Since servlets run inside the servers, however, they do not need a graphical user interface (GUI). In this sense, servlets are also faceless objects.
Servlets more closely resemble Common Gateway Interface (CGI) scripts or programs than applets in terms of functionality. As in CGI programs, servlets can respond to user events from an HTML request, and then dynamically construct an HTML response that is sent back to the client.

Servlet process flow
Servlets implement a common request/response paradigm for the handling of the messaging between the client and the server. The Java Servlet API defines a standard interface for the handling of these request and response messages between the client and server.
1. The client sends a request to the server.
2. The server sends the request information to the servlet.
3. The servlet builds a response and passes it to the server. That response is dynamically built, and the content of the response usually depends on the client’s request. External resources may also be used.
4. The server sends the response back to the client.

High-level client-to-servlet process flow

Servlets are powerful tools for implementing complex business application logic. Written in Java, servlets have access to the full set of Java API’s, such as JDBC for accessing enterprise databases.
As mentioned above, servlets are similar to CGI in that they can produce dynamic Web content. Servlets, however, have the following advantages over traditional CGI programs:
❑Portability and platform independence: Servlets are written in Java, making them portable across platforms and across different Web servers, because the Java Servlet API defines a standard interface between a servlet and a Web server.
❑Persistence and performance: A servlet is loaded once by a Web server, and invoked for each client request. This means that the servlet can maintain system resources, like a database connection, between requests. Servlets don’t incur the overhead of instantiating a new servlet with each request. CGI processes typically must be loaded with each invocation.
❑Java based: Because servlets are written in Java, they inherit all the benefits of the Java language, including a strong typed system, object-orientation, and modularity, to name a few.

The Java Servlet API
The Java Servlet API is a set of Java classes which define a standard interface between a Web client and a Web servlet. Client requests are made to the Web server, which then invokes the servlet to service the request through this interface. The Java Servlet API is a Standard Java Extension API, meaning that it is not part of the core Java framework, but rather, is available as an add-on set of packages.
The API is composed of two packages:
❑javax.servlet
❑javax.servlet.http
The javax.servlet package contains classes to support generic protocol-independent servlets. This means that servlets can be used for many protocols, for example, HTTP and FTP. The javax.servlet.http package extends the functionality of the base package to include specific support for the HTTP protocol.
The Servlet interface class is the central abstraction of the Java Servlet API. This class defines the methods which servlets must implement, including a service() method for the handling of requests. The GenericServlet class implements this interface, and defines a generic, protocol-independent servlet. To write an HTTP servlet for use on the Web, we will use an even
more specialized class of GenericServlet called HttpServlet.HttpServlet provides additional methods for the processing of HTTP requests such as GET (doGet method) and POST (doPost method). Although our servlets may implement a service method, in most cases we will implement the HTTP specific request handling methods of doGet and doPost.

The servlet life cycle
A client of a servlet-based application does not usually communicate directly with a servlet, but requests the servlet’s services through a Web server or application server that invokes the servlet through the Java Servlet API. The server’s role is to manage the loading and initialization of the servlet, the servicing of the request, and the unloading or destroying of the servlet. This is generally provided by a servlet manager function of the application server.Typically, there is one instance of a particular servlet object at a time in the
Web servers’ environment. This is the underlying principle to the persistence of the servlet. The Web server is responsible for handling the initialization of this servlet when the servlet is first loaded into the environment, where it remains active (or persistent) for the life of the servlet.Each client request to the servlet is handled via a new thread against the original instance object. The Web server is responsible for creating the new threads to handle the requests. The Web server is also responsible for the unloading or reloading of the servlets. This might happen when the Web application is brought down, or the underlying class file for the servlet changes, depending on the underlying implementation of the server.
❑Servlet1 is initially loaded by the Web application server. Instance variables are initialized, and remain active (persistent) for the life of the servlet.
❑Two Web browser clients have requested the services of Servlet1. A handler thread is spawned by the server to handle each request. Each thread has access to the originally loaded instance variables that were initialized when the servlet was loaded.
❑Each thread handles its own requests, and responses are sent back to the calling client.
basic client-to-servlet interaction
The life cycle of a servlet is expressed in the Java Servlet API in the init, service (doGet or doPost), and destroy methods of the Servlet interface. We will discuss the functions of these methods in more detail and the objects that they manipulate.

Life-cycle of an individual servlet.
The WebSphere administrator can set an application and its servlets to be unavailable for service. In such cases, the application and servlets remain unavailable until the administrator changes them to available.