Update of /cvsroot/xdoclet/xdoclet/modules/ibm/src/xdoclet/modules/ibm/websphere/ejb In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11952/xdoclet/modules/ibm/src/xdoclet/modules/ibm/websphere/ejb
Added Files: WebSphereEjbRefTagsHandler.java Log Message: XDT-1185: Fixed the problem with a EJB-bean that defines both a local and a remote interface. --- NEW FILE: WebSphereEjbRefTagsHandler.java --- /* * Copyright (c) 2001, 2002 The XDoclet team * All rights reserved. */ package xdoclet.modules.ibm.websphere.ejb; import java.util.Collection; import java.util.HashMap; import java.util.Iterator; import java.util.Properties; import org.apache.commons.logging.Log; import xjavadoc.XClass; import xjavadoc.XTag; import xdoclet.XDocletException; import xdoclet.modules.ejb.EjbTagsHandler; import xdoclet.modules.ejb.XDocletModulesEjbMessages; import xdoclet.modules.ejb.dd.EjbRefTagsHandler; import xdoclet.modules.ejb.home.HomeTagsHandler; import xdoclet.util.LogUtil; import xdoclet.util.Translator; import xdoclet.util.TypeConversionUtil; /** * @author <a href="mailto:ml at callista.se">Magnus Larsson</a> * @created Dec 26, 2004 * @xdoclet.taghandler namespace="WebSphereEjbRef" * @version $Revision 1.1 $ */ public class WebSphereEjbRefTagsHandler extends EjbRefTagsHandler { /** * Generates code if the ejb-ref is local * * @param template * @exception XDocletException * @doc.tag type="block" */ public void ifLocalEjbRef(String template) throws XDocletException { if (isLocalEjbRef(getCurrentClassTag())) { generate(template); } } /** * Generates code if the ejb-ref is local * * @param template * @exception XDocletException * @doc.tag type="block" */ public void ifRemoteEjbRef(String template) throws XDocletException { if (isRemoteEjbRef(getCurrentClassTag())) { generate(template); } } /** * Returns the global JNDI name for the current EJB ref.<br/> * WebSphere can only can have one global JNDI name for an EJB bean even if it expose both a local and a remote * interface. In this case we return the remote JNDI-name defined on the bean. <p> * * <bold>NOTE:</bold> This means that the local JNDI-name will not be used by WebSphere if both a local and a remote * interface is exposed on a EJB bean. For portability (with other J2EE servers) reasons you should however always * specify both jndi-names in this case. * * @return The JNDI name of current EJB ref. * @exception XDocletException * @doc.tag type="content" */ public String ejbRefJndiName() throws XDocletException { String ejbRefJndiName = null; String jndiNameParameter = getCurrentClassTag().getAttributeValue("jndi-name"); // Return the jndi-name on the ejb-ref-tag if any // TODO: Can a ejb-ref-tag specify a jndi name or is this test irrelevant (copied from the baseclass)? if (jndiNameParameter != null) { ejbRefJndiName = jndiNameParameter; // Return the jndi-name on the ejb-bean depending on the view-type } else { String refed_ejb_name = getCurrentClassTag().getAttributeValue("ejb-name"); if (refed_ejb_name == null) { throw new XDocletException("No ejb-name attribute found in ejb-ref specified in bean " + getCurrentClass()); } XClass refed_clazz = findEjb(refed_ejb_name); String ejb_type = null; // If the ejb-bean expose both remote and local itnerfaces we however always return the remote jndi-name since WebSphere only can handle ine jndi-name on a ejb-bean. if (isLocalEjb(getCurrentClass()) && isRemoteEjb(getCurrentClass())) { ejb_type = "remote"; } else { ejb_type = isLocalEjbRef(getCurrentClassTag()) ? "local" : "remote"; } ejbRefJndiName = HomeTagsHandler.getJndiNameOfTypeFor(ejb_type, refed_clazz); } return ejbRefJndiName; } /** * Return true if the ejb-ref is local * * @param ejbRefTag * @return true if the ejb-ref is local otherwise false * @exception XDocletException */ protected boolean isLocalEjbRef(XTag ejbRefTag) throws XDocletException { String viewTypeParameter = ejbRefTag.getAttributeValue("view-type"); return "local".equals(viewTypeParameter); } /** * Return true if the ejb-ref is remote * * @param ejbRefTag * @return true if the ejb-ref is remote otherwise false * @exception XDocletException */ protected boolean isRemoteEjbRef(XTag ejbRefTag) throws XDocletException { return !isLocalEjbRef(ejbRefTag); } } ------------------------------------------------------- SF email is sponsored by - The IT Product Guide Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/ _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel