KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > homeintf > remotehomeintf > RemoteHomeInterfaceRmiIIOP


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.homeintf.remotehomeintf;
24
25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
27 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils;
28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
29 import com.sun.enterprise.tools.verifier.Result;
30 import com.sun.enterprise.tools.verifier.Verifier;
31 import com.sun.enterprise.deployment.EjbDescriptor;
32 import com.sun.enterprise.deployment.EjbEntityDescriptor;
33 import com.sun.enterprise.deployment.EjbSessionDescriptor;
34
35 /**
36  * Home Interface follows the standard rules for RMI-IIOP remote interfaces
37  * test.
38  *
39  * All enterprise beans home interface's must follow the standard rules
40  * for RMI-IIOP remote interfaces.
41  */

42 public class RemoteHomeInterfaceRmiIIOP extends EjbTest implements EjbCheck {
43
44
45     /**
46      * Home Interface follows the standard rules for RMI-IIOP remote interfaces
47      * test.
48      *
49      * All enterprise beans home interface's must follow the standard rules
50      * for RMI-IIOP remote interfaces.
51      *
52      * @param descriptor the Enterprise Java Bean deployment descriptor
53      *
54      * @return <code>Result</code> the results for this assertion
55      */

56     public Result check(EjbDescriptor descriptor) {
57
58     Result result = getInitializedResult();
59     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
60     
61     if(descriptor.getHomeClassName() == null || "".equals(descriptor.getHomeClassName())) {
62             addNaDetails(result, compName);
63             result.notApplicable(smh.getLocalString
64                        ("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp",
65                         "Not Applicable because, EJB [ {0} ] has Local Interfaces only.",
66                                           new Object JavaDoc[] {descriptor.getEjbClassName()}));
67
68         return result;
69     }
70     
71     if ((descriptor instanceof EjbSessionDescriptor) ||
72         (descriptor instanceof EjbEntityDescriptor)) {
73  
74         try {
75         ClassLoader JavaDoc jcl = getVerifierContext().getClassLoader();
76         Class JavaDoc c = Class.forName(descriptor.getHomeClassName(), false, jcl);
77
78         // remote interface must be defined as valid Rmi-IIOP remote interface
79
boolean isValidRmiIIOPInterface = false;
80         if (RmiIIOPUtils.isValidRmiIIOPInterface(c) && RmiIIOPUtils.isValidRmiIIOPInterfaceMethods(c)) {
81             isValidRmiIIOPInterface = true;
82         }
83  
84         // remote interface must be defined as valid Rmi-IIOP remote interface
85
if (!isValidRmiIIOPInterface){
86             addErrorDetails(result, compName);
87             result.failed(smh.getLocalString
88                   (getClass().getName() + ".failed",
89                    "Error: [ {0} ] is not defined as valid RMI-IIOP remote interface. All enterprise beans home interfaces must be defined as valid RMI-IIOP remote interface. [ {1} ] is not a valid remote home interface.",
90                    new Object JavaDoc[] {descriptor.getHomeClassName(),descriptor.getHomeClassName()}));
91         } else {
92             addGoodDetails(result, compName);
93             result.passed(smh.getLocalString
94                   (getClass().getName() + ".passed",
95                    "[ {0} ] properly declares the home interface as valid RMI-IIOP remote interface.",
96                    new Object JavaDoc[] {descriptor.getHomeClassName()}));
97         }
98         } catch (ClassNotFoundException JavaDoc e) {
99         Verifier.debug(e);
100         addErrorDetails(result, compName);
101         result.failed(smh.getLocalString
102                   (getClass().getName() + ".failedException",
103                    "Error: [ {0} ] class not found.",
104                    new Object JavaDoc[] {descriptor.getHomeClassName()}));
105         }
106         return result;
107  
108     } else {
109         addNaDetails(result, compName);
110         result.notApplicable(smh.getLocalString
111                  (getClass().getName() + ".notApplicable",
112                   "[ {0} ] expected {1} bean or {2} bean, but called with {3}.",
113                   new Object JavaDoc[] {getClass(),"Session","Entity",descriptor.getName()}));
114         return result;
115     }
116     }
117 }
118
Popular Tags