1 13 14 package org.ejbca.core.model.services; 15 16 import javax.ejb.CreateException ; 17 import javax.ejb.EJBException ; 18 19 import org.ejbca.core.ejb.ServiceLocator; 20 import org.ejbca.core.ejb.ca.caadmin.ICAAdminSessionLocal; 21 import org.ejbca.core.ejb.ca.caadmin.ICAAdminSessionLocalHome; 22 import org.ejbca.core.ejb.ca.store.CertificateDataLocalHome; 23 import org.ejbca.core.ejb.log.ILogSessionLocal; 24 import org.ejbca.core.ejb.log.ILogSessionLocalHome; 25 import org.ejbca.core.ejb.ra.IUserAdminSessionLocal; 26 import org.ejbca.core.ejb.ra.IUserAdminSessionLocalHome; 27 28 36 37 public abstract class BaseServiceComponent { 38 39 40 41 private ILogSessionLocal logsession = null; 42 private CertificateDataLocalHome certHome = null; 43 private ICAAdminSessionLocal caadminsession = null; 44 private IUserAdminSessionLocal useradminsession = null; 45 46 50 protected ServiceLocator getLocator() { 51 return ServiceLocator.getInstance(); 52 } 53 54 59 protected ILogSessionLocal getLogSession() { 60 if (logsession == null) { 61 try { 62 ILogSessionLocalHome logsessionhome = (ILogSessionLocalHome) getLocator().getLocalHome(ILogSessionLocalHome.COMP_NAME); 63 logsession = logsessionhome.create(); 64 } catch (CreateException e) { 65 throw new EJBException (e); 66 } 67 } 68 return logsession ; 69 } 71 76 protected CertificateDataLocalHome getCertificateDataHome() { 77 if (certHome == null) { 78 certHome = (CertificateDataLocalHome) getLocator().getLocalHome(CertificateDataLocalHome.COMP_NAME); 79 } 80 return certHome ; 81 } 83 88 protected ICAAdminSessionLocal getCAAdminSession() { 89 if (caadminsession == null) { 90 try { 91 ICAAdminSessionLocalHome caadminsessionhome = (ICAAdminSessionLocalHome) getLocator().getLocalHome(ICAAdminSessionLocalHome.COMP_NAME); 92 caadminsession = caadminsessionhome.create(); 93 } catch (CreateException e) { 94 throw new EJBException (e); 95 } 96 } 97 return caadminsession ; 98 } 100 105 protected IUserAdminSessionLocal getUserAdminSession() { 106 if (useradminsession == null) { 107 try { 108 IUserAdminSessionLocalHome useradminsessionhome = (IUserAdminSessionLocalHome) getLocator().getLocalHome(IUserAdminSessionLocalHome.COMP_NAME); 109 useradminsession = useradminsessionhome.create(); 110 } catch (CreateException e) { 111 throw new EJBException (e); 112 } 113 } 114 return useradminsession ; 115 } 117 118 119 } 120 | Popular Tags |