KickJava   Java API By Example, From Geeks To Geeks.

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


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.beanpool;
25
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.tools.verifier.Verifier;
30
31
32 /** ejb [0,n]
33  * bean-pool ?
34  * steady-pool-size ? [String]
35  * pool-resize-quantity ? [String]
36  * max-pool-size ? [String]
37  * pool-idle-timeout-in-seconds ? [String]
38  * max-wait-time-in-millis ? [String]
39  *
40  * The max-pool-size element specifies the maximum pool size.
41  *
42  * Valid values are 0 to MAX_INT
43  *
44  *
45  * @author Irfan Ahmed
46  */

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