EJB вопросы и ответы для интервью
Question: can we have static initializer Block in EJB?Answer: Purpose of Static initializer block is to initialize some static fields before any execution of constructor or method or we can say creation of object. According to EJB Spec its a violation if static field are used and they are non final ."EJB Spec": Enterprise bean are not allowed to read or write the non final fields. But technically,from the point of java its correct but if in EJB we use static initializer block to initialize static field then because EJB components are used in distributed environment mean to say if single JVM then it will be ok but if run on different JVM then it will be a problem if we change or update the value in on environment then only the instance running on same JVM have new value .thats why static blocks are avoided and also all static field should be final. And same thing we can achieve in ejbCreate(), setSessionContext() or setEntityContext() methods. |
Сохранить для повторения
Добавьте этот элемент в закладки, отметьте как сложный или поместите в набор для повторения.
Войдите, чтобы сохранять закладки, сложные вопросы и наборы для повторения.
Это полезно? Да Нет
Самое полезное по оценкам пользователей:
- What are the different kinds of enterprise beans?
- What is Entity Bean?
- What is Session Bean?
- What is the difference between Container-Managed Persistent (CMP) bean and Bean-Managed Persistent(BMP)?
- What are the methods of Entity Bean?