001 package com.bea.medrec.controller;
002
003 import com.bea.medrec.entities.*;
004 import com.bea.medrec.utils.JNDINames;
005 import com.bea.medrec.utils.ServiceLocator;
006 import javax.jms.Queue;
007 import javax.jms.QueueConnectionFactory;
008 import javax.naming.NamingException;
009
010 /**
011 * <p>Utility to lookup entity and session beans and JMS queues.</p>
012 *
013 * @author Copyright (c) 2006 by BEA Systems. All Rights Reserved.
014 */
015 public class JNDILookupUtils {
016 // E J B & Q U E U E L O O K U P S
017
018 // E N T I T I E S
019 /**
020 * <p>Get Address Entity EJB local home.</p>
021 *
022 * @return AddressLocalHome
023 * @throws NamingException
024 */
025 public static AddressLocalHome getAddressLocalHome() throws NamingException {
026 return (AddressLocalHome) lookUpLocalHome(JNDINames.ADDRESS_LOCAL_HOME,
027 AddressLocalHome.class);
028 }
029
030 /**
031 * <p>Get Group Entity EJB local home.</p>
032 *
033 * @return GroupLocalHome
034 * @throws NamingException
035 */
036 public static GroupLocalHome getGroupLocalHome() throws NamingException {
037 return (GroupLocalHome) lookUpLocalHome(JNDINames.GROUP_LOCAL_HOME,
038 GroupLocalHome.class);
039 }
040
041 /**
042 * <p>Get Patient Entity EJB local home.</p>
043 *
044 * @return PatientLocalHome
045 * @throws NamingException
046 */
047 public static PatientLocalHome getPatientLocalHome() throws NamingException {
048 return (PatientLocalHome) lookUpLocalHome(JNDINames.PATIENT_LOCAL_HOME,
049 PatientLocalHome.class);
050 }
051
052 /**
053 * <p>Get Physician Entity EJB local home.</p>
054 *
055 * @return PhysicianLocalHome
056 * @throws NamingException
057 */
058 public static PhysicianLocalHome getPhysicianLocalHome() throws NamingException {
059 return (PhysicianLocalHome) lookUpLocalHome(JNDINames.PHYSICIAN_LOCAL_HOME,
060 PhysicianLocalHome.class);
061 }
062
063
064 /**
065 * <p>Get Prescription Entity EJB local home.</p>
066 *
067 * @return PrescriptionLocalHome
068 * @throws NamingException
069 */
070 public static PrescriptionLocalHome getPrescriptionLocalHome()
071 throws NamingException {
072 return (PrescriptionLocalHome) lookUpLocalHome(JNDINames.PRESCRIPTION_LOCAL_HOME,
073 PrescriptionLocalHome.class);
074 }
075
076 /**
077 * <p>Get Record Entity EJB local home.</p>
078 *
079 * @return RecordLocalHome
080 * @throws NamingException
081 */
082 public static RecordLocalHome getRecordLocalHome() throws NamingException {
083 return (RecordLocalHome) lookUpLocalHome(JNDINames.RECORD_LOCAL_HOME,
084 RecordLocalHome.class);
085 }
086
087 /**
088 * <p>Get User Entity EJB local home.</p>
089 *
090 * @return UserLocalHome
091 * @throws NamingException
092 */
093 public static UserLocalHome getUserLocalHome() throws NamingException {
094 return (UserLocalHome) lookUpLocalHome(JNDINames.USER_LOCAL_HOME,
095 UserLocalHome.class);
096 }
097
098 /**
099 * <p>Get Vital Signs Entity EJB local home.</p>
100 *
101 * @return VitalSignsLocalHome
102 * @throws NamingException
103 */
104 public static VitalSignsLocalHome getVitalSignsLocalHome() throws NamingException {
105 return (VitalSignsLocalHome) lookUpLocalHome(JNDINames.VITALSIGNS_LOCAL_HOME,
106 VitalSignsLocalHome.class);
107 }
108
109
110 // Q U E U E S
111 /**
112 * <p>Get Mail JMS Queue.</p>
113 *
114 * @return Queue
115 * @throws NamingException
116 */
117 public static Queue getJMailQueue() throws NamingException {
118 return (Queue)
119 ServiceLocator.getInstance().lookupQueue(JNDINames.MAIL_MDB_QUEUE);
120 }
121
122 /**
123 * <p>Get Registration JMS Queue.</p>
124 *
125 * @return Queue
126 * @throws NamingException
127 */
128 public static Queue getRegQueue() throws NamingException {
129 return (Queue)
130 ServiceLocator.getInstance().lookupQueue(JNDINames.REGISTRATION_MDB_QUEUE);
131 }
132
133 /**
134 * <p>Get XML Upload JMS Queue.</p>
135 *
136 * @return Queue
137 * @throws NamingException
138 */
139 public static Queue getXMLQueue() throws NamingException {
140 return (Queue)
141 ServiceLocator.getInstance().lookupQueue(JNDINames.XML_UPLOAD_MDB_QUEUE);
142 }
143
144 /**
145 * <p>Get JMS Queue Connection Factory.</p>
146 *
147 * @return QueueConnectionFactory
148 * @throws NamingException
149 */
150 public static QueueConnectionFactory getQCFactory() throws NamingException {
151 return (QueueConnectionFactory)
152 ServiceLocator.getInstance().lookupQCFactory(JNDINames.QUEUE_CONNECTION_FACTORY);
153 }
154
155 // S E S S I O N B E A N S
156 /**
157 * <p>Get MailSession.</p>
158 *
159 * @return MailSession
160 * @throws NamingException
161 */
162 public static MailSession getMailSession()
163 throws NamingException {
164 ServiceLocator locator = ServiceLocator.getInstance();
165 Object obj = locator.getObj(JNDINames.MAIL_SESSION_REMOTE_HOME,
166 com.bea.medrec.controller.MailSessionHome.class);
167 return (MailSession) obj;
168 }
169
170 /**
171 * <p>Get AdminSession.</p>
172 *
173 * @return AdminSession
174 * @throws NamingException
175 */
176 public static AdminSession getAdminSession()
177 throws NamingException {
178 ServiceLocator locator = ServiceLocator.getInstance();
179 Object obj = locator.getObj(JNDINames.ADMIN_SESSION_REMOTE_HOME,
180 com.bea.medrec.controller.AdminSessionHome.class);
181 return (AdminSession) obj;
182 }
183
184 // L O O K U P U T I L S
185 /**
186 * <p>Get local home.</p>
187 *
188 * @return Object
189 * @throws NamingException
190 */
191 public static Object lookUpHome(String pHome, Class pClazz)
192 throws NamingException {
193 ServiceLocator locator = ServiceLocator.getInstance();
194 Object obj = locator.lookupHome(pHome, pClazz);
195 return obj;
196 }
197
198 /**
199 * <p>Get local home.</p>
200 *
201 * @return Object
202 * @throws NamingException
203 */
204 public static Object lookUpLocalHome(String pHome, Class pClazz)
205 throws NamingException {
206 ServiceLocator locator = ServiceLocator.getInstance();
207 Object obj = locator.lookupLocalHome(pHome, pClazz);
208 return obj;
209 }
210 }
|