KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.resource;
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.tools.verifier.tests.ejb.EjbTest;
27 import java.util.*;
28 import com.sun.enterprise.deployment.EjbDescriptor;
29 import com.sun.enterprise.tools.verifier.*;
30 import com.sun.enterprise.tools.verifier.tests.*;
31
32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck;
33
34 import com.sun.enterprise.deployment.ResourceReferenceDescriptor;
35
36 /** ejb [0,n]
37  * resource-ref [0,n]
38  * res-ref-name [String]
39  * jndi-name [String]
40  * default-resource-principal ?
41  * name [String]
42  * password [String]
43  *
44  * The resource-ref element holds the runtime bindings for a resource
45  * reference declared in the ejb-jar.xml
46  * @author Irfan Ahmed
47  */

48
49 public class ASEjbResRef extends EjbTest implements EjbCheck {
50
51     public Result check(EjbDescriptor descriptor)
52     {
53     Result result = getInitializedResult();
54     ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
55
56         Set resRef = descriptor.getResourceReferenceDescriptors();
57         boolean oneFailed = false;
58         if(!(resRef.isEmpty()))
59         {
60             Iterator it = resRef.iterator();
61             while (it.hasNext())
62             {
63                 ResourceReferenceDescriptor resDesc = (ResourceReferenceDescriptor)it.next();
64                 String JavaDoc refName = resDesc.getName();
65                 
66              try
67                     {
68                         descriptor.getResourceReferenceByName(refName);
69                         addGoodDetails(result, compName);
70                         result.passed(smh.getLocalString(getClass().getName()+".passed",
71                             "PASSED [AS-EJB resource-ref] : res-ref-name {0} is verified with ejb-jar.xml",
72                             new Object JavaDoc[]{refName}));
73                     }
74                     catch(IllegalArgumentException JavaDoc iaex)
75                     {
76                         Verifier.debug(iaex);
77                         addErrorDetails(result, compName);
78                         result.failed(smh.getLocalString(getClass().getName()+".failed",
79                             "FAILED [AS-EJB resource-ref] : The res-ref-name {0} is not defined in ejb-jar.xml for this bean",
80                             new Object JavaDoc[]{refName}));
81                     }
82              
83             }
84                 
85         }
86         else
87         {
88             addNaDetails(result, compName);
89             result.notApplicable(smh.getLocalString
90                 (getClass().getName() + ".notApplicable",
91                     "{0} Does not define any resource-ref Elements",
92                     new Object JavaDoc[] {descriptor.getName()}));
93         }
94     return result;
95     }
96 }
97
Popular Tags