SCBCD 5 Short Notes

My SCBCD 5 Short Notes..

1)
@PostConstruct
public void initialize( ){ }
@PreDestroy
public void cleanup( ){ }


@PrePassivate
public void cleanup( ){ }

@PostActivate
public void openConnection( ){ }
Access modifier can be  public
                                     protected
                                     default
                                     private
Not static
Not Final
Not throw checked Exceptions
 
@Remove
public void cancel( ){ }

@PostConstruct, @PreDestroy can be used with stateful, stateless session beans
@PrePassivate, @PostActivate, @Remove used with stateful session beans

 2)
Transaction attributes
Reference : EJB 3 in Action
Transaction Attribute Caller Transaction Exists? Effect
REQUIRED No Container creates a new transaction.
Yes Method joins the caller’s transaction.
REQUIRES_NEW No Container creates a new transaction.
Yes Container creates a new transaction and the caller’s transaction is suspended
SUPPORTS No No transaction is used.
Yes Method joins the caller’s transaction.
MANDATORY No javax.ejb.EJBTransactionRequired-Exception is thrown.
Yes Method joins the caller’s transaction.
NOT_SUPPORTED No No transaction is used.
Yes The caller’s transaction is suspended and the method is called without a transaction
NEVER No No transaction is used.
Yes javax.ejb.EJBException is thrown


3)

  1. @Entity  
  2. public class Project{  
  3.     @ManyToMany(mappedBy="projects")  
  4.     Set<Employee> emps;  
  5. }  
  6.   
  7. @Entity  
  8. public class Employee{  
  9.     @ManyToMany(targetEntity=Project.class)  
  10.     Collection projects;  
  11. }  
If we not use Generics we have to use targetEntity


4 )
  1. @MessageDriven  
  2. public class MyMessageBean implements MessageListener{  
  3.       
  4.     public MyMessageBean(){}  
  5.       
  6.     public void onMesage(Message message){  
  7.           
  8.     }  
  9. }  


5) EJB Roles
  1. Enterprise Bean Provider
  2. Application Assembler
  3. Deployer
  4. EJB Server Provider
  5. EJB Container Provider
  6. Persistence Provider
  7. System Administrator
6)
 @PersistenceUnit
EntityManagerFactory emf;

@PersistenceContext
EntityManager em;

7)Defining a Runtime Exception

  1. @ApplicationException  
  2. public class MyException extends java.lang.RuntimeException  

8)  ejb-jar is a contract between ,

           Bean Provider and Application Assembler
           Application Assembler and Deployer

No comments:

Post a Comment