KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > services > BaseServiceComponent


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13
14 package org.ejbca.core.model.services;
15
16 import javax.ejb.CreateException JavaDoc;
17 import javax.ejb.EJBException JavaDoc;
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 /**
29  *
30  * An abstract base class containing common methods for workers, actions and intervals
31  *
32  * @author Philip Vendil 2006 sep 27
33  *
34  * @version $Id: BaseServiceComponent.java,v 1.1 2006/10/26 11:01:01 herrvendil Exp $
35  */

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     /**
47      * return the environment entries locator
48      * @return return the environment entries locator
49      */

50     protected ServiceLocator getLocator() {
51         return ServiceLocator.getInstance();
52     }
53     
54     /**
55      * Gets connection to log session bean
56      *
57      * @return Connection
58      */

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 JavaDoc e) {
65                 throw new EJBException JavaDoc(e);
66             }
67         }
68         return logsession ;
69     } //getLogSession
70

71     /**
72      * Gets connection to cerificate data home
73      *
74      * @return Connection
75      */

76     protected CertificateDataLocalHome getCertificateDataHome() {
77         if (certHome == null) {
78                 certHome = (CertificateDataLocalHome) getLocator().getLocalHome(CertificateDataLocalHome.COMP_NAME);
79         }
80         return certHome ;
81     } //getCertificateDataHome
82

83     /**
84      * Gets connection to CA Admin session
85      *
86      * @return Connection
87      */

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 JavaDoc e) {
94                 throw new EJBException JavaDoc(e);
95             }
96         }
97         return caadminsession ;
98     } //getCAAdminSession
99

100     /**
101      * Gets connection to CA Admin session
102      *
103      * @return Connection
104      */

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 JavaDoc e) {
111                 throw new EJBException JavaDoc(e);
112             }
113         }
114         return useradminsession ;
115     } //getUserAdminSession
116

117
118    
119 }
120
Popular Tags