KickJava   Java API By Example, From Geeks To Geeks.

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


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.elements;
24
25 import com.sun.enterprise.tools.verifier.tests.appclient.AppClientTest;
26 import com.sun.enterprise.tools.verifier.tests.appclient.AppClientCheck;
27 import java.util.*;
28 import com.sun.enterprise.deployment.*;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32 /**
33  * The ejb-ref-type element must be one of the following:
34  * Entity
35  * Session
36  */

37 public class AppClientEjbRefTypeElement extends AppClientTest implements AppClientCheck {
38
39
40     /**
41      * The ejb-ref-type element must be one of the following:
42      * Entity
43      * Session
44      *
45      * @param descriptor the Application client deployment descriptor
46      *
47      * @return <code>Result</code> the results for this assertion
48      */

49     public Result check(ApplicationClientDescriptor descriptor) {
50
51     Result result = getInitializedResult();
52     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53
54     boolean failed = false;
55
56     //The ejb-ref-type element must be one of the following:
57
// Entity
58
// Session
59
if (!descriptor.getEjbReferenceDescriptors().isEmpty()) {
60         for (Iterator itr = descriptor.getEjbReferenceDescriptors().iterator();
61          itr.hasNext();) {
62         EjbReferenceDescriptor nextEjbReference = (EjbReferenceDescriptor) itr.next();
63         String JavaDoc ejbRefTypeStr = nextEjbReference.getType();//getEjbDescriptor().getType();
64
if (!((ejbRefTypeStr.equals(EjbSessionDescriptor.TYPE)) ||
65               (ejbRefTypeStr.equals(EjbEntityDescriptor.TYPE)))) {
66             result.addErrorDetails(smh.getLocalString
67                        ("tests.componentNameConstructor",
68                     "For [ {0} ]",
69                     new Object JavaDoc[] {compName.toString()}));
70             result.failed(smh.getLocalString
71                   (getClass().getName() + ".failed",
72                    "Error: ejb-ref-type [ {0} ] within \n application client [ {1} ] is not valid. \n Must be [ {2} ] or [ {3} ]",
73                    new Object JavaDoc[] {ejbRefTypeStr,descriptor.getName(),EjbEntityDescriptor.TYPE,EjbSessionDescriptor.TYPE}));
74             failed = true;
75         }
76         }
77     } else {
78         result.addNaDetails(smh.getLocalString
79                        ("tests.componentNameConstructor",
80                     "For [ {0} ]",
81                     new Object JavaDoc[] {compName.toString()}));
82         result.notApplicable(smh.getLocalString
83                  (getClass().getName() + ".notApplicable",
84                   "There are no ejb references to other beans within this application client [ {0} ]",
85                   new Object JavaDoc[] {descriptor.getName()}));
86         return result;
87     }
88
89     if (failed)
90         {
91         result.setStatus(Result.FAILED);
92         } else {
93         result.addGoodDetails(smh.getLocalString
94                        ("tests.componentNameConstructor",
95                     "For [ {0} ]",
96                     new Object JavaDoc[] {compName.toString()}));
97         result.passed
98             (smh.getLocalString
99              (getClass().getName() + ".passed",
100               "All ejb-ref-type elements are valid. They are all [ {0} ] or [ {1} ] within this application client [ {2} ]",
101               new Object JavaDoc[] {EjbEntityDescriptor.TYPE,EjbSessionDescriptor.TYPE,descriptor.getName()}));
102         }
103     return result;
104     }
105 }
106
Popular Tags