KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > messagebean > EjbCreateModifiers


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.messagebean;
25
26 import java.lang.reflect.Method JavaDoc;
27 import java.lang.reflect.Modifier JavaDoc;
28 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
29 import com.sun.enterprise.tools.verifier.Result;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32
33 /**
34  * Verify that message beans implement the ejbCreate method with a void return
35  * type
36  *
37  * @author Jerome Dochez
38  * @version
39  */

40 public class EjbCreateModifiers extends MessageBeanTest {
41
42     /**
43      * <p>
44      * @return the name of the method on the message bean this test applies to
45      * </p>
46      */

47     protected String JavaDoc getMethodName() {
48         return "ejbCreate";
49     }
50     
51     /**
52      * Run a verifier test against an individual declared message
53      * drive bean component
54      *
55      * @param descriptor the Enterprise Java Bean deployment descriptor
56      *
57      * @return <code>Result</code> the results for this assertion
58      */

59     public Result check(EjbMessageBeanDescriptor descriptor) {
60         
61         Result result = getInitializedResult();
62     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
63         Class JavaDoc mbc = loadMessageBeanClass(descriptor, result);
64         if (mbc!=null) {
65             Method JavaDoc m = getMethod(mbc, getMethodName(),null);
66             if (m!=null) {
67                 int modifiers = m.getModifiers();
68                 if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers) && !Modifier.isFinal(modifiers)) {
69                     result.addGoodDetails(smh.getLocalString
70                       ("tests.componentNameConstructor",
71                        "For [ {0} ]",
72                        new Object JavaDoc[] {compName.toString()}));
73             
74             result.passed(smh.getLocalString
75                     ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateModifiers.passed",
76                         "Message-Drive bean [ {0} ] provide an {1} implementation declared public and not static or final",
77                     new Object JavaDoc[] {(descriptor).getEjbClassName(), getMethodName()}));
78                 } else {
79             result.addErrorDetails(smh.getLocalString
80                        ("tests.componentNameConstructor",
81                         "For [ {0} ]",
82                         new Object JavaDoc[] {compName.toString()}));
83             result.failed(smh.getLocalString
84                 ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateModifiers.failed",
85                         "Error: Message-Drive bean [ {0} ] {1} implementation is either not public or is static or final",
86                     new Object JavaDoc[] {(descriptor).getEjbClassName(), getMethodName()}));
87                 }
88             } else {
89         result.addErrorDetails(smh.getLocalString
90                        ("tests.componentNameConstructor",
91                     "For [ {0} ]",
92                     new Object JavaDoc[] {compName.toString()}));
93         result.failed(smh.getLocalString
94             ("com.sun.enterprise.tools.verifier.tests.ejb.messagebean.EjbCreateExists.failed",
95                     "Error: Message-Drive bean [ {0} ] does not implement an {1} with no arguments",
96                 new Object JavaDoc[] {(descriptor).getEjbClassName(), getMethodName()}));
97             }
98         }
99         return result;
100     }
101 }
102
Popular Tags