KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > runtime > beancache > ASEjbBCVictimPolicy


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.beancache;
25
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.Result;
28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
29
30
31 /** ejb [0,n]
32  * bean-cache ?
33  * max-cache-size ? [String]
34  * is-cache-overflow-allowed ? [String]
35  * cache-idle-timout-in-seconds ? [String]
36  * removal-timeout-in-seconds ? [String]
37  * victim-selection-policy ? [String]
38  *
39  * The victim-selection-policy specifies the algorithm that is used to select
40  * victims.
41  * Valid values are FIFO, LRU and NRU
42  * @author Irfan Ahmed
43  */

44
45 public class ASEjbBCVictimPolicy extends ASEjbBeanCache
46 {
47     
48     public Result check(EjbDescriptor descriptor)
49     {
50         Result result = getInitializedResult();
51         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52         String JavaDoc beanCache = null;
53         String JavaDoc victimPolicy = null;
54         try{
55             beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache");
56             if(beanCache!=null)
57             {
58                 victimPolicy = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache/victim-selection-policy");
59                 if(victimPolicy!=null)
60                 {
61                     victimPolicy = victimPolicy.trim();
62                     if(victimPolicy.length()==0)
63                     {
64                         addErrorDetails(result, compName);
65                         result.failed(smh.getLocalString(getClass().getName()+".failed",
66                             "FAILED [AS-EJB bean-cache] : victim-selection-policy cannot be empty. It has to be either FIFO, NRU or LRU"));
67                     }else
68                     {
69                         if(!victimPolicy.equalsIgnoreCase("FIFO") && !victimPolicy.equalsIgnoreCase("NRU")
70                                 && !victimPolicy.equalsIgnoreCase("LRU"))
71                         {
72                             addErrorDetails(result, compName);
73                             result.failed(smh.getLocalString(getClass().getName()+".failed1",
74                                     "FAILED [AS-EJB bean-cache] : victim-selection-policy cannot be [{0}]. It should be either FIFO, NRU or LRU [case insensitive]",
75                                     new Object JavaDoc[]{victimPolicy}));
76                         }
77                         else
78                         {
79                             addGoodDetails(result, compName);
80                             result.passed(smh.getLocalString(getClass().getName()+".passed",
81                                 "PASSED [AS-EJB bean-cache] : victim-selection-policy is {0}",
82                                  new Object JavaDoc[]{victimPolicy}));
83                         }
84                     }
85                 }else //victim-selection-policy not defined
86
{
87                     addNaDetails(result, compName);
88                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
89                         "NOT APPLICABLE [AS-EJB bean-cache] : victim-selection-policy element not defined"));
90                 
91                 }
92             
93             }else //bean-cache is not defined
94
{
95                 addNaDetails(result, compName);
96                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
97                     "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
98             
99             }
100         }catch(Exception JavaDoc ex){
101             addErrorDetails(result, compName);
102             result.addErrorDetails(smh.getLocalString
103                  (getClass().getName() + ".notRun",
104                   "NOT RUN [AS-EJB] : Could not create the descriptor object"));
105         }
106         return result;
107     }
108 }
109
Popular Tags