KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > model > services > workers > CRLUpdateWorker


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 package org.ejbca.core.model.services.workers;
14
15 import javax.ejb.CreateException JavaDoc;
16
17 import org.apache.log4j.Logger;
18 import org.ejbca.core.ejb.ca.crl.ICreateCRLSessionLocal;
19 import org.ejbca.core.ejb.ca.crl.ICreateCRLSessionLocalHome;
20 import org.ejbca.core.model.services.BaseWorker;
21 import org.ejbca.core.model.services.ServiceExecutionFailedException;
22
23 /**
24  * Class managing the updating of CRLs.
25  *
26  * This is a replacement of the old jboss service.
27  *
28  * @author Philip Vendil
29  * @version $Id: CRLUpdateWorker.java,v 1.2.2.2 2007/03/09 17:23:51 anatom Exp $
30  */

31 public class CRLUpdateWorker extends BaseWorker {
32
33     private static Logger log = Logger.getLogger(CRLUpdateWorker.class);
34     
35     private ICreateCRLSessionLocal createcrlsession = null;
36     
37     /**
38      * Checks if there are any CRL that needs to be updated, and then does the creation.
39      *
40      * @see org.ejbca.core.model.services.IWorker#work()
41      */

42     public void work() throws ServiceExecutionFailedException {
43         long polltime = getNextInterval();
44         ICreateCRLSessionLocal session = getCreateCRLSession();
45         if (session != null) {
46             session.createCRLs(getAdmin(), polltime*1000);
47         }
48     }
49
50     
51     public ICreateCRLSessionLocal getCreateCRLSession(){
52         if(createcrlsession == null){
53             try {
54                 ICreateCRLSessionLocalHome home = (ICreateCRLSessionLocalHome) getLocator().getLocalHome(ICreateCRLSessionLocalHome.COMP_NAME);
55                 this.createcrlsession = home.create();
56             } catch (CreateException JavaDoc e) {
57                 log.error(e);
58             }
59         }
60   
61         return createcrlsession;
62     }
63 }
64
Popular Tags