KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > ui > web > admin > rainterface > EndEntityProfileNameProxy


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 /*
15  * cProfileNameProxy.java
16  *
17  * Created on den 23 juli 2002, 17:49
18  */

19
20 package org.ejbca.ui.web.admin.rainterface;
21 import java.util.HashMap JavaDoc;
22
23 import org.ejbca.core.ejb.ra.raadmin.IRaAdminSessionLocal;
24 import org.ejbca.core.model.log.Admin;
25
26 /**
27  * A class used to improve performance by proxying end entity profileid to profilename mappings by minimizing the number of needed lockups over rmi.
28  *
29  * @author TomSelleck
30  * @version $Id: EndEntityProfileNameProxy.java,v 1.1 2006/01/17 20:32:20 anatom Exp $
31  */

32 public class EndEntityProfileNameProxy implements java.io.Serializable JavaDoc {
33     
34     /** Creates a new instance of ProfileNameProxy */
35     public EndEntityProfileNameProxy(Admin administrator, IRaAdminSessionLocal raadminsession){
36               // Get the RaAdminSession instance.
37
this.raadminsession = raadminsession;
38       
39       profilenamestore = new HashMap JavaDoc();
40       this.administrator = administrator;
41     }
42     
43     /**
44      * Method that first tries to find profilename in local hashmap and if it doesn't exists looks it up over RMI.
45      *
46      * @param profileid the profile id number to look up.
47      * @return the profilename or null if no profilename is relatied to the given id
48      */

49     public String JavaDoc getEndEntityProfileName(int profileid) {
50       String JavaDoc returnval = null;
51       // Check if name is in hashmap
52
returnval = (String JavaDoc) profilenamestore.get(new Integer JavaDoc(profileid));
53       
54       if(returnval==null){
55         // Retreive profilename
56
returnval = raadminsession.getEndEntityProfileName(administrator, profileid);
57         if(returnval != null)
58           profilenamestore.put(new Integer JavaDoc(profileid),returnval);
59       }
60        
61       return returnval;
62     }
63     
64     // Private fields
65
private HashMap JavaDoc profilenamestore;
66     private IRaAdminSessionLocal raadminsession;
67     private Admin administrator;
68
69 }
70
Popular Tags