KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > runtime > beanpool > ASEjbBeanPool


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.beanpool;
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.EjbMessageBeanDescriptor;
36 import com.sun.enterprise.deployment.runtime.BeanPoolDescriptor;
37 import com.sun.enterprise.deployment.runtime.IASEjbExtraDescriptors;
38
39
40
41
42 /** ejb [0,n]
43  * bean-pool ?
44  * steady-pool-size ? [String]
45  * pool-resize-quantity ? [String]
46  * max-pool-size ? [String]
47  * pool-idle-timeout-in-seconds ? [String]
48  * max-wait-time-in-millis ? [String]
49  *
50  * The bean-pool element specifies the bean pool properties for the beans
51  *
52  * The bean-pool is valid only for Stateless Session Beans (SSB) and
53  * Message-Driven Beans (MDB).
54  * @author Irfan Ahmed
55  */

56
57 public class ASEjbBeanPool extends EjbTest implements EjbCheck {
58
59     
60     public BeanPoolDescriptor beanPool;
61     public Result check(EjbDescriptor descriptor)
62     {
63         Result result = getInitializedResult();
64         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
65         
66         IASEjbExtraDescriptors ejbJar = descriptor.getIASEjbExtraDescriptors();
67         if(ejbJar!=null)
68         {
69             try
70             {
71                 beanPool = ejbJar.getBeanPool();
72                 if(beanPool!=null)
73                 {
74                     if(descriptor instanceof EjbSessionDescriptor && ((EjbSessionDescriptor)descriptor).getSessionType().equals(EjbSessionDescriptor.STATEFUL))
75                     {
76                         result.addWarningDetails(smh.getLocalString
77                                       ("tests.componentNameConstructor",
78                                        "For [ {0} ]",
79                                        new Object JavaDoc[] {compName.toString()}));
80                         result.warning(smh.getLocalString(getClass().getName()+".warning",
81                             "WARNING [AS-EJB ejb] : bean-pool should be defined for Stateless Session Beans, Entity Beans or Message Driven Beans"));
82                     }else if(descriptor instanceof EjbMessageBeanDescriptor || (descriptor instanceof EjbSessionDescriptor && ((EjbSessionDescriptor)descriptor).getSessionType().equals(EjbSessionDescriptor.STATELESS)) || descriptor instanceof EjbEntityDescriptor){
83                         result.addGoodDetails(smh.getLocalString
84                                       ("tests.componentNameConstructor",
85                                        "For [ {0} ]",
86                                        new Object JavaDoc[] {compName.toString()}));
87                         result.passed(smh.getLocalString(getClass().getName()+".passed",
88                             "PASSED [AS-EJB ejb] : bean-pool is correctly defined"));
89                     
90                     }
91                 }
92                 else
93                 {
94                     result.addNaDetails(smh.getLocalString
95                                   ("tests.componentNameConstructor",
96                                    "For [ {0} ]",
97                                    new Object JavaDoc[] {compName.toString()}));
98                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
99                         "NOT APPLICABLE [AS-EJB ejb] : bean-pool element not defined"));
100                 }
101                     return result;
102             }catch(Exception JavaDoc ex)
103             {
104                 result.addErrorDetails(smh.getLocalString
105                                        ("tests.componentNameConstructor",
106                                         "For [ {0} ]",
107                                         new Object JavaDoc[] {compName.toString()}));
108                 result.addErrorDetails(smh.getLocalString
109                         (getClass().getName() + ".notRun",
110                             "NOT RUN [AS-EJB] : Could not create a beanPool object"));
111             }
112         }
113         else
114         {
115             result.addErrorDetails(smh.getLocalString
116                                    ("tests.componentNameConstructor",
117                                     "For [ {0} ]",
118                                     new Object JavaDoc[] {compName.toString()}));
119             result.addErrorDetails(smh.getLocalString
120                  (getClass().getName() + ".notRun",
121                   "NOT RUN [AS-EJB] : Could not create an IASEjbExtraDescriptor object"));
122         }
123         return result;
124     }
125 }
126         
127
Popular Tags