KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
32  * Enterprise Java Bean class modifiers test. The class must be defined as
33  * public.
34  *
35  * @author Jerome Dochez
36  * @version
37  */

38 public class EjbClassModifiersPublic extends EjbTest {
39
40
41     /**
42      * Enterprise Java Bean class modifiers test. The class must be defined as
43      * public.
44      *
45      * @param descriptor the Enterprise Java Bean deployment descriptor
46      *
47      * @return <code>Result</code> the results for this assertion
48      */

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