KickJava   Java API By Example, From Geeks To Geeks.

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


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

59 public class ASEjbBeanPool extends EjbTest implements EjbCheck {
60
61     public BeanPool beanPool;
62     public Ejb testCase;
63     
64     public void getBeanPool(EjbDescriptor descriptor, SunEjbJar ejbJar)
65     {
66         testCase = getEjb(descriptor.getName(),ejbJar);
67         beanPool = testCase.getBeanPool();
68     }
69     
70     public Result check(EjbDescriptor descriptor)
71     {
72         Result result = getInitializedResult();
73     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
74         
75         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
76         if(ejbJar!=null)
77         {
78             getBeanPool(descriptor,ejbJar);
79             if(beanPool!=null)
80             {
81                 if(descriptor instanceof EjbSessionDescriptor
82                     && ((EjbSessionDescriptor)descriptor).getSessionTypeString().equals(EjbSessionDescriptor.STATEFUL)
83                     || descriptor instanceof EjbEntityDescriptor)
84                 {
85                     result.warning(smh.getLocalString(getClass().getName()+".warning1",
86                     "WARNING [AS-EJB ejb] : bean-pool should be defined for Stateless Session Beans or Message Driven Beans"));
87                 }
88             }
89             else
90             {
91                 if(descriptor instanceof EjbMessageBeanDescriptor
92                     || (descriptor instanceof EjbSessionDescriptor
93                             && ((EjbSessionDescriptor)descriptor).getSessionTypeString().equals(EjbSessionDescriptor.STATELESS)))
94                 {
95                     result.warning(smh.getLocalString(getClass().getName()+".warning",
96                         "WARNING [AS-EJB ejb] : bean-pool should be defined for Stateless Session and Message Driven Beans"));
97                 }
98                 else
99                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
100                         "NOT APPLICABLE [AS-EJB ejb] : bean-pool element not defined"));
101             }
102             return result;
103         }
104         else
105         {
106             result.addErrorDetails(smh.getLocalString
107                                    ("tests.componentNameConstructor",
108                                     "For [ {0} ]",
109                                     new Object JavaDoc[] {compName.toString()}));
110             result.addErrorDetails(smh.getLocalString
111                  (getClass().getName() + ".notRun",
112                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
113             return result;
114         }
115     }
116 }
117         
118
Popular Tags