• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

answer for this question

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Answer to this question is A,B,E,F.
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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")
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic