Tuesday, August 28, 2012

JMS

Introduction


Message and messaging:
In general, message is an object whose existence is useful until used and messaging is a way through which message is used.
Technically, messaging is a method or way of communication between two or more applications. We can say that it is a peer to peer facility where a client send message to and receive message from, any other client. Each client connects to a messaging agent that provides facilities for creating, sending, receiving, and reading messages. Messaging enables loosely coupled architecture. In loosely coupled, the sender and receiver needs not be available at the same time in order to communicate. Sender and receiver don’t need to know anything about each other. They need to know the message format and destination to be used.

Sunday, August 26, 2012

AJAX

What is Ajax?

AJAX
=A+JA+X
=Asynchronous +JavaScript+XML
= Asynchronous + (JavaScript+XML)
=Group of interrelated web development techniques to create asynchronous web application

Definition
AJAX is group of technologies which implements web application that communicates with the server in the background without interfering with the current state of page.

UI Shifting

                             
Why Ajax?

When we use HTML for web application each client action required that the page be re-loaded from the server. In this process all page content disappears then reappears. Each time a page is reloaded due to a partial change, all of the content must be re-sent instead of only the changed information. If we want to display some specific part of the page, we have to reload the page. This leads additional load on the server and use excessive bandwidth.

To avoid this complexity, a new technology came into web picture that implements the web application in the background without interfering the exiting states of page.

Component of Ajax
Ajax is having following components
1. JavaScript
2. HTML and CSS
3. XML
4. DOM
5. XmlHttpRequest object

Here HTML and CSS is used as markup and style information.DOM is used to display dynamically and allow user to interact with the information.DOM is used with JavaScript. JavaScript and XmlHttpRequest object provide a method for exchanging the data asynchronously between client and server to avoid full page reload. JavaScript brings these technologies together.

What is postback?
When a client sends a request to a server, the server sends a response back to the client. This entire process of request and response is called postback. There are two types of postback.


Synchronous Postback
This is normal postback. Here the entire content of webpage is sent to the server and in response the server sends the required response to the client.


Asynchronous Postback
Asynchronous means we make a request to a server and perform other actions while the server is processing your request -- and on the arrival of the response required actions is performed. Here instead of sending entire information to the server, only the specific information is sent to the server as a request. So only a particular portion of webpage is updated with the new information and rest of the page remains same. This is called partial update. In this process web page uses XmlHttpRequest object to send the request to the server.

Architecture of AJAX

When a client sends initial request to server, in response page is loaded with AJAX Engine. Then after client send request to AJAX Engine through JavaScript call and AJAX Engine forward request to the server through XmlHttpRequest object. The server send response as Xml response and AJAX Engine parse the response and sends to the client as HttpResponse.Here AJAX Engine is only JavaScript function which uses XmlHttpRequest to sends the request to the server.


ADRotator

AdRotator
This control is used to display a sequence of rotating ad images. Whenever you refresh the page it will show new image. It uses an XML file to store the ad information. The XML file must begins and end with an .Inside the tag there may be several tags which defines each ad


Element
The predefined elements inside the tag are listed below.
<ImageUrl> Optional. The path to the image file.
<NavigateUrl>Optional.The URL to link to if the user clicks the ad
<Alternate Text>Optional. An alternate text for the image
<Keyword>Optional. A category for the ad
<Impressions>Optional.The display rates in percent of the hits.

Property

Some properties of this control:
AdvertisementFile: Specifies the path to the XML file that contains ad information.
AlternateTextField: Specifies a data field to be used instead of the Alt text for an ad
ImageUrlField: Specifies a data field to be used instead of the ImageURL attribute for an ad
KeywordFilter: Specifies a filter to limit ads after categories.
NavigateUrlField: Specifies a data field to be used of the NavigateUrl attribute for an ad

The steps to display advertisement by using AdRotator control.

1. Select images what you want to select but each image should have fixed dimension (size).Here we have taken three images google.jpg (200, 75), Microsoft.jpg (200, 75) and oracle.jpg (200, 75).
2. Start Visual Studio.Net
3. Create a new ASP.NET Web Application

4.      Change its name to Advertisement
5.In Solution Explorer, right click on project name and select Add New Item
6.'Add New Item Window' will come. Select XML File template and change its name to Ad.xml
7.Add new folder named as Images and place the images that we want to use for advertisement. Open the   Ad.xml and places the code shown in figure.                          

