Showing posts with label java Notes. Show all posts
Showing posts with label java Notes. Show all posts

Monday, 20 August 2012

   Session beans can either be stateful or stateless. With stateful beans, the EJB container saves internal bean data during and in between method calls on the client’s behalf. With stateless beans, the clients may call any available instance of an instantiated bean for as long as the EJB container has the ability to pool stateless beans. This enables the number of instantiations of a bean to be reduced, thereby reducing required resources.

Stateless Session Beans
A session bean represents work performed by a single client. That work can be performed within a single method invocation, or it may span multiple method invocations. If the work does span more than one method, the object must retain the user’s object state across the method calls, and a stateful session bean would therefore be required.
Generally, stateless beans are intended to perform individual operations automatically and don’t maintain state across method invocations. They’re also amorphous, in that any client can use any instance of a stateless bean at any time at the container’s discretion. They are the lightest weight and easiest to manage of the various EJB component configurations.

Stateful Session Beans
Stateful session beans maintain state both within and between transactions. Each stateful session bean is therefore associated with a specific client. Containers are able to save and retrieve a bean’s state automatically while managing instance pools (as opposed to bean pools) of stateful session beans.
Stateful session beans maintain data consistency by updating their fields each time a transaction is committed. To keep informed of changes in transaction status, a stateful session bean implements the SessionSynchronization interface. The container calls methods of this interface while it initiates and completes transactions involving the bean.
Session beans, whether stateful or stateless, are not designed to be persistent. The data maintained by stateful session beans is intended to be transitional. It is used solely for a particular session with a particular client. A stateful session bean instance typically can’t survive system failures and other destructive events. While a session bean has a container-provided identity (called its handle), that identity passes when the client removes the session bean at the end of a session. If a client needs to revive a stateful session bean that has disappeared, it must provide its own means to reconstruct the bean’s state.

Stateful Session Beans vs. Stateless Session Beans
A stateful session bean will maintain a conversational state with a client. The state of the session is maintained for the duration of the conversation between the client and the stateful session bean. When the client removes the stateful session bean, its session ends and the state is destroyed. The transient nature of the state of the stateful session bean should not be problematic for either the client or the bean, because once the conversation between the client and the stateful session bean ends, neither the client nor the stateful session bean should have any use for the state.
A stateless session bean will not maintain conversational states for specific clients longer than the period of an individual method invocation. Instance variables used by a method of a stateless bean may have a state, but only for the duration of the method invocation. After a method has finished running either successfully or unsuccessfully, the states of all its instance variables are dropped. The transient nature of this state gives the stateless session bean beneficial attributes, such as the following:
·         Bean pooling Any stateless session bean method instance that is not currently invoked is equally available to be called by an EJB container or application server to service the request of a client. This allows the EJB container to pool stateless bean instances and increase performance.
·         Scalability Because stateless session beans are able to service multiple clients, they tend to be more scalable when applications have a large number of clients. When compared to stateful session beans, stateless session beans usually require less instantiation.
·         Performance An EJB container will never move a stateless session bean from RAM out to a secondary storage, which it may do with a stateful session bean; therefore, stateless session beans may offer greater performance than stateful session beans.
Since no explicit mapping exists between multiple clients and stateless bean instances, the EJB container is free to service any client’s request with any available instance. Even though the client calls the create() and remove() methods of the stateless session bean, making it appear that the client is controlling the lifecycle of an EJB, it is actually the EJB container that is handling the create() andremove() methods without necessarily instantiating or destroying an EJB instance

Thursday, 7 June 2012

How Did Java Get IT'S Name

Posted by Unknown On 09:27 | No comments

 When you think of other programming languages’ names, such as BASIC, FORTRAN, COBOL, C, C++, and PASCAL, the name Java doesn’t really fit in. The name itself is interesting enough to garner curiosity. So just how did Java get its name?  The original name for Java was intended to be “OAK”, but they couldn’t use that name because it was already taken (by Oak Technologies). Other names floating around were “Silk” and “DNA”.

What is Double buffering in Java

Posted by Unknown On 09:14 | No comments


Double buffering is an extremely powerful concept that has
helped make some of today’s flicker-free animation and game
play possible. It reduces flicker by performing all the graphics
functions on a hidden image that resides in memory instead of
drawing directly to the screen. Then, the entire image is dis-
played all at once instead of having to update the screen every
time a new bit of graphics is drawn.
If we removed the double buffering technique from our applet,











public class HelloWorld
{
  public static void main(String[] args)
  {
    System.out.println("Hello, World!");
  }
}

Wednesday, 6 June 2012

Important Packages of Core Java

Posted by Unknown On 23:48 | No comments

1)java.long: - This package got primary classes and interfaces essential for java program. It consists of wrapper classes, strings, threads, etc. wrapper classes are useful to create an object. Thread means process.
2)java.util: - (utility) in this util data structures are available. This package contains useful classes and interfaces like stack, linked list, hash table, arrays. etc.

Tuesday, 5 June 2012

FEATURES OF JAVA PROGRAMMING LANGUAGE

Posted by Unknown On 23:41 | No comments
1. Simple: - Java is a simple programming language. Learning & practicing java is easy because of its resemblance C and C++ pointers are not available on JAVA.
  
2. Object Oriented: - Java is a purely object-oriented programming language. Java programs use objects & classes.
àObject: - Object is anything exists really in the world. An object contains properties and performs actions. Properties are represented by variables & actions are formed by functions. Functions are called methods in java.
àClass: - A class is a group of name that represents properties & actions of objects. Class does not exist physically. Where as object exist physically.  A class is a plan or model to create objects, from the class to create the objects. In every java program we must contain at least one class.
  

Blogroll

Blogger templates

About