KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > cainterface > CertificateProfileNameProxy


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.ui.web.admin.cainterface;
15
16
17 import java.util.HashMap JavaDoc;
18
19 import org.ejbca.core.ejb.ca.store.ICertificateStoreSessionLocal;
20 import org.ejbca.core.model.log.Admin;
21
22 /**
23  * A class used to improve performance by proxying certificateprofile id to certificate name mappings by minimizing the number of needed lockups over rmi.
24  *
25  * @version $Id: CertificateProfileNameProxy.java,v 1.1 2006/01/17 20:28:08 anatom Exp $
26  */

27 public class CertificateProfileNameProxy implements java.io.Serializable JavaDoc {
28     
29     /** Creates a new instance of ProfileNameProxy */
30     public CertificateProfileNameProxy(Admin administrator, ICertificateStoreSessionLocal certificatestoresession){
31       this.certificatestoresession = certificatestoresession;
32       
33       certificateprofilenamestore = new HashMap JavaDoc();
34       this.admin= administrator;
35         
36     }
37     
38     /**
39      * Method that first tries to find certificateprofile name in local hashmap and if it doesn't exists looks it up over RMI.
40      *
41      * @param certificateprofileid the certificateprofile id number to look up.
42      * @return the certificateprofilename or null if no certificateprofilename is relatied to the given id
43      */

44     public String JavaDoc getCertificateProfileName(int certificateprofileid) {
45       String JavaDoc returnval = null;
46       // Check if name is in hashmap
47
returnval = (String JavaDoc) certificateprofilenamestore.get(new Integer JavaDoc(certificateprofileid));
48       
49       if(returnval==null){
50         // Retreive profilename
51
returnval = certificatestoresession.getCertificateProfileName(admin, certificateprofileid);
52         if(returnval != null)
53           certificateprofilenamestore.put(new Integer JavaDoc(certificateprofileid),returnval);
54       }
55        
56       return returnval;
57     }
58     
59     // Private fields
60
private HashMap JavaDoc certificateprofilenamestore;
61     private ICertificateStoreSessionLocal certificatestoresession;
62     private Admin admin;
63
64 }
65
Popular Tags