KickJava   Java API By Example, From Geeks To Geeks.

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


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.Verifier;
29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
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 removal-timeout-in-seconds specifies the amount of time the bean remains
40  * passivated.
41  * Valid values are between 0 and MAX_LONG
42  * @author Irfan Ahmed
43  */

44
45 public class ASEjbBCRemovalTimeout extends ASEjbBeanCache
46 {
47     public Result check(EjbDescriptor descriptor)
48     {
49         Result result = getInitializedResult();
50         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
51         String JavaDoc beanCache = null;
52         String JavaDoc removeTime = null;
53         try{
54             beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache");
55             if(beanCache!=null)
56             {
57                 removeTime = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache/removal-timeout-in-seconds");
58                 if (removeTime!=null)
59                 {
60                     try{
61                         removeTime = removeTime.trim();
62                         if (removeTime.length()==0)
63                         {
64                             addErrorDetails(result, compName);
65                             result.failed(smh.getLocalString(getClass().getName()+".failed",
66                                     "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be empty. It should be between 0 and {0}",
67                                     new Object JavaDoc[]{new Long JavaDoc(Long.MAX_VALUE)}));
68                         }else
69                         {
70                             long value = new Integer JavaDoc(removeTime).longValue();
71                             if(value < 0 || value > Long.MAX_VALUE)
72                             {
73                                 addErrorDetails(result, compName);
74                                 result.failed(smh.getLocalString(getClass().getName()+".failed1",
75                                     "FAILED [AS-EJB bean-cache] : removal-timeout-in-seconds cannot be {0}. It should be between 0 and {1}",
76                                     new Object JavaDoc[]{new Long JavaDoc(value),new Long JavaDoc(Long.MAX_VALUE)}));
77                             }else
78                             {
79                                 addGoodDetails(result, compName);
80                                 result.passed(smh.getLocalString(getClass().getName()+".passed",
81                                     "PASSED [AS-EJB bean-cache] : removal-timeout-in-seconds is {0}",
82                                     new Object JavaDoc[]{new Long JavaDoc(value)}));
83                             }
84                         }
85                     }catch(NumberFormatException JavaDoc nfex){
86                         Verifier.debug(nfex);
87                         addErrorDetails(result, compName);
88                         result.failed(smh.getLocalString(getClass().getName()+".failed2",
89                                 "FAILED [AS-EJB bean-cache] : [{0}] is not a valid Long number",new Object JavaDoc[]{removeTime}));
90                     }
91                 } else // removal-timeout not defined
92
{
93                     addNaDetails(result, compName);
94                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
95                                 "NOT APPLICABLE [AS-EJB bean-cache] : removal-timeout-in-seconds element not defined"));
96                 }
97             }else // bean-cache not defined
98
{
99                 addNaDetails(result, compName);
100                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
101                     "NOT APPLICABLE [AS-EJB] : bean-cache element not defined"));
102             }
103
104         }catch(Exception JavaDoc ex)
105         {
106             addErrorDetails(result, compName);
107             result.addErrorDetails(smh.getLocalString
108                     (getClass().getName() + ".notRun",
109                             "NOT RUN [AS-EJB] : Could not create an descriptor object"));
110         }
111         return result;
112     }
113 }
114
Popular Tags