KickJava   Java API By Example, From Geeks To Geeks.

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


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

24
25 import java.util.*;
26 import com.sun.enterprise.deployment.EjbDescriptor;
27 import com.sun.enterprise.tools.verifier.*;
28 import com.sun.enterprise.tools.verifier.tests.*;
29
30 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
31
32 /** ejb [0,n]
33  * resource-ref [0,n]
34  * res-ref-name [String]
35  * jndi-name [String]
36  * default-resource-principal ?
37  * name [String]
38  * password [String]
39  *
40  * The res-ref-name specfies the name of the resource in the ejb-jar.xml for which
41  * this element shows the jndi binding properties
42  *
43  * The res-ref-name should exist in the ejb-jar.xml file
44  *
45  * @author Irfan Ahmed
46  */

47 public class ASEjbRRefName extends ASEjbResRef {
48
49     public Result check(EjbDescriptor descriptor)
50     {
51         Result result = getInitializedResult();
52     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
53         boolean oneFailed = false;
54         try
55         {
56         Set resRef = descriptor.getResourceReferenceDescriptors();
57         if(!(resRef.isEmpty()))
58         {
59             Iterator it = resRef.iterator();
60             while (it.hasNext())
61             {
62                 ResourceReferenceDescriptor resDesc = ((ResourceReferenceDescriptor)it.next());
63                 String JavaDoc refName = resDesc.getName();
64                 if(refName == null || refName.length()==0)
65                     {
66                         addErrorDetails(result, compName);
67                         result.failed(smh.getLocalString(getClass().getName()+".failed",
68                             "FAILED [AS-EJB resource-ref] : resource-ref has empty res-ref-name"));
69                     }
70                     else
71                     {
72                         addGoodDetails(result, compName);
73                         result.passed(smh.getLocalString(getClass().getName()+".passed",
74                             "PASSED [AS-EJB resource-ref] : res-ref-name is {0}",new Object JavaDoc[]{refName}));
75                     }
76             }
77         }
78         else
79         {
80             addNaDetails(result, compName);
81             result.notApplicable(smh.getLocalString
82                 (getClass().getName() + ".notApplicable",
83                     "{0} Does not define any resource-ref Elements",
84                     new Object JavaDoc[] {descriptor.getName()}));
85         }
86         }catch(Exception JavaDoc ex)
87         {
88             addErrorDetails(result, compName);
89             result.addErrorDetails(smh.getLocalString
90                  (getClass().getName() + ".notRun",
91                   "NOT RUN [AS-EJB] : Could not create the descriptor object"));
92         }
93         return result;
94     }
95 }
96
Popular Tags