KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ias > 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.ias.beanpool;
25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.deployment.EjbSessionDescriptor;
30 import com.sun.enterprise.tools.verifier.*;
31 import com.sun.enterprise.tools.verifier.tests.*;
32
33 import com.sun.enterprise.tools.common.dd.ejb.*;
34
35
36 /** ejb [0,n]
37  * bean-pool ?
38  * steady-pool-size ? [String]
39  * pool-resize-quantity ? [String]
40  * max-pool-size ? [String]
41  * pool-idle-timeout-in-seconds ? [String]
42  * max-wait-time-in-millis ? [String]
43  *
44  * The pool-idle-timeout-in-seconds specifies the maximum time for which a SSB or
45  * an MDB is allowed to be idle in the bean pool.
46  *
47  * Valid value are 0 to MAX_LONG
48  *
49  *
50  * @author Irfan Ahmed
51  */

52 public class ASEjbBPPoolIdleTime extends ASEjbBeanPool
53 {
54     
55     public Result check(EjbDescriptor descriptor)
56     {
57
58     Result result = getInitializedResult();
59     ComponentNameConstructor compName = new ComponentNameConstructor(descriptor);
60
61         SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
62         String JavaDoc ejbName = null;
63         Ejb testCase = null;
64         boolean oneFailed = false;
65         if(ejbJar!=null)
66         {
67             getBeanPool(descriptor,ejbJar);
68             if(beanPool!=null)
69             {
70                 String JavaDoc poolIdleTimeout = beanPool.getPoolIdleTimeoutInSeconds();
71                 if(poolIdleTimeout!=null)
72                 {
73                     if(poolIdleTimeout.length()==0)
74                     {
75                         result.failed(smh.getLocalString(getClass().getName()+".failed1",
76                             "FAILED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds cannot be empty"));
77                     }
78                     else
79                     {
80                         try
81                         {
82                             long value = Long.valueOf(poolIdleTimeout).longValue();
83                             if(value < 0 || value > Long.MAX_VALUE)
84                             {
85                                 result.failed(smh.getLocalString(getClass().getName()+".failed2",
86                                     "FAILED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds cannot be {0}. It should be between 0 and {1}",
87                                     new Object JavaDoc[]{new Long JavaDoc(value),new Long JavaDoc(Long.MAX_VALUE)}));
88                             }
89                             else
90                             {
91                                 result.passed(smh.getLocalString(getClass().getName()+".passed",
92                                     "PASSED [AS-EJB bean-pool] : pool-idle-timeout-in-seconds is {0}",
93                                     new Object JavaDoc[]{new Long JavaDoc(value)}));
94                             }
95                         }
96                         catch(NumberFormatException JavaDoc nfex)
97                         {
98                             Verifier.debug(nfex);
99                             result.failed(smh.getLocalString(getClass().getName()+".failed3",
100                                 "FAILED [AS-EJB bean-pool] : {0} is not a valid Long number",new Object JavaDoc[]{poolIdleTimeout}));
101                         }
102                     }
103                 }
104                 else
105                 {
106                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
107                     "NOT APPLICABLE [AS-EJB bean-pool] : pool-idle-timeout-in-seconds element not defined"));
108                 }
109             }
110             else
111             {
112                 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
113                     "NOT APPLICABLE [AS-EJB] : bean-pool element not defined"));
114             }
115         }
116         else
117         {
118             result.addErrorDetails(smh.getLocalString
119                                    ("tests.componentNameConstructor",
120                                     "For [ {0} ]",
121                                     new Object JavaDoc[] {compName.toString()}));
122             result.addErrorDetails(smh.getLocalString
123                  (getClass().getName() + ".notRun",
124                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
125         }
126         return result;
127     }
128 }
129
130
131
Popular Tags