KickJava   Java API By Example, From Geeks To Geeks.

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


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

26
27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
31 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
32 import com.sun.enterprise.tools.verifier.Result;
33 import com.sun.enterprise.deployment.EjbEntityDescriptor;
34 import com.sun.enterprise.deployment.EjbSessionDescriptor;
35 import com.sun.enterprise.deployment.runtime.BeanCacheDescriptor;
36
37
38 /** ejb [0,n]
39  * bean-cache ?
40  * max-cache-size ? [String]
41  * is-cache-overflow-allowed ? [String]
42  * cache-idle-timout-in-seconds ? [String]
43  * removal-timeout-in-seconds ? [String]
44  * victim-selection-policy ? [String]
45  *
46  * The bean-cache element specifies the bean cache properties for the bean.
47  * This is valid only for entity beans and stateful session beans
48  * @author Irfan Ahmed
49  */

50
51 public class ASEjbBeanCache extends EjbTest implements EjbCheck {
52
53     public BeanCacheDescriptor beanCache;
54     public Result check(EjbDescriptor descriptor)
55     {
56         Result result = getInitializedResult();
57         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
58         String JavaDoc beanCache = null;
59         try{
60             beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache");
61             if(beanCache!=null)
62             {
63                 if(descriptor instanceof EjbEntityDescriptor
64                         || (descriptor instanceof EjbSessionDescriptor
65                         && ((EjbSessionDescriptor)descriptor).getSessionType().equals(EjbSessionDescriptor.STATEFUL)))
66                 {
67                     addGoodDetails(result, compName);
68                     result.passed(smh.getLocalString(getClass().getName()+".passed",
69                                 "PASSED [AS-EJB ejb] : bean-cache Element parsed"));
70                 }
71                 else
72                 {
73                     addWarningDetails(result, compName);
74                     result.warning(smh.getLocalString(getClass().getName()+".warning1",
75                             "WARNING [AS-EJB ejb] : bean-cache should be defined only for Stateful Session and Entity Beans"));
76                 }
77             }
78             else
79             {
80                 addNaDetails(result, compName);
81                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
82                         "NOT APPLICABLE [AS-EJB ejb] : bean-cache element not defined"));
83             }
84         }catch(Exception JavaDoc ex)
85         {
86             addErrorDetails(result, compName);
87             result.addErrorDetails(smh.getLocalString
88                     (getClass().getName() + ".notRun",
89                             "NOT RUN [AS-EJB] : Could not get a beanCache object"));
90         }
91         return result;
92     }
93 }
94
Popular Tags