8.Open the design view of default.aspx and drag AdRotator control from the Toolbox. Reposition the control to Top Center and resize it to size as the images what we have taken(200,75)
9.Click AdRotator1 and then press F4 key to view its properties. 10.Set the AdvertisementFile property to Ad.xml
11.Save Default.aspx and build and run the project.
After refreshing the page we  will get other ad.

JDBC

Introduction


JDBC is an API that helps java programmer to write java program to connect to a database, retrieve the data from form the database and perform various actions on the data in the java program.

Process of Java program to connect database through JDBC

Java program calls JDBC library.JDBC loads driver and driver talks to database.
The various classes used by java program to connect database in various steps of JDBC program are in following figure.


The following steps used by java program to connect to database using JDBC:


Registering the driver A database driver is a collection of classes and interfaces written according to JDBC API.Since there are several drivers available in the market, we should first decide the driver that would be used for communication with the database server in a java program.

Connecting to database
We establish a connection with the help of driver selected in prev. step.

Preparing SQL statements
We create SQL statement using any of the interfaces like Statement, Preparedstatement and CallableStatement available in Java.sql package.

Execute the SQL statements on the database
We use execute (), executeQuery () and executeUpdate () of statement interface.

Retrieving the results
The result obtained by executing the SQL statement can be stored in an object with the help of interfaces like ResultSet, ResultSetMetaData etc.

Closing the connection
We should close the connection between java program and database by using close() method.

Types of JDBC Driver

There are four types of java driver
Type 1: JDBC-ODBC Bridge Driver
This driver receives any JDBC calls and sends to ODBC driver. ODBC driver understands these calls and communicate with the database library.


Type 2: Native API-Partly Java Driver
It converts JDBC calls into database specific calls with the help of vendor database library. It communicates directly with the database server. So need of some binary code should be present in client machine.

Type 3: Net Protocol Pure Java Driver

It follows a three tier architecture where JDBC requests are passed through the network to a middle tier server. The middle tier server translates the request into database specific library and sends into the database server. The database server executes the request and gives back the results.
Type 4: Native Protocol Pure Java Driver

It converts JDBC calls into vendor specific database management system protocol so that client application communicates directly with the database server. This is completely implemented in Java to achieve platform independent.




Saturday, August 25, 2012

JNDI Architecture

The JNDI is an API that provides a standard protocol for accessing and sharing any network resources and its file structure in internet/Intranet and supports accessing a variety of naming and directory services. The purpose of naming service is to associates names with objects and provides access to objects through mapping a unique id to each object and its name.


The ranges of objects in a naming system can from files in a file system and names located in Domain Name System records, to Enterprise JavaBeans components in an application server and user profiles in Lightweight Directory Access Protocol directory. If you want to use Java to write an application such as a network-enabled desktop, an application launcher, a search utility, a network management utility or anything that accesses objects in a naming system then JNDI is a good architecture for writing that application.

Architecture

The architecture of JNDI is like the JDBC architecture, in which both provide a standard protocol-independent API built on top of protocol-specific driver or provider implementations. It consists of the JNDI API and the JNDI SPI. The JNDI API allows Java applications to access a variety of naming and directory services. The JNDI SPI is designed to be used by arbitrary service providers including directory service providers. This enables a variety of directory and naming services to be plugged in transparently to the Java application which uses only the JNDI API.


EJB Architecture

Component Model
Component has become new trend nowadays in software engineering. Component is self contained element of software that can be controlled dynamically. The basic concepts behind components are to build applications from reusable units that can easily be distributed by interoperating according to a set of rules and regulation.

Java Beans: Component Architecture for Java.
Java beans are Java’s component model. It allows users to construct applications by piecing components together either programmatically or visually (or both).It has the ability to write applications quickly and easily by using a palette of components that can be assembled to form larger applications. It is right to say that any component you can imagine can be written as a JavaBean, and then plugged into an application. If you know how to write software in Java, you know how to use and create Beans The model is made up of architecture and an API (Application Programming Interface). Together, these elements provide a structure whereby components can be combined to create an application.

EJB Architecture
When a client sends a request to server through jsp, container sees that request is for servlet and then creates two objects HttpServletResponse and HttpServletRequest. The container finds the correct servlet and creates a thread for that request but before passes the request and response object to the servlet thread, it passes to filter chain to intercepts and process the request .The servlet is having no knowledge of filter. After filtering the request the container passes the request and response object to the servlet thread and calls the service () of servlet depending on the type of request. Depending on the request servlet container passes the request to EJB container. But client never calls any of its requests directly. So when client sends a request to EJB object through servlet EJB container generates two objects EJB object and Home object which manage the service like Security, Persistence etc. and delegate the request to the associated beans(session, entity and message driven) instances. Home object hides the actual location of EJB object. So client access only that EJB objects that are stored at different location by the home object. Depends on the beans request goes to database through JDBC and fetch response from database and sends to EJB objects and then response goes to particular servlet. Thread completes and converts the response object to HTTP Response and sends back to the filter chain and again filter chain process the response and response sends to the client, then delete the request and response object. Finally client accepts response from servlet through JSP.





Wednesday, August 22, 2012

.Net framework 4.5:New features

Some new features are
1. .NET for Windows Store Application
2.  Portable Class Libraries
3.  Core New Features and Improvements
4.  Tools
5.  Parallel Computing
6.  Web
7.  Networking
8.  Windows Presentation Foundation(WPF)
9.  Windows Communication Foundation(WCF)
10.Windows Workflow Foundation(WF) etc..

Java 8:New features

Java 8 is being actively developed by Oracle.

Some new features are
1. Lambda expression (“Closures”)
2. Jigsaw- a native module system to simplify the construction, packaging and deployment of applications
3. Small language enhancements (Remaining parts of “Project Coin”)
4. Swing application framework- an API that would eliminate lots of boilerplate code and providing a much-improved initial developer experience
5. JVM start-up time and ergonomics improvements



Friday, August 17, 2012

Java EE Architecture

First of all, we will say J2EE is not a product. Rather it is specification that defines the standard for the development of multitier enterprise applications in Java.


Formation of Architecture

Whenever we think about client-server concept then immediately first thing come in picture that there is a client asks for a resource to server. Here at least two things can happen.
1. Server provides that particular resource to client and
2. Server is not able to find what client asked for.
But in both cases server has to respond and I am sure that you have seen ‘404 not found’ error whenever you have tried to open a page and server didn’t find that page.

Whenever server sends a response, it sends some types of content (set of instruction written in HTML) and through HTTP.HTML tells the browser how to represent the content sent by server to user.

When browser sends a request to server for server, the server hands the request not to servlet itself but to container in which servlet is deployed.

Now question is how container handles servlet? Let’s see.

When a client send a request to server container sees that request is for servlet and then creates two objects HttpServletResponse and HttpServletRequest. The container finds the correct servlet and creates a thread for that request but before passes the request and response object to the servlet thread, it passes to filter chain to intercepts and process the request .The servlet is having no knowledge of filter. After filtering the request the container passes the request and response object to the servlet thread and calls the service () of servlet depending on the type of request. Thread completes and converts the response object to HTTP Response and sends back to the filter chain and again filter chain process the response and response sends to the client, then delete the request and response object.

Note: Request filter can perform security checks, reformat the request header and body and audit or log request. Response filter can compress the response stream and creates a different response altogether.

JVM Architecture

JVM is the main part of Java architecture and is the part of JRE(Java Runtime Environment).It is a component of the Java system that interprets and executes in our class files.
Memory configuration by the JVM
Each instance of the JVM has one method area, one heap and one or more stacks -one for each thread. When JVM loads a class files, it puts its information in the method area. As the program runs, all objects instantiated are stored in the heap. The stack area is used to store activation records as a program runs.
 Contents of memory Block at runtime
The class loader performs three main functions of JVM, namely: loading, linking and initialization. The linking process consists of three sub-tasks,namely,verification,preparation and resolution.
                                                     Class loading processes
Class loading process
Loading means reading the class file for a type, parsing it to get its information, and storing the information in the method area.The end of the loading process is the creation of an instance of java.lang.Class for the loaded type. The purpose is to give access to some of the information captured in the method area for the type, to the programmer.
The next process handled by the class loader is Linking. This involves three sub-processes: 1.Verification,
2.Preparation and
3.Resolution
Verification is the process of ensuring that binary representation of a class is structurally correct.
Preparation is the process of allocating memory by JVM for the class (i.e static) variables and sets them to default initial values.



Sunday, August 12, 2012

Architecture

Java Architecture

Java is the foundation for virtually every type of network application and is the global standard for developing and delivering mobile applications, games, Web based content and enterprise software.

When we think about architecture of Java then at least three things come into picture:
1. Java programming language
2. Java Class files
3. Java Virtual Machine

Suppose we write a java program a.java using Java. After compilation compiler produces a.class which contains byte code instructions. These byte code instructions are given to JVM to understand that which processor used. After that JVM converts byte code into machine code that is compatible to processor which is used to write a.java.

                   
                                                    

Copyright © Codingnodes,2014.All Rights Reserved.