KickJava   Java API By Example, From Geeks To Geeks.

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


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.EjbInterceptor;
31
32 import java.util.Set JavaDoc;
33 /**
34  * An interceptor class must have a public no-arg constructor.
35  *
36  * @author Vikas Awasthi
37  */

38 public class InterceptorNoArgConstructor extends EjbTest {
39
40     public Result check(EjbDescriptor descriptor) {
41         Result result = getInitializedResult();
42         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
43         Set JavaDoc<EjbInterceptor> interceptors = descriptor.getInterceptorClasses();
44         
45         for (EjbInterceptor interceptor : interceptors) {
46             try {
47                 Class JavaDoc interceptorClass = Class.forName(interceptor.getInterceptorClassName(),
48                                                        false,
49                                                        getVerifierContext().getClassLoader());
50                 try {
51                     interceptorClass.getConstructor(new Class JavaDoc[]{});
52                 } catch (NoSuchMethodException JavaDoc e) {
53                     addErrorDetails(result, compName);
54                     result.failed(smh.getLocalString
55                                     (getClass().getName() + ".failed",
56                                     "Interceptor class [ {0} ] does not have a " +
57                                     "public constructor with no arguments.",
58                                     new Object JavaDoc[] {interceptorClass}));
59                 }
60             } catch (ClassNotFoundException JavaDoc e) {}// will be caught in other tests
61
}
62         if(result.getStatus()!=Result.FAILED) {
63             addGoodDetails(result, compName);
64             result.passed(smh.getLocalString
65                             (getClass().getName() + ".passed",
66                             "Valid Interceptor(s) used."));
67         }
68
69         return result;
70     }
71 }
72
Popular Tags