KickJava   Java API By Example, From Geeks To Geeks.

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


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.Method 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 constuctor test.
33  * The class must not define the finalize() method.
34  */

35 public class EjbClassFinalizeMethod extends EjbTest {
36
37
38
39     /**
40      * Enterprise Java Bean class constuctor test.
41      * The class must not define the finalize() method.
42      *
43      * @param descriptor the Enterprise Java Bean deployment descriptor
44      *
45      * @return <code>Result</code> the results for this assertion
46      */

47     public Result check(EjbDescriptor descriptor) {
48
49     Result result = getInitializedResult();
50     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
51
52         Class JavaDoc c = loadEjbClass(descriptor, result);
53         if (c!=null) {
54             
55             Method JavaDoc m = getDeclaredMethod(c, "finalize", null);
56
57             if (m!=null) {
58         result.addErrorDetails(smh.getLocalString
59                        ("tests.componentNameConstructor",
60                     "For [ {0} ]",
61                     new Object JavaDoc[] {compName.toString()}));
62                 result.failed(smh.getLocalString
63                     (getClass().getName() + ".failed",
64                     "Error: The bean class [ {0} ] must not define the " +
65                     "\n finalize() method.",
66                     new Object JavaDoc[] {descriptor.getEjbClassName()}));
67             } else {
68         result.addGoodDetails(smh.getLocalString
69                       ("tests.componentNameConstructor",
70                        "For [ {0} ]",
71                        new Object JavaDoc[] {compName.toString()}));
72                 result.passed(smh.getLocalString
73                     (getClass().getName() + ".passed",
74                     "Valid: This bean class [ {0} ] correctly does not " +
75                     "\n define the finalize() method.",
76                 new Object JavaDoc[] {descriptor.getEjbClassName()}));
77             }
78         }
79         return result;
80      }
81 }
82
Popular Tags