KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime;
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the License). You may not use this file except in
7  * compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
11  * glassfish/bootstrap/legal/CDDLv1.0.txt.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * Header Notice in each file and include the License file
17  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
18  * If applicable, add the following below the CDDL Header,
19  * with the fields enclosed by brackets [] replaced by
20  * you own identifying information:
21  * "Portions Copyrighted [year] [name of copyright owner]"
22  *
23  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24  */

25
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
28 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor;
30 import com.sun.enterprise.tools.verifier.Result;
31 import com.sun.enterprise.deployment.EjbMessageBeanDescriptor;
32
33
34 /** ejb [0,n]
35  * jndi-name ? [String]
36  *
37  * The jndi-name of an ejb is valid for MDBs.
38  * The jndi-name should not be an empty string.
39  * @author Irfan Ahmed
40  */

41 public class ASEjbJndiName extends EjbTest implements EjbCheck {
42
43     boolean oneFailed = false;
44     boolean oneWarning = false;
45     public Result check(EjbDescriptor descriptor) {
46         Result result = getInitializedResult();
47         ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
48         String JavaDoc ejbName = null, jndiName=null;
49         ejbName = descriptor.getName(); //get ejb-name
50
jndiName=getXPathValue("/sun-ejb-jar/enterprise-beans/ejb/jndi-name");
51         if(jndiName != null){
52             if(jndiName.trim().length()==0){
53                 check(result, descriptor, compName);
54             }else{
55                 addGoodDetails(result, compName);
56                 result.passed(smh.getLocalString(getClass().getName()+".passed",
57                         "PASSED [AS-EJB ejb] : jndi-name is {0}", new Object JavaDoc[]{jndiName}));
58             }
59         }else
60             check(result, descriptor, compName);
61
62         if(oneFailed)
63             result.setStatus(Result.FAILED);
64         else if(oneWarning)
65             result.setStatus(Result.WARNING);
66         return result;
67
68     }
69
70     public void check(Result result, EjbDescriptor descriptor, ComponentNameConstructor compName) {
71         if(descriptor instanceof EjbMessageBeanDescriptor) {
72             String JavaDoc mdbres = getXPathValue("sun-ejb-jar/enetrprise-beans/ejb/mdb-resource-adapter");
73             if (mdbres != null) {
74                 addGoodDetails(result, compName);
75                 result.passed(smh.getLocalString(getClass().getName()+".passed1",
76                         "mdb-resource-adapter is defined for the EJB {0}", new Object JavaDoc[]{mdbres}));
77             }else{
78                 oneFailed=true;
79                 addErrorDetails(result, compName);
80                 result.addErrorDetails(smh.getLocalString(getClass().getName()+".failed",
81                         "jndi-name or mdb-resource-adapter should be defined for an MDB"));
82             }
83         }else if(descriptor.isRemoteInterfacesSupported()) {
84          /** Bug#5060283 -- It is possible to use this ejb by referencing thru' ejb-ref/ejb-link.
85             * Only thing is, the accessibility of the ejb is reduced.
86             * It is only accessible to other clients bundled within this ear file.
87             * Hence, report a warning, instead of an error.
88             */

89 // oneFailed=true;
90
// addErrorDetails(result, compName);
91
// result.addErrorDetails(smh.getLocalString(getClass().getName()+".failed1",
92
// "jndi-name should be defined for a bean implementing a remote interface"));
93
oneWarning = true;
94             addWarningDetails(result, compName);
95             result.warning(smh.getLocalString(getClass().getName() + ".warning",
96                     "WARNING [AS-EJB ejb] : jndi-name is not defined for the EJB {0} although it has a remote interface.",
97                     new Object JavaDoc[]{descriptor.getName()}));
98
99         }else {
100             result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", "NOT APPLICABLE"));
101         }
102
103     }
104 }
105
Popular Tags