KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > ibm > websphere > ejb > WebSphereEjbRefTagsHandler


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.ibm.websphere.ejb;
6
7 import xjavadoc.XClass;
8
9 import xdoclet.XDocletException;
10 import xdoclet.modules.ejb.EjbTagsHandler;
11 import xdoclet.modules.ejb.env.EnvEjbRefTagsHandler;
12 import xdoclet.modules.ejb.home.HomeTagsHandler;
13
14 /**
15  * @author <a HREF="mailto:ml at callista.se">Magnus Larsson</a>
16  * @created Dec 26, 2004
17  * @xdoclet.taghandler namespace="WebSphereEjbRef"
18  * @version $Revision 1.1 $
19  */

20 public class WebSphereEjbRefTagsHandler extends EnvEjbRefTagsHandler
21 {
22
23     /**
24      * Returns the global JNDI name for the current EJB ref.<br/>
25      * WebSphere can only can have one global JNDI name for an EJB bean even if it expose both a local and a remote
26      * interface. In this case we return the remote JNDI-name defined on the bean. <p>
27      *
28      * <bold>NOTE:</bold> This means that the local JNDI-name will not be used by WebSphere if both a local and a remote
29      * interface is exposed on a EJB bean. For portability (with other J2EE servers) reasons you should however always
30      * specify both jndi-names in this case.
31      *
32      * @return The JNDI name of current EJB ref.
33      * @exception XDocletException
34      * @doc.tag type="content"
35      */

36     public String JavaDoc ejbRefJndiName() throws XDocletException
37     {
38         String JavaDoc ejbRefJndiName = null;
39
40         String JavaDoc jndiNameParameter = currentTag.getAttributeValue("jndi-name");
41
42         // Return the jndi-name on the ejb-ref-tag if any
43
if (jndiNameParameter != null) {
44             ejbRefJndiName = jndiNameParameter;
45         }
46         // Return the jndi-name on the ejb-bean depending on the view-type
47
else {
48             String JavaDoc refed_ejb_name = currentTag.getAttributeValue("ejb-name");
49
50             if (refed_ejb_name == null) {
51                 throw new XDocletException("No ejb-name attribute found in ejb-ref specified in bean " + getCurrentClass());
52             }
53
54             XClass refed_clazz = findEjb(refed_ejb_name);
55             String JavaDoc ejb_type = null;
56
57             // If the ejb-bean expose both remote and local itnerfaces we however always return the remote jndi-name since WebSphere only can handle one jndi-name on a ejb-bean.
58
if (EjbTagsHandler.isLocalEjb(getCurrentClass()) && EjbTagsHandler.isRemoteEjb(getCurrentClass())) {
59                 ejb_type = "remote";
60
61             }
62             else {
63                 ejb_type = isLocalEjbRef(currentTag) ? "local" : "remote";
64             }
65
66             ejbRefJndiName = HomeTagsHandler.getJndiNameOfTypeFor(ejb_type, refed_clazz);
67         }
68
69         return ejbRefJndiName;
70     }
71
72 }
73
Popular Tags