KickJava   Java API By Example, From Geeks To Geeks.

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


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.ejb30;
24
25 import com.sun.enterprise.tools.verifier.Result;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
28
29 import java.util.Set JavaDoc;
30
31 /**
32  * A message-driven bean class must not have a superclass that is itself a
33  * message-driven bean class.
34  *
35  * @author Vikas Awasthi
36  */

37 public class MDBInheritsMDB extends MessageBeanTest {
38     
39     public Result check(EjbMessageBeanDescriptor descriptor) {
40         try {
41             ClassLoader JavaDoc cl = getVerifierContext().getClassLoader();
42             Class JavaDoc ejbCls = Class.forName(descriptor.getEjbClassName(), false, cl);
43             Set JavaDoc<EjbDescriptor> descrptors =
44                                 descriptor.getEjbBundleDescriptor().getEjbs();
45             for (EjbDescriptor ejbDescriptor : descrptors) {
46                 if(!(ejbDescriptor instanceof EjbMessageBeanDescriptor))
47                     continue;
48                 if(descriptor.getEjbClassName().equals(ejbDescriptor.getEjbClassName()))
49                     continue;
50                 Class JavaDoc mdbCls = null;
51                 try {
52                     mdbCls = Class.forName(ejbDescriptor.getEjbClassName(), false, cl);
53                 } catch (ClassNotFoundException JavaDoc e) {
54                     continue; // ignore as this error will be caught by other tests
55
}
56                 if(mdbCls.isAssignableFrom(ejbCls)) {
57                     addErrorDetails(result, compName);
58                     result.failed(
59                             smh.getLocalString(getClass().getName()+".failed",
60                             "Message bean [ {0} ] inherits other message bean [ {1} ]",
61                             new Object JavaDoc[] {ejbCls.getName(), mdbCls.getName()}));
62                 }
63
64             }
65         } catch (ClassNotFoundException JavaDoc e) {
66             //ignore as this error will be caught by other tests
67
logger.fine(descriptor.getEjbClassName() + " Not found");
68         }
69
70         if(result.getStatus() != Result.FAILED) {
71             addGoodDetails(result, compName);
72             result.passed(
73                     smh.getLocalString(getClass().getName()+".passed",
74                             "Valid Message bean [ {0} ]",
75                             new Object JavaDoc[] {descriptor.getEjbClassName()}));
76         }
77         
78         return result;
79     }
80 }
81
Popular Tags