KickJava   Java API By Example, From Geeks To Geeks.

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


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;
24
25 import com.sun.enterprise.deployment.EjbDescriptor;
26 import com.sun.enterprise.deployment.EjbEntityDescriptor;
27 import com.sun.enterprise.deployment.EjbSessionDescriptor;
28 import com.sun.enterprise.tools.verifier.Result;
29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
30
31
32 /**
33  * Bean interface type test.
34  * The bean provider must provide either Local or Remote or Both interfaces
35  *
36  * @author Sheetal Vartak
37  */

38 public class EjbHasLocalorRemoteorBothInterfaces extends EjbTest implements EjbCheck {
39
40     /**
41      * Bean interface type test.
42      * The bean provider must provide either Local or Remote or Both interfaces
43      *
44      * @param descriptor the Enterprise Java Bean deployment descriptor
45      *
46      * @return <code>Result</code> the results for this assertion
47      */

48     public Result check(EjbDescriptor descriptor) {
49
50         Result result = getInitializedResult();
51         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
52
53         if (!(descriptor instanceof EjbSessionDescriptor) &&
54                 !(descriptor instanceof EjbEntityDescriptor)) {
55             addNaDetails(result, compName);
56             result.notApplicable(smh.getLocalString
57                     ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceClassExist.notApplicable1",
58                             "Test apply only to session or entity beans."));
59             return result;
60         }
61         if ((descriptor.getRemoteClassName() == null || "".equals(descriptor.getRemoteClassName()))&&
62                 (descriptor.getLocalClassName() == null || "".equals(descriptor.getLocalClassName()))) {
63
64             if (implementsEndpoints(descriptor)) {
65                 addNaDetails(result, compName);
66                 result.notApplicable(smh.getLocalString
67                         ("com.sun.enterprise.tools.verifier.tests.ejb.webservice.notapp",
68                                 "Not Applicable because, EJB [ {0} ] implements a Service Endpoint Interface.",
69                                 new Object JavaDoc[] {compName.toString()}));
70                 return result;
71             }
72             else {
73                 addErrorDetails(result, compName);
74                 result.failed(smh.getLocalString
75                         (getClass().getName() + ".failed",
76                                 "Ejb [ {0} ] does not have local or remote interfaces",
77                                 new Object JavaDoc[] {descriptor.getEjbClassName()}));
78                 return result;
79             }
80         }
81         else {
82             addGoodDetails(result, compName);
83             result.passed(smh.getLocalString
84                     (getClass().getName() + ".passed",
85                             "Ejb [ {0} ] does have valid local and/or remote interfaces",
86                             new Object JavaDoc[] {descriptor.getEjbClassName()}));
87             return result;
88         }
89     }
90 }
91
92
Popular Tags