KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ejb30 > InitMethodReturnType


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
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
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 in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 package com.sun.enterprise.tools.verifier.tests.ejb.ejb30;
22
23 import com.sun.enterprise.tools.verifier.Result;
24 import com.sun.enterprise.deployment.EjbSessionDescriptor;
25 import com.sun.enterprise.deployment.EjbInitInfo;
26
27 import java.util.Set JavaDoc;
28 import java.lang.reflect.Method JavaDoc;
29
30 /**
31  * The Init annotation is used to specify the correspondence of a method on the
32  * bean class with a createMETHOD method for an adapted EJB 2.1 EJBHome and/or
33  * EJBLocalHome client view.
34  * The result type of such an Init method is required to be void.
35  *
36  * @author Vikas Awasthi
37  */

38 public class InitMethodReturnType extends SessionBeanTest {
39
40     public Result check(EjbSessionDescriptor descriptor) {
41         Set JavaDoc<EjbInitInfo> initMethods = descriptor.getInitMethods();
42         for (EjbInitInfo initInfo : initMethods) {
43             Method JavaDoc method = initInfo.getBeanMethod().getMethod(descriptor);
44             if(!method.getReturnType().getName().equals("void")) {
45                 addErrorDetails(result, compName);
46                 result.failed(smh.getLocalString
47                         (getClass().getName()+".failed",
48                         "Wrong init method [ {0} ].",
49                         new Object JavaDoc[] {method}));
50             }
51         }
52         
53         if(result.getStatus() != Result.FAILED) {
54             addGoodDetails(result, compName);
55             result.passed(smh.getLocalString
56                     (getClass().getName()+".passed",
57                     "Valid init method(s)."));
58         }
59         return result;
60     }
61 }
62
Popular Tags