KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > beanclass > EjbClassModifiersFinal


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 package com.sun.enterprise.tools.verifier.tests.ejb.beanclass;
24
25 import java.lang.reflect.Modifier JavaDoc;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.Result;
28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
29 import com.sun.enterprise.tools.verifier.tests.*;
30
31 /** Enterprise Java Bean class modifiers test. The class must not be final.
32  */

33 public class EjbClassModifiersFinal extends EjbTest {
34
35     /** Enterprise Java Bean class modifiers test. The class must not be final.
36      *
37      * @param descriptor the Enterprise Java Bean deployment descriptor
38      *
39      * @return <code>Result</code> the results for this assertion
40      */

41     public Result check(EjbDescriptor descriptor) {
42
43     Result result = getInitializedResult();
44     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
45
46         Class JavaDoc c = loadEjbClass(descriptor, result);
47         if (c!=null) {
48             boolean isFinal = false;
49             int modifiers = c.getModifiers();
50             if (Modifier.isFinal(modifiers)) {
51                 isFinal = true;
52             }
53
54             if (!isFinal) {
55         result.addGoodDetails(smh.getLocalString
56                       ("tests.componentNameConstructor",
57                        "For [ {0} ]",
58                        new Object JavaDoc[] {compName.toString()}));
59                 result.passed(smh.getLocalString
60                     (getClass().getName() + ".passed",
61                     "[ {0} ] properly declares non-final class modifier.",
62                     new Object JavaDoc[] {descriptor.getEjbClassName()}));
63             } else if (isFinal) {
64         result.addErrorDetails(smh.getLocalString
65                        ("tests.componentNameConstructor",
66                     "For [ {0} ]",
67                     new Object JavaDoc[] {compName.toString()}));
68                 result.failed(smh.getLocalString
69                     (getClass().getName() + ".failed",
70                     "Error: Ejb Class [ {0} ] was found, but was declared as final. The class [ {1} ] must not be defined as final.",
71                     new Object JavaDoc[] {descriptor.getEjbClassName(),descriptor.getEjbClassName()}));
72             }
73         }
74         return result;
75     }
76 }
77
Popular Tags