KickJava   Java API By Example, From Geeks To Geeks.

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


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.ejb30;
25
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.deployment.EjbDescriptor;
30 import com.sun.enterprise.deployment.MethodDescriptor;
31 import com.sun.enterprise.deployment.LifecycleCallbackDescriptor;
32
33 import java.util.Set JavaDoc;
34 import java.lang.reflect.Method JavaDoc;
35
36 /**
37  * An AroundInvoke method must not be a business method.
38  *
39  * @author Vikas Awasthi
40  */

41 public class AroundInvokeNotBusinessMethod extends EjbTest {
42
43     public Result check(EjbDescriptor descriptor) {
44         Result result = getInitializedResult();
45         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
46         ClassLoader JavaDoc cl = getVerifierContext().getClassLoader();
47
48         if(descriptor.hasAroundInvokeMethod()) {
49             Set JavaDoc<MethodDescriptor> businessMethods = descriptor.getMethodDescriptors();
50             Set JavaDoc<LifecycleCallbackDescriptor> aiDescriptors =
51                                         descriptor.getAroundInvokeDescriptors();
52             
53             for (LifecycleCallbackDescriptor aiDesc : aiDescriptors) {
54                 try {
55                     Method JavaDoc interceptorMethod = aiDesc.getLifecycleCallbackMethodObject(cl);
56                     MethodDescriptor interceptorMD = new MethodDescriptor(interceptorMethod);
57                     if(businessMethods.contains(interceptorMD)) {
58                         addErrorDetails(result, compName);
59                         result.failed(smh.getLocalString
60                                 (getClass().getName() + ".failed",
61                                 "AroundInvoke method [ {0} ] is a business method.",
62                                 new Object JavaDoc[] {interceptorMethod}));
63                     }
64                 } catch (Exception JavaDoc e) {}// will be caught in other tests
65
}
66         }
67
68         if(result.getStatus()!=Result.FAILED) {
69             addGoodDetails(result, compName);
70             result.passed(smh.getLocalString
71                     (getClass().getName() + ".passed",
72                             "Valid Interceptor methods."));
73         }
74         return result;
75     }
76 }
77
Popular Tags