KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > verifier > tests > ejb > ias > resource > ASEjbREnvRefJndiName


1 package com.sun.enterprise.tools.verifier.tests.ejb.ias.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 com.sun.enterprise.tools.verifier.tests.ejb.EjbTest;
26 import java.util.*;
27 import com.sun.enterprise.deployment.EjbDescriptor;
28 import com.sun.enterprise.deployment.EjbSessionDescriptor;
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.tools.common.dd.ejb.SunEjbJar;
35 import com.sun.enterprise.tools.common.dd.ejb.Ejb;
36 import com.sun.enterprise.tools.common.dd.ResourceEnvRef;
37 import com.sun.enterprise.tools.common.dd.DefaultResourcePrincipal;
38 import com.sun.enterprise.deployment.JmsDestinationReferenceDescriptor;
39
40 /** ejb [0,n]
41  * resource-env-ref [0,n]
42  * resource-env-ref-name [String]
43  * jndi-name [String]
44  *
45  * The jndi-name tag specifies the jndi name to which the resource environment reference
46  * name is binded.
47  *
48  * The value of this elemnet should not be null and should start
49  * with jms/
50  *
51  * @author Irfan Ahmed
52  */

53 public class ASEjbREnvRefJndiName extends ASEjbResEnvRef {
54
55     public Result check(EjbDescriptor descriptor)
56     {
57     SunEjbJar ejbJar = descriptor.getEjbBundleDescriptor().getIasEjbObject();
58         boolean oneFailed = false;
59         
60         if(ejbJar!=null)
61         {
62             getEjb(descriptor,ejbJar);
63             if(resRefs.length > 0)
64             {
65                 for(int j=0;j<resRefs.length;j++)
66                 {
67                     String JavaDoc refName = resRefs[j].getResourceEnvRefName();
68                     String JavaDoc refJndiName = resRefs[j].getJndiName();
69                     try
70                     {
71                         JmsDestinationReferenceDescriptor resDesc = descriptor.getJmsDestinationReferenceByName(refName);
72                         String JavaDoc type = resDesc.getRefType();
73                         if(type.indexOf("javax.jms")>-1) //jms resource
74
{
75                             if(refJndiName.startsWith("jms/"))
76                                 result.passed(smh.getLocalString(getClass().getName()+".passed1",
77                                     "PASSED [AS-EJB res-env-ref] : jndi-name {0} is valid", new Object JavaDoc[]{refJndiName}));
78                             else
79                                 result.failed(smh.getLocalString(getClass().getName()+".failed4",
80                                     "FAILED [AS-EJB res-env-ref] : jndi-name {0} has invalid JNDI naming Scheme. " +
81                                     "JMS resources should have jndi-name starting with jms/",
82                                     new Object JavaDoc[]{refJndiName}));
83                         }
84                     }
85                     catch(IllegalArgumentException JavaDoc iex)
86                     {
87                         result.failed(smh.getLocalString(getClass().getName()+".failed",
88                             "FAILED [AS-EJB res-env-ref] : res-ref with res-ref-name {0} is not defined in the ejb-jar.xml",
89                             new Object JavaDoc[]{refName}));
90                     }
91                 }
92             }
93             else
94             {
95                  result.notApplicable(smh.getLocalString
96                          (getClass().getName() + ".notApplicable",
97                           "{0} Does not define any resource-env-ref Elements",
98                           new Object JavaDoc[] {descriptor.getName()}));
99             }
100         }
101         else
102         {
103             result.addErrorDetails(smh.getLocalString
104                  (getClass().getName() + ".notRun",
105                   "NOT RUN [AS-EJB] : Could not create an SunEjbJar object"));
106         }
107         return result;
108     }
109 }
110
111
Popular Tags