KickJava   Java API By Example, From Geeks To Geeks.

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


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.tools.verifier.Verifier;
30 import com.sun.enterprise.deployment.EjbDescriptor;
31 import com.sun.enterprise.deployment.EjbInterceptor;
32
33 import java.lang.reflect.Method JavaDoc;
34 import java.util.List JavaDoc;
35 import java.util.Set JavaDoc;
36 import java.util.HashSet JavaDoc;
37
38 /**
39  * Interceptor methods may throw runtime exceptions or application exceptions
40  * that are allowed in the throws clause of the business method.
41  * The methods of the business interface should not throw the
42  * java.rmi.RemoteException, even if the interface is a remote business
43  * interface or the bean class is annotated WebService or the method as
44  * WebMethod.
45  *
46  * These statements from the specification indicate that the interceptor method
47  * must not throw java.rmi.RemoteException
48  *
49  * @author Vikas Awasthi
50  */

51 public class InterceptorMethodException extends EjbTest {
52
53     public Result check(EjbDescriptor descriptor) {
54         Result result = getInitializedResult();
55         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
56         Set JavaDoc<Method JavaDoc> interceptorMethods = new HashSet JavaDoc<Method JavaDoc>();
57
58         if(descriptor.hasAroundInvokeMethod()) {
59 //XXX
60
/*
61             Method method = descriptor.getAroundInvokeMethod().getMethod(descriptor);
62             interceptorMethods.add(method);
63 */

64         }
65         
66         List JavaDoc<EjbInterceptor> interceptors = descriptor.getInterceptorChain();
67         
68         for (EjbInterceptor interceptor : interceptors) {
69             try {
70                 Class JavaDoc interceptorClass =
71                         Class.forName(interceptor.getInterceptorClassName(),
72                                       false,
73                                       getVerifierContext().getClassLoader());
74 //XXX
75
/*
76                 Method method = interceptor.getAroundInvokeMethod().getMethod(interceptorClass);
77                 interceptorMethods.add(method);
78 */

79             } catch (ClassNotFoundException JavaDoc e) {
80                 Verifier.debug(e);
81                 addErrorDetails(result, compName);
82                 result.failed(smh.getLocalString
83                                 (getClass().getName() + ".failed1",
84                                 "[ {0} ] not found.",
85                                 new Object JavaDoc[] {interceptor.getInterceptorClassName()}));
86             }
87         }
88         
89         for (Method JavaDoc method : interceptorMethods) {
90             Class JavaDoc[] exceptions = method.getExceptionTypes();
91             for (Class JavaDoc excepClass : exceptions) {
92                 if(java.rmi.RemoteException JavaDoc.class.isAssignableFrom(excepClass)) {
93                     addErrorDetails(result, compName);
94                     result.failed(smh.getLocalString
95                                     (getClass().getName() + ".failed",
96                                     "Method [ {0} ] throws java.rmi.RemoteException.",
97                                     new Object JavaDoc[] {method}));
98                 }
99             }
100         }
101         
102         if(result.getStatus()!=Result.FAILED) {
103             addGoodDetails(result, compName);
104             result.passed(smh.getLocalString
105                             (getClass().getName() + ".passed",
106                             "Valid Interceptor methods."));
107         }
108
109         return result;
110     }
111 }
112
Popular Tags