PhysBaseAction.java
01 package com.bea.medrec.actions;
02 
03 import com.bea.medrec.controller.PhysicianSession;
04 import com.bea.medrec.controller.PhysicianSessionHome;
05 import com.bea.medrec.utils.MedRecLog4jFactory;
06 import javax.naming.InitialContext;
07 import org.apache.log4j.Logger;
08 
09 /**
10  <p>Base servlet encapsulating common servlet functionality.</p>
11  *
12  @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
13  */
14 public abstract class PhysBaseAction
15     extends BaseAction implements PhysicianConstants {
16 
17   private static Logger logger =
18       MedRecLog4jFactory.getLogger(PhysBaseAction.class.getName());
19 
20   protected InitialContext ctx = null;
21   private PhysicianSession physicianSession;
22 
23   /**
24    <p>Retrives PhysicianSession home.
25    * If instance does not exist, retrieve a new instance.<p>
26    *
27    @return PhysicianSession
28    */
29   protected PhysicianSession getPhysicianSession() throws Exception {
30     if (ctx == nullctx = new InitialContext();
31     if (physicianSession == null) {
32       logger.debug("Getting new physician session.");
33       this.physicianSession = getPhysicianSessionHome();
34     }
35     return this.physicianSession;
36   }
37 
38   //   P R I V A T E   M E T H O D S
39   /**
40    <p>Get PhysicianSession EJB</p>
41    *
42    @return PhysicianSession
43    */
44   private PhysicianSession getPhysicianSessionHome() throws Exception {
45     PhysicianSessionHome home = (PhysicianSessionHomectx.lookup(
46         "java:/comp/env/PhysicianSessionEJB");
47     return (PhysicianSessionhome.create();
48   }
49 }