Saturday, March 21, 2009

What is class Loader in java, it's functions and importance??

Class loaders offer a very powerful mechanism by which classes can be loaded at runtime. Its power lies in its extensibility, i.e. custom classes needed for the application can be loaded in addition to the basic classes loaded by bootstrap loader. But with such powerful tool comes some security problems as well. Its important for application developers to understand the functioning of classloaders to make their application efficient and and it will also make debugging easy.


One of the main features of java is "Write Once and Run Anywhere". The
Java Virtual Machine (JVM) is responsible for loading and executing the code. For this purpose, it uses the java class loader. The java class loaders are responsible for loading appropriate classes in the JVM at the runtime. In a JVM, each and every class is loaded by some instance of a
java.lang.ClassLoader. The main feature of the classloader is that JVM.
doesn’t need to have any knowledge about the classes that will be loaded at runtime. ClassLoaders support features like hot deployment and run time platform e extensibility. The next section explains how a class loader works.

Class Loader Functioning:


A class file is the smallest unit that gets loaded by the class loader. It contains binary representation of a java class
and contains bytecodes and links to other class files that will be used. Class loader reads this bytecode and creates the instance of
java.lang.Class. When the JVM starts, initially only the class file is loaded and other classes are loaded as and when required by the JVM. In this process, JVM is initially
unaware of what classes will be loaded later on. Lazy loading plays a key role in providing dynamic extensibility to the Java platform.
In lazy loading, dependents are only loaded as they are specifically
requested.

Different class loaders are responsible for loading different classes from different repositories.

  1. First the " bootstrap class " loader loads the key classes
  2. Next comes the " java extension class "loader. It loads the libraries, which are not part of the core java run time.
  3. The ExtClassLoader is responsible for loading all .jar files kept in the java.ext.dirs path.
  4. Finally, developer , can add his own custom classes needed by the application .

Figure 1 below explains hierarchy of different class loaders.

Java ClassLoader Hierarchy

Figure 1: Hierarchy of class loaders

The process of loading of a class by a class loader is not standalone process. Its a 3-step process.

  1. Loading
  2. Linking
  3. Initialization

Loading is the process of locating the binary representation of a type and bringing it into the JVM. Linking is the process of taking the type and incorporating it into the runtime state of the JVM so that it can be executed. Initialization is the process of executing the initializers of a type (static initializers for classes; static field initializers for classes and interfaces). Once a class becomes unreachable it is available for garbage collection.

The next section deals with how the requested class is searched and loaded by a class loader

How Class Loader Works:

When a client requests to load a particular class, a check is performed by the class loader to see whether the requested class is already loaded. If the class is already loaded then loaded class is returned and
the request ceases. However if the class is not loaded, then the request is sent to the parent class loader to search for the requested class. This request for search can go up to
the level of bootstrap loader (highest in the hierarchy). If the parent is
successful in finding the class then that class is returned and the
request ceases, but if that does not work out, then the current class
loader has to find the requested class.

Each class loader has a specific location for searching the class. e.g
bootstrap loader searches for folders, zips and jars. The methods that are
invoked to search for and load the requested class are

  1. protected Class findClass (String className) throws ClassNotFoundException
  2. public class loadClass (String className) throws ClassNotFoundException

Thursday, March 19, 2009

Action class of Struts Framework


Struts Action class :

An Action class in the struts application extends Struts 'org.apache.struts.action.Action" Class. Action class acts as wrapper around the business logic and provides an interface to the application's Model layer. It acts as glue between the View and Model layer. It also transfers the data from the view layer to the specific business process layer and finally returns the processed data from business layer to the view layer.

An Action works as an adapter between the contents of an incoming HTTP request and the business logic that corresponds to it. Then the struts controller (ActionServlet) slects an appropriate Action and creates an instance if necessary, and finally calls execute method.

Lost data Recover From Hard Disk...

Data Recovery is just like a way to get back and grab the important information that got lost during a computer crash, virus attack or hard disk failure. Whatever maybe the scale of data to be recovered, it is an important and essential part of any operating system. Data is always precious, whether it is for a single user or for a big corporate house; every one needs the retrieval of their precious lost data.

Lost data recovery is possible due to the way the operating system of Microsoft windows is designed. Whenever you delete a file, windows only removes that file from the file system table and keeps track of all the files on your hard disk. There are often some emergent situations when the data recover becomes very essential. Such type of situations arises in case of critical floods, fires and explosions that lead to the data disaster.

One of the ways to recover the lost data is through the system of file data recovery. In this process it is assumed that the tasks that are done while emptying the recycle bin can be reversed. Generally when a file gets deleted, the attribute of the space from an occupied status to an available status used by the file are changed by the operating system. Files are generally lost during a power failure, a hardware crash or sometimes due to a human mistake. Some of these can be recovered based on the extent of damage and the amount of data lost.

Another way is through data disk recover that most people want to settle for. In case data recovery dos not become possible there can be risk to our business or personal work. There are some data recovery software solutions available and the need is to select the best among it according to number of benefits you derive from software. Such software helps you to restore the files.

Wednesday, March 18, 2009

Situations for using Interface and Abstract class

Primary Difference between an Interface and an Abstract class.

• an abstract class can have a mix of abstract and non-abstract methods, so some default implementations can be defined in the
abstract base class. An abstract class can also have static methods, static data, private and protected methods, etc. In other words, a
class is a class, so it can contain features inherent to a class. The downside to an abstract base class, is that since their is only single
inheritance in Java, you can only inherit from one class.
• an interface has a very restricted use, namely, to declare a set of public abstract method singatures that a subclass is required to
implement. An interfaces defines a set of type constraints, in the form of type signatures, that impose a requirement on a subclass to
implement the methods of the interface. Since you can inherit multiple interfaces, they are often a very useful mechanism to allow a
class to have different behaviors in different situations of usage by implementing multiple interfaces.
It is usually a good idea to implement an interface when you have any methods that are to be overridden by some
subclass. If you then want some of the methods implemented with default implementations that will be inherited by
a subclass, then create an implementation class for the interface.
interface X {
void f();
int g();
}
class XImpl implements X {
void g() { return -1; } // default implementation for g()
}
class Y extends XImpl implements X {
void f() { ... } // provide implementation for f()
}
Note that when you invoke an abstract method using a reference of the type of an abstract class or an interface, the
method call is dynamically dispatched.
X x = new Y;
x.f(); // dynamically determines which f() to invoke, and calls Y.f(this=(Y)x);

Thursday, March 12, 2009

What is object oriented

Object-oriented programming (OOP) is a programming paradigm that uses "objects" and their interactions to design applications and computer programs. Programming techniques may include features such as information hiding, data abstraction, encapsulation, modularity, polymorphism, and inheritance. It was not commonly used in mainstream software application development until the early 1990s. Many modern programming languages now support OOP.

Object-oriented programming can trace its roots to the 1960s. As hardware and software became increasingly complex, quality was often compromised . Researchers studied ways to maintain software quality and developed object-oriented programming in part to address common problems by strongly emphasizing discrete, reusable units of programming logic. The methodology focuses on data rather than processes, with programs composed of self-sufficient modules (objects) each containing all the information needed to manipulate its own data structure. This is in contrast to the existing modular programming which had been dominant for many years that focused on the function of a module, rather than specifically the data, but equally provided for code reuse, and self-sufficient reusable units of programming logic, enabling collaboration through the use of linked modules (/subroutines) . This more conventional approach, which still persists, tends to consider data and behavior separately.
An object-oriented program may thus be viewed as a collection of cooperating objects, as opposed to the conventional model, in which a program is seen as a list of tasks (subroutines) to perform. In OOP, each object is capable of receiving messages, processing data, and sending messages to other objects and can be viewed as an independent 'machine' with a distinct role or responsibility. The actions (or "operators") on these objects are closely associated with the object. For example, the data structures tend to carry their own operators around with them (or at least "inherit" them from a similar object or class).
The Simula programming language was the first to introduce the concepts underlying object-oriented programming (objects, classes, subclasses, virtual methods, coroutines, garbage collection, and discrete event simulation) as a superset of Algol. Simula was used for physical modeling, such as models to study and improve the movement of ships and their content through cargo ports. Smalltalk was the first programming language to be called "object-oriented".[

Monday, March 9, 2009

Bura Na Mano Holi Hai....Holi Hai...

Holi - the festival of colors - is undoubtedly the most fun-filled and boisterous of Hindu festival. It's an occasion that brings in unadulterated joy and mirth, fun and play, music and dance, and, of course, lots of bright colors!
Happy Days Are Here Again!With winter neatly tucked up in the attic, it's time to come out of our cocoons and enjoy this spring festival. Every year it is celebrated on the day after the full moon in early March and glorifies good harvest and fertility of the land. It is also time for spring harvest. The new crop refills the stores in every household and perhaps such abundance accounts for the riotous merriment during Holi. This also explains the other names of this celebration - 'Vasant Mahotsava' and 'Kama Mahotsava'.
"Don't Mind, It's Holi!"During Holi, practices, which at other times could be offensive, are allowed. Squirting colored water on passers-by, dunking friends in mud pool amidst teasing and laughter, getting intoxicated on bhaang and reveling with companions is perfectly acceptable. In fact, on the days of Holi, you can get away with almost anything by saying, "Don't mind, it's Holi!" (Hindi = Bura na mano, Holi hai.)
The Festive License!Women, especially, enjoy the freedom of relaxed rules and sometimes join in the merriment rather aggressively. There is also much vulgar behavior connected with phallic themes. It is a time when pollution is not important, a time for license and obscenity in place of the usual societal and caste restrictions. In a way, Holi is a means for the people to ventilate their 'latent heat' and Like all Indian and Hindu festivals, Holi is inextricably linked to mythical tales. There are at least three legends that are directly associated with the festival of colors: the Holika-Hiranyakashipu-Prahlad episode, Lord Shiva's killing of Kamadeva, and the story of the ogress Dhundhi. The Holika-Prahlad EpisodeThe evolution of the term Holi makes an interesting study in itself. Legend has it that it derives its name from Holika, the sister of the mythical megalomaniac king Hiranyakashipu who commanded everyone to worship him. But his little son Prahlad refused to do so. Instead he became a devotee of Vishnu, the Hindu God.
Hiranyakashipu ordered his sister Holika to kill Prahlad and she, possessing the power to walk through fire unharmed, picked up the child and walked into a fire with him. Prahlad, however, chanted the names of God and was saved from the fire. Holika perished because she did not know that her powers were only effective if she entered the fire alone.
This myth has a strong association with the festival of Holi, and even today there is a practice of hurling cow dung into the fire and shouting obscenities at it, as if at Holika.
The Story of Dhundhi It was also on this day that an ogress called Dhundhi, who was troubling the children in the kingdom of Prthu was chased away by the shouts and pranks of village youngsters. Although this female monster had secured several boons that made her almost invincible, shouts, abuses and pranks of boys was a chink in the armor for Dhundi, owing to a curse from Lord Shiva.
The Kamadeva MythIt is often believed that it was on this day that Lord Shiva opened his third eye and incinerated Kamadeva, the god of love, to death. So, many people worship Kamadeva on Holi-day, with the simple offering of a mixture of mango blossoms and sandalwood paste.
Radha-Krishna LegendHoli is also celebrated in memory of the immortal love of Lord Krishna and Radha. The young Krishna would complain to his mother Yashoda about why Radha was so fair and he so dark. Yashoda advised him to apply colour on Radha's face and see how her complexion would change. In the legends of Krishna as a youth he is depicted playing all sorts of pranks with the gopis or cowgirls. One prank was to throw colored powder all over them. So at Holi, images of Krishna and his consort Radha are often carried through the streets. Holi is celebrated with eclat in the villages around Mathura, the birth-place of Krishna.
Holi-Day 1
The day of the full moon (Holi Purnima) is the first day of Holi. A platter ('thali') is arranged with colored powders, and colored water is placed in a small brass pot ('lota'). The eldest male member of the family begins the festivities by sprinkling colors on each member of the family, and the youngsters follow.
Holi-Day 2
On the second day of the festival called 'Puno', images of Holika are burnt in keeping with the legend of Prahlad and his devotion to lord Vishnu. In rural India, the evening is celebrated by lighting huge bonfires as part of the community celebration when people gather near the fire to fill the air with folk songs and dances. Mothers often carry their babies five times in a clockwise direction around the fire, so that her children are blessed by Agni, the god of fire.
Holi-Day 3
The most boisterous and the final day of the festival is called 'Parva', when children, youth, men and women visit each other's homes and colored powders called 'aabir' and 'gulal' are thrown into the air and smeared on each other's faces and bodies. 'Pichkaris' and water balloons are filled with colors and spurted onto people - while young people pay their respects to elders by sprinkling some colors on their feet, some powder is also smeared on the faces of the deities, especially Krishna and Radha.

Thursday, March 5, 2009

What Is Beta Testing Status..

Bata Testing or u Can say The User acceptance testing is the testing which is done by user itself. Before final release of software, developers put it for user testing & after using by users they ask for their views about the software application features, if they suggest for any enhancement thn after general consencus of development team steps are taken accordingly.
Or sometimes software is released with some low severty defects known to developers, only to check wether they are affecting to the other modules of the application with this Beta status.
when development team thinks that there are no possibility of any further increment in the software , they release it without Beta status for final use.
For Example ORKUT.. in which new features are being added regullarly