KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias.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 java.util.*;
29 import com.sun.enterprise.deployment.EjbDescriptor;
30 import com.sun.enterprise.deployment.EjbSessionDescriptor;
31 import com.sun.enterprise.tools.verifier.*;
32 import com.sun.enterprise.tools.verifier.tests.*;
33
34 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
35
36 import com.sun.enterprise.tools.common.dd.ejb.SunEjbJar;
37 import com.sun.enterprise.tools.common.dd.ejb.EnterpriseBeans;
38 import com.sun.enterprise.tools.common.dd.ejb.Ejb;
39 import com.sun.enterprise.deployment.EjbEntityDescriptor;
40 import com.sun.enterprise.deployment.EjbSessionDescriptor;
41 import java.lang.reflect.*;
42
43 import com.sun.enterprise.tools.common.dd.ejb.BeanCache;
44
45 /** ejb [0,n]
46  * bean-cache ?
47  * max-cache-size ? [String]
48  * is-cache-overflow-allowed ? [String]
49  * cache-idle-timout-in-seconds ? [String]
50  * removal-timeout-in-seconds ? [String]
51  * victim-selection-policy ? [String]
52  *
53  * The bean-cache element specifies the bean cache properties for the bean.
54  * This is valid only for entity beans and stateful session beans
55  * @author Irfan Ahmed
56  */

57 public class ASEjbBeanCache extends EjbTest implements EjbCheck {
58
59     public BeanCache beanCache;
60     public Ejb testCase;
61     
62     public void getBeanCache(EjbDescriptor descriptor, SunEjbJar ejbJar)
63     {
64         testCase = getEjb(descriptor.getName(),ejbJar);
65         beanCache = testCase.getBeanCache();
66     }
67     
68     public Result check(EjbDescriptor descriptor)
69     {
70         Result result = getInitializedResult();
71     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
72         
73         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
74         if(ejbJar!=null)
75         {
76             getBeanCache(descriptor,ejbJar);
77             if(beanCache!=null)
78             {
79                 if(descriptor instanceof EjbEntityDescriptor
80                     || (descriptor instanceof EjbSessionDescriptor
81                             && ((EjbSessionDescriptor)descriptor).getSessionTypeString().equals(EjbSessionDescriptor.STATEFUL)))
82                 {
83                     result.passed(smh.getLocalString(getClass().getName()+".passed",
84                         "PASSED [AS-EJB ejb] : bean-cache Element parsed"));
85                 }
86                 else
87                 {
88                     result.warning(smh.getLocalString(getClass().getName()+".warning1",
89                     "WARNING [AS-EJB ejb] : bean-cache should be defined only for Stateful Session and Entity Beans"));
90                 }
91             /*
92                 if(descriptor instanceof EjbSessionDescriptor
93                     && ((EjbSessionDescriptor)descriptor).getSessionTypeString().equals(EjbSessionDescriptor.STATELESS))
94                 {
95                     result.warning(smh.getLocalString(getClass().getName()+".warning1",
96                     "WARNING [AS-EJB ejb] : bean-cache should be defined for Stateful Session and Entity Beans"));
97                 }
98                 else
99                     result.passed(smh.getLocalString(getClass().getName()+".passed",
100                         "PASSED [AS-EJB ejb] : bean-cache Element parsed"));
101             */

102             }
103             else
104             {
105                 if(descriptor instanceof EjbEntityDescriptor
106                     || (descriptor instanceof EjbSessionDescriptor
107                             && ((EjbSessionDescriptor)descriptor).getSessionTypeString().equals(EjbSessionDescriptor.STATEFUL)))
108                 {
109                     result.warning(smh.getLocalString(getClass().getName()+".warning",
110                         "WARNING [AS-EJB ejb] : bean-cache should be defined for Stateful Session and Entity Beans"));
111                 }
112                 else
113                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
114                         "NOT APPLICABLE [AS-EJB ejb] : bean-cache element not defined"));
115             }
116         }
117         else
118         {
119             result.addErrorDetails(smh.getLocalString
120                                    ("tests.componentNameConstructor",
121                                     "For [ {0} ]",
122                                     new Object JavaDoc[] {compName.toString()}));
123             result.addErrorDetails(smh.getLocalString
124                  (getClass().getName() + ".notRun",
125                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
126         }
127         return result;
128     }
129 }
130         
131
Popular Tags