KickJava   Java API By Example, From Geeks To Geeks.

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


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.Result;
28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
29 import com.sun.enterprise.tools.verifier.Verifier;
30
31 /** ejb [0,n]
32  * bean-pool ?
33  * steady-pool-size ? [String]
34  * pool-resize-quantity ? [String]
35  * max-pool-size ? [String]
36  * pool-idle-timeout-in-seconds ? [String]
37  * max-wait-time-in-millis ? [String]
38  *
39  * The pool-idle-timeout-in-seconds specifies the maximum time for which a SSB or
40  * an MDB is allowed to be idle in the bean pool.
41  *
42  * Valid value are 0 to MAX_LONG
43  *
44  *
45  * @author Irfan Ahmed
46  */

47
48 public class ASEjbBPPoolIdleTime 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 poolIdleTimeout = null;
57         try
58         {
59             pool = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-pool");
60             if (pool!=null)
61             {
62                 poolIdleTimeout = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-pool/pool-idle-timeout-in-seconds");
63                 try{
64                     if (poolIdleTimeout!=null)
65                     {
66                         poolIdleTimeout = poolIdleTimeout.trim();
67                         if (poolIdleTimeout.length()==0)
68                         {
69                             addErrorDetails(result, compName);
70                             result.failed(smh.getLocalString(getClass().getName()+".failed",
71                                 "FAILED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds cannot be empty"));
72
73                         }else
74                         {
75                             long value = new Integer JavaDoc(poolIdleTimeout).longValue();
76                             if(value < 0 || value > Long.MAX_VALUE)
77                             {
78                                 addErrorDetails(result, compName);
79                                 result.failed(smh.getLocalString(getClass().getName()+".failed1",
80                                     "FAILED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds cannot be {0}. It should be between 0 and {1}",
81                                     new Object JavaDoc[]{new Long JavaDoc(value),new Long JavaDoc(Long.MAX_VALUE)}));
82                             }
83                             else
84                             {
85                                 addGoodDetails(result, compName);
86                                 result.passed(smh.getLocalString(getClass().getName()+".passed",
87                                     "PASSED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds is {0}",
88                                     new Object JavaDoc[]{new Long JavaDoc(value)}));
89                             }
90                         }
91                     }else // if pool-idle-timeout is not specified
92
{
93                         addNaDetails(result, compName);
94                         result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
95                             "NOT APPLICABLE [AS-EJB bean-pool] : pool-idle-timeout-in-seconds element not defined"));
96                     }
97                 }catch(NumberFormatException JavaDoc nfex){
98                     Verifier.debug(nfex);
99                     addErrorDetails(result, compName);
100                     result.failed(smh.getLocalString(getClass().getName()+".failed2",
101                         "FAILED [AS-EJB bean-pool] : The value [ {0} ] for pool-idle-timeout-in-seconds is not a valid Integer number",new Object JavaDoc[]{poolIdleTimeout}));
102
103
104                 }
105
106             }else //if bean-pool elememnt is not present
107
{
108                 addNaDetails(result, compName);
109                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1",
110                     "NOT APPLICABLE [AS-EJB] : bean-pool element not defined"));
111             }
112
113         }catch (Exception JavaDoc ex){
114             addErrorDetails(result, compName);
115             result.addErrorDetails(smh.getLocalString
116                  (getClass().getName() + ".notRun",
117                   "NOT RUN [AS-EJB] : Could not create the descriptor object"));
118         }
119         return result;
120     }
121 }
Popular Tags