FileDocCategorySizeDatePackage
TestENCBean.javaAPI DocJBoss 4.2.13486Fri Jul 13 20:55:02 BST 2007org.jboss.tutorial.jboss_resource_ref.bean

TestENCBean

public class TestENCBean extends Object implements TestENC
A bean that does nothing but access resources from the ENC to test ENC usage.
author
Scott.Stark@jboss.org
version
$Revision: 60233 $

Fields Summary
Logger
log
Constructors Summary
Methods Summary
public voidaccessENC()


       
   
      // Obtain the enterprise beans environment naming context.
      Context initCtx = new InitialContext();
      Context myEnv = (Context) initCtx.lookup(Container.ENC_CTX_NAME + "/env");
      
      // This bean should have the full ENC setup of the ENCBean
      testJdbcDataSource(initCtx, myEnv);
      testMail(initCtx, myEnv);
      testJMS(initCtx, myEnv);
      testResourceEnvEntries(initCtx, myEnv);
   
public voidremove()

      
   
private voidtestJMS(javax.naming.Context initCtx, javax.naming.Context myEnv)

      // JavaMail Session
      Object obj = myEnv.lookup("jms/QueFactory");
      if ((obj instanceof javax.jms.QueueConnectionFactory) == false)
         throw new NamingException("mail/DefaultMail is not a javax.jms.QueueConnectionFactory");
      log.info("Found jms queue resource ref");
   
private voidtestJdbcDataSource(javax.naming.Context initCtx, javax.naming.Context myEnv)

      // JDBC DataSource
      Object obj = myEnv.lookup("jdbc/DefaultDS");
      if ((obj instanceof javax.sql.DataSource) == false)
         throw new NamingException("jdbc/DefaultDS is not a javax.sql.DataSource");
      log.info("Found data source resource ref");
   
private voidtestMail(javax.naming.Context initCtx, javax.naming.Context myEnv)

      // JavaMail Session
      Object obj = myEnv.lookup("mail/DefaultMail");
      if ((obj instanceof javax.mail.Session) == false)
         throw new NamingException("DefaultMail is not a javax.mail.Session");
      log.info("Found mail resource ref");
   
private voidtestResourceEnvEntries(javax.naming.Context initCtx, javax.naming.Context myEnv)

      Object obj = myEnv.lookup("res/aQueue");
      if ((obj instanceof javax.jms.Queue) == false)
         throw new NamingException("res/aQueue is not a javax.jms.Queue");
      log.info("Found jms queue resource env ref");