KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > appclient > AppClientEjbRefNamePrefixed


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.appclient;
24
25 import java.util.*;
26 import com.sun.enterprise.deployment.*;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.*;
29
30 /**
31  * The application client ejb-ref-name element contains the name of an EJB
32  * reference. The EJB reference is an entry in the enterprise bean's
33  * environment. It is recommended that name is prefixed with "ejb/".
34  */

35 public class AppClientEjbRefNamePrefixed extends AppClientTest implements AppClientCheck {
36
37
38     /**
39      * The application client ejb-ref-name element contains the name of an EJB
40      * reference. The EJB reference is an entry in the enterprise bean's
41      * environment. It is recommended that name is prefixed with "ejb/".
42      *
43      * @param descriptor the app-client deployment descriptor
44      *
45      * @return <code>Result</code> the results for this assertion
46      */

47     public Result check(ApplicationClientDescriptor descriptor) {
48     Result result = getInitializedResult();
49 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
50
51     boolean oneWarning = false;
52     if (!descriptor.getEjbReferenceDescriptors().isEmpty()) {
53         for (Iterator itr = descriptor.getEjbReferenceDescriptors().iterator();
54          itr.hasNext();) {
55         EjbReferenceDescriptor nextEjbReference = (EjbReferenceDescriptor) itr.next();
56         String JavaDoc ejbRefName = nextEjbReference.getName();
57
58         if (ejbRefName.startsWith("ejb/")) {
59             result.addGoodDetails(smh.getLocalString
60                        ("tests.componentNameConstructor",
61                     "For [ {0} ]",
62                     new Object JavaDoc[] {compName.toString()}));
63             result.addGoodDetails
64             (smh.getLocalString
65              (getClass().getName() + ".passed",
66               "[ {0} ] is prefixed with recommended string \"ejb/\" within application client [ {1} ]",
67               new Object JavaDoc[] {ejbRefName,descriptor.getName()}));
68         } else {
69             if (!oneWarning) {
70             oneWarning = true;
71             }
72             result.addWarningDetails(smh.getLocalString
73                        ("tests.componentNameConstructor",
74                     "For [ {0} ]",
75                     new Object JavaDoc[] {compName.toString()}));
76             result.addWarningDetails
77             (smh.getLocalString
78              (getClass().getName() + ".warning",
79               "Warning: [ {0} ] is not prefixed with recommended string \"ejb/\" within application client [ {1} ]",
80               new Object JavaDoc[] {ejbRefName,descriptor.getName()}));
81         }
82         }
83         if (oneWarning) {
84         result.setStatus(Result.WARNING);
85         } else {
86         result.setStatus(Result.PASSED);
87         }
88     } else {
89         result.addNaDetails(smh.getLocalString
90                        ("tests.componentNameConstructor",
91                     "For [ {0} ]",
92                     new Object JavaDoc[] {compName.toString()}));
93         result.notApplicable(smh.getLocalString
94                  (getClass().getName() + ".notApplicable",
95                   "There are no ejb references to other beans within this application client [ {0} ]",
96                   new Object JavaDoc[] {descriptor.getName()}));
97     }
98     return result;
99     }
100 }
101
Popular Tags