Home | Login | Blog | Forum | Download | RSS Feed | Ajax | Hello-World | J2EE | BPM | EJB | FileNet | Hibernate | ORM | IBM | ILOG | Interview | FAQs |

Java | Apache | JVM | Others | BRMS | Oracle | Pega | SOA | Sun-Certification | Web-Service | websphere | XML |
 

JAVA DEVELOPER SITE - COMPLETE JAVA TUTORIALS

Lifecycle Callbacks for Stateless Session Beans



 Subscribe in a reader

Newly Added TutorialNewly Added Tutorial


Share

Java Exception Handling
Thread Creation in Java
Read a File in Java
Convert List to Array
Read Excel in Java
Method Invocation Using Reflection
Ajax Basics
Stateless Session Beans Callback
Ajax Autocomplete in Java
Hello World Java
Decision Table
Object Serialization
Singleton Pattern
Java Heap Size
Set Heap Size Eclipse
OutofMemory Exception in Java
Axis Web Services
Java C++ Difference
SOA Tutorials
Filenet Platform BPM
Eclipse Tips & Tricks
enterprise service bus (ESB)
Enterprise Application Integration (EAI)
JPA Basics
ORM
Marshalling & Unmarshalling XML
JAXP Tutorial
JAXP- Read Write XML
WPS & WID
IT Jobs
IBM Websphere
Rule Engine
ILOG
ECM
JAX-WS Vs JAX-RPC
REST Web Service
Lombardi TeamWorks Vs FileNet BPM
JBoss ( JEMS)
Apache Tomcat
JMS Overview
JCA Overview
Hibernate Source Code
JPA HelloWorld
Java Beginner Tutorial
ILOG CPlex
Link/Unlink Adsense - Analytics
XSD Restriction
Convert xsd to xml / xml to xsd
ILOG Vs Drools
AJAX tutorial
Filenet tutorial
SCJP 1.6 dumps
Lombardi Tutorial
Process server
Spring
Struts Tutorial

JAVA Tutorials

Collection Framework
Operators in Java
If-else Statement

Thread
File
Generics
Input-Output in java
File Stream
Java Methods
Java Arrays
Java Objects
Java Exception Handling
Java Inheritance Tutorial
Java Threads
Garbage collection

J2EE Tutorials

Servlets Tutorials
Introduction to Struts Framework
JSP Tutorials
SPRING Framework Tutorials
STRUTS Tutorials
HIBERNATE Tutorials
Web Services Tutorials

BRMS Tutorial

ILOG
BLAZE ADVISOR
PEGA
Drools
BRMS
BPM
JRules for .NET
ilog jrules interview questions
ilog jrules certification dumps
Java Certification Study Guide
hibernate tutorial
hello world struts example

 
 
 

Useful Java Links



Lifecycle Callbacks for Stateless Session Beans
The J2EE server (like Glassfish or Oracle Weblogic) manages the life cycle of a stateless session bean unlike regular Java classes. The server decides when to create and remove bean instances, so the application never knows how many instances of a session bean class that is created, nor does it know when they are created or destroyed.
Since the server itself needs to initialize services for the bean before the business logic is invoked, and the bean itself most likely will need to make some initializations of itself,
the constructor is not a good place for that bean initialization code.
To allow both the server and the enterprise bean to make their initializations, EJBs support something called "lifecycle callback methods" that are annotated by the programmer and invoked by the server at various points in th beans life cycle.

For stateless session beans there are two lifecycle callbacks:

@PostConstruct

@PreDestroy

The server will invoke the method that is annotated with the @PostConstruct annotation as soon as the server is finished with its initialization tasks,
and the server will also invoke the method annotated with the @PreDestroy annotation immediately before the bean instance is released for garbage collection.

A good use of the @PostConstruct annotation could be to get hold of a Logger instance.

package com.javagenious.examples;

import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.Stateless;

/**
 *
 * @author javagenious.com
 */

@Stateless
public class PasswordBeanImpl implements PasswordBeanLocal {

    private Logger logger;
    
    @PostConstruct
    public void initBean() {
        logger = Logger.getLogger(PasswordBeanImpl.class.getName());
    }

    public String getGeneratedPassword() {

        String generatedPassword = null;

        //Code to generate password here

        return generatedPassword;
    }
}




Download Latest Java/J2EE eBooks, SCJP Dumps, SCWCD Dumps, Pega Tutorial, IBM WebSphere BPM tutorials and many more

If you need any urgent assistance on Lifecycle_Callbacks_for_Stateless_Session_Beans, kindly email your requirement to us at : info@javagenious.com or Contact-an-Expert. Our experts will try their best to solve your problem.

You can also subscribe to our newsletters on Lifecycle_Callbacks_for_Stateless_Session_Beans, to receive updates on Lifecycle_Callbacks_for_Stateless_Session_Beans,via email.Enter you email below:

Enter your email address:

Delivered by FeedBurner



Keyword Tags: Lifecycle_Callbacks_for_Stateless_Session_Beans tutorial,Lifecycle_Callbacks_for_Stateless_Session_Beans in java,Concepts of Lifecycle_Callbacks_for_Stateless_Session_Beans,Java,J2EE,Interview Questions,Lifecycle_Callbacks_for_Stateless_Session_Beans Examples


Comments:

  1. Raghav says:

    What is the difference between a session bean and a stateless bean?

  1. IBM Interview Question says:

    I was asked this in my recent IBM interview...I could not answered it but then also i got selected..


Post Your Comment:

*

Yes, I would like to recieve email notifications on my reply.

Related Posts on Lifecycle Callbacks for Stateless Session Beans

 
Popular Downloads

SCJP 1.6 Dumps
JSP Interview Questions
Struts Interview Questions
Hibernate Interview Questions
SCWCD Dumps
SCBCD Dumps

Java/J2EE Tutorial
JMS Tutorials
seam richfaces tutorial
richfaces live demo
jquery example demo
JQuery Tutorial and Source Code
JSF Tutorial
XSL Tutorial
J2EE JMS
CORBA Applications
Java CERTIFICATION
SCJP 1.5
SCJP 1.6
SCWCD 1.5
SCBCD
Mis
Ajax autosuggest autocomplete from database
Struts forms and validation with webflow
Java Apache POI Examples
JDBC Tutorial
Oracle 9i & 10g
MYSQL Tutorial
php Tutorial
JQuery Examples
Upload Java File
JAXB Examples
PL-SQL Tutorial
Dojo AJAX
EJB Examples
Java IDE
Eclipse
NetBeans
IBM Rational Weblogic Workshop
Downloads
SCJP 1.6 Dumps
SCJP 1.5 DUMP
SCJP Material
SCWCD
Java Security
SCBCD Dumps
External Links
SUN Java
JOracle
IBM
PHP Certification
Technical Interview Questions
Amazon Interview Questions
Google Interview Questions
Microsoft Interview Questions
IBM Interview Questions
Yahoo Interview Questions
All Tutorials
php mysql tutorial
SCJP 1.5/1.6
SCWCD 1.5/1.6
Polymorphism
Thread Tutorial
Generics & Exceptions
Spring Struts Hibernate
Java Collections
MAP
SET
LIST
VECTOR
Advanced Java
Stateless Session Bean
Introduction to EJB
Stateful Session Bean
Java Design Patterns
HOME | FORUM | ABOUT | BLOGS | CONTACT-US