• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

answer for this question

 
Mohammed Eesa
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need answer for this question

import javax.ejb.*;
import javax.naming.*;
import javax.sql.*;
import javax.jms.*;
public class MySessionBean implements SessionBean {
private SessionContext sessionContext;
private Context jndiContext;
private Queue queue;
private UserDefinedClass userDefinedClass;
public void ejbCreate() {
try {
queue = (Queue) jndiContext.lookup("java:comp/env/jms/StockQueue");
} catch (NamingException ne) {
throw new EJBException(ne);
}
userDefinedClass = new UserDefinedClass();
}
public void ejbRemove() {...}
public void ejbActivate() {...}
public void ejbPassivate() {...}
public void setSessionContext(SessionContext sessionContext) {
this.sessionContext = sessionContext;
try {
jndiContext = new InitialContext();
} catch (NamingException ne) {
throw new EJBException(ne);
}
}
public class UserDefinedClass {
String dummy;
private DataSource dataSource;
public UserDefinedClass() {
try {
dataSource = (DataSource) jndiContext.lookup(
"java:comp/env/jdbc/MyDB");
} catch (NamingException ne) {
throw new EJBException(ne);
}
}
}
}
Which of the following are true about the conversational state?
A. The state of the variable sessionContext is kept after passivation/activation.
B. The state of the variable jndiContext is kept after passivation/activation.
C. The state of the variable queue is kept after passivation/activation.
D. The state of the variable userDefinedClass is kept after passivation/activation.
E. The container must be able to properly save and restore the reference to the
home and component interfaces of the EJBs stored in the instance��s
state even if the classes that implement the object references are not
serializable.
F. The container may use the object replacement technique
(java.io.ObjectOutputStream/ObjectInputStream) to externalize the home and
component references.
 
gopi chillakuru
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Answer to this question is A,B,E,F.
 
Brian Tinnel
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is jndiContext kept? The spec says that only the environment context is serialized. A new InitialContext() is not the environment context is it? wouldn't you need to have to do a lookup of "java:comp/env" to get the environment context?
 
Arthur Orange
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Brian Tinnel:
Is jndiContext kept? The spec says that only the environment context is serialized. A new InitialContext() is not the environment context is it? wouldn't you need to have to do a lookup of "java:comp/env" to get the environment context?


I think the JNDI context is saved atleast that is what it says in HFEJB pg. 203 (about a "bean's special JNDI context")
 
Gaurav Chikara
Ranch Hand
Posts: 412
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think answer should be ABDEF.There is no reason that the userdefined class will also be not passivated
It will be passivated as it passivates non-serializable objects also
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic