KickJava   Java API By Example, From Geeks To Geeks.

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


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
32 import java.util.Set JavaDoc;
33
34 /**
35  * A business interface must not extend javax.ejb.EJBObject or
36  * javax.ejb.EJBLocalObject.
37  *
38  * @author Vikas Awasthi
39  */

40 public class BusinessIntfInheritance extends EjbTest {
41     
42     public Result check(EjbDescriptor descriptor) {
43         Result result = getInitializedResult();
44         ComponentNameConstructor compName =
45                 getVerifierContext().getComponentNameConstructor();
46
47         Set JavaDoc<String JavaDoc> remoteAndLocalIntfs = descriptor.getRemoteBusinessClassNames();
48         remoteAndLocalIntfs.addAll(descriptor.getLocalBusinessClassNames());
49         
50         for (String JavaDoc remoteOrLocalIntf : remoteAndLocalIntfs) {
51             try {
52                 Class JavaDoc c = Class.forName(remoteOrLocalIntf,
53                                         false,
54                                         getVerifierContext().getClassLoader());
55                 if(javax.ejb.EJBObject JavaDoc.class.isAssignableFrom(c) ||
56                         javax.ejb.EJBLocalObject JavaDoc.class.isAssignableFrom(c)) {
57                     addErrorDetails(result, compName);
58                     result.failed(smh.getLocalString
59                                     (getClass().getName() + ".failed",
60                                     "[ {0} ] extends either javax.ejb.EJBObject " +
61                                     "or javax.ejb.EJBLocalObject.",
62                                     new Object JavaDoc[] {remoteOrLocalIntf}));
63                 }
64             } catch (ClassNotFoundException JavaDoc e) {
65                 Verifier.debug(e);
66                 addErrorDetails(result, compName);
67                 result.failed(smh.getLocalString
68                                 (getClass().getName() + ".failed1",
69                                 "Business Interface class [ {0} ] not found.",
70                                 new Object JavaDoc[] {remoteOrLocalIntf}));
71             }
72         }
73         if(result.getStatus()!=Result.FAILED) {
74             addGoodDetails(result, compName);
75             result.passed(smh.getLocalString
76                             (getClass().getName() + ".passed",
77                             "Business Interface(s) are valid."));
78         }
79         
80         return result;
81     }
82 }
83
Popular Tags