KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime;
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the License). You may not use this file except in
7  * compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
11  * glassfish/bootstrap/legal/CDDLv1.0.txt.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * Header Notice in each file and include the License file
17  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
18  * If applicable, add the following below the CDDL Header,
19  * with the fields enclosed by brackets [] replaced by
20  * you own identifying information:
21  * "Portions Copyrighted [year] [name of copyright owner]"
22  *
23  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24  */

25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.tools.verifier.*;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
32
33 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
34
35 import com.sun.enterprise.deployment.runtime.IASEjbExtraDescriptors;
36
37 /** ejb [0,n]
38  * jms-max-messages-load ? [String]
39  *
40  * The jms-max-messages-load specifies the maximum number of messages to
41  * load into a JMS Session.
42  * It is valid only for MDBs
43  * The value should be between 1 and MAX_INT
44  * @author Irfan Ahmed
45  */

46 public class ASEjbJMSMaxMessagesLoad extends EjbTest implements EjbCheck {
47
48     public Result check(EjbDescriptor descriptor)
49     {
50     Result result = getInitializedResult();
51     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52         
53         try{
54             IASEjbExtraDescriptors iasEjbDescriptor = descriptor.getIASEjbExtraDescriptors();
55             int value = iasEjbDescriptor.getJmsMaxMessagesLoad();
56             Integer JavaDoc jmsMaxMsgs = new Integer JavaDoc(value);
57             if (jmsMaxMsgs != null){
58                 if(value<1 || value>Integer.MAX_VALUE){
59                     addErrorDetails(result, compName);
60                     result.failed(smh.getLocalString(getClass().getName()+".failed",
61                         "FAILED [AS-EJB ejb] : {0} is not a valid value for jms-max-messages-load. It should be " + '\n' +
62                         "between 0 and MAX_INT", new Object JavaDoc[]{new Integer JavaDoc(value)}));
63                 }else{
64                     addGoodDetails(result, compName);
65                     result.passed(smh.getLocalString(getClass().getName()+".passed",
66                         "PASSED [AS-EJB ejb] : jms-max-messages-load is {0}", new Object JavaDoc[]{jmsMaxMsgs}));
67                 }
68             }else{
69                 if(descriptor instanceof EjbMessageBeanDescriptor){
70                     //<addition author="irfan@sun.com" [bug/rfe]-id="4724447" >
71
//Change in message output ms->jms //
72
addWarningDetails(result, compName);
73                     result.warning(smh.getLocalString(getClass().getName()+".warning",
74                         "WARNING [AS-EJB ejb] : jms-max-messages-load should be defined for MDBs"));
75                 }else{
76                     addNaDetails(result, compName);
77                     result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable",
78                         "NOT APPLICABLE [AS-EJB ejb] : jms-max-messages-load element is not defined"));
79                 }
80             }
81         }catch(Exception JavaDoc ex){
82             addErrorDetails(result, compName);
83             result.addErrorDetails(smh.getLocalString
84                  (getClass().getName() + ".notRun",
85                   "NOT RUN [AS-EJB] : Could not create a descriptor object"));
86         }
87         return result;
88     }
89 }
90
Popular Tags