Update of /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/env In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26235/modules/ejb/src/xdoclet/modules/ejb/env
Modified Files: EnvTagsHandler.java Log Message: statefull session bean passivation implemented (XDT-1325) Index: EnvTagsHandler.java =================================================================== RCS file: /cvsroot/xdoclet/xdoclet/modules/ejb/src/xdoclet/modules/ejb/env/EnvTagsHandler.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** EnvTagsHandler.java 9 Apr 2005 15:44:02 -0000 1.2 --- EnvTagsHandler.java 10 Apr 2005 16:50:08 -0000 1.3 *************** *** 35,43 **** { /** - * The tags for which a value is bound in the java componenet environement jndi namespace - */ - private final static String[] ENV_TAGS = {"ejb.env-entry", "ejb.resource-ref", "ejb.resource-env-ref", "ejb.destination-ref", "ejb.ejb-service-ref", "ejb.ejb-ref", "ejb.external-ref"}; - - /** * Maps primitive types to their wrapper classes */ --- 35,38 ---- *************** *** 68,71 **** --- 63,68 ---- * @throws XDocletException if an error occures * @doc.param name="tagName" optional="false" description="the tag name" + * @doc.param name="paramName" optional="true" description="the required parameter" + * @doc.param name="paramValue" optional="true" description="the value for the required parameter" * @doc.tag type="block" */ *************** *** 82,85 **** --- 79,84 ---- * @throws XDocletException if an error occures * @doc.param name="tagName" optional="false" description="the tag name" + * @doc.param name="paramName" optional="true" description="the required parameter" + * @doc.param name="paramValue" optional="true" description="the value for the required parameter" * @doc.tag type="block" */ *************** *** 97,100 **** --- 96,101 ---- * @throws XDocletException if an error occures * @doc.param name="tagName" optional="false" description="the tag name" + * @doc.param name="paramName" optional="true" description="the required parameter" + * @doc.param name="paramValue" optional="true" description="the value for the required parameter" * @doc.tag type="block" */ *************** *** 370,386 **** public void ifPrimitiveMember(String template, Properties attributes) throws XDocletException { ! if (currentMember != null) { ! String type = currentMemberType(); ! String wrapper = (String) wrappers.get(type); ! if (wrapper != null) { ! generate(template); ! } } } /** ! * Executes the body only if the current class has at least one field or method tag for which a value is bound in ! * the java componenet environement jndi namespace * * @param template the template --- 371,396 ---- public void ifPrimitiveMember(String template, Properties attributes) throws XDocletException { ! if (isPrimitiveMember()) { ! generate(template); ! } ! } ! /** ! * Executes the body only if the current field type or method return type is not a primitive. ! * ! * @param template the template ! * @param attributes the attributes ! * @exception XDocletException if an error occures ! * @doc.tag type="block" ! */ ! public void ifNotPrimitiveMember(String template, Properties attributes) throws XDocletException ! { ! if (!isPrimitiveMember()) { ! generate(template); } } /** ! * Executes the body only if the current class has at least one ot the passed tags at field- or method-level * * @param template the template *************** *** 388,399 **** * @exception XDocletException if an error occures * @doc.tag type="block" */ ! public void ifHasEnvTags(String template, Properties attributes) throws XDocletException { ! if (hasMemberWithEnvTag(getCurrentClass().getMethods(true))) { generate(template); } else { ! if (hasMemberWithEnvTag(getCurrentClass().getFields(true))) { generate(template); } --- 398,422 ---- * @exception XDocletException if an error occures * @doc.tag type="block" + * @doc.param name="tagName" optional="false" description="the tag names (comma separated)" + * @doc.param name="paramName" optional="true" description="tags must have this parameter" + * @doc.param name="paramValue" optional="true" description="tags must have this value for the + * parameter with 'paramName'" */ ! public void ifHasTag(String template, Properties attributes) throws XDocletException { ! String tags = attributes.getProperty("tagName"); ! ! if (tags == null) { ! throw new XDocletException("tagName is mandatory"); ! } ! ! String paramName = attributes.getProperty("paramName"); ! String paramValue = attributes.getProperty("paramValue"); ! ! if (hasMemberWithTag(getCurrentClass().getMethods(true), tags, paramName, paramValue)) { generate(template); } else { ! if (hasMemberWithTag(getCurrentClass().getFields(true), tags, paramName, paramValue)) { generate(template); } *************** *** 425,429 **** while (st.hasMoreTokens()) { ! forTagsInternal(template, st.nextToken(), superclasses, forClass, forMethod, forField); } } --- 448,453 ---- while (st.hasMoreTokens()) { ! attributes.setProperty("tagName", st.nextToken()); ! forTagsInternal(template, attributes, superclasses, forClass, forMethod, forField); } } *************** *** 440,443 **** --- 464,486 ---- } + + /** + * Returns whether the current field type or method return type is primitive. + * + * @return <code>true</code> it the current member is primitive + */ + private boolean isPrimitiveMember() + { + if (currentMember != null) { + String type = currentMemberType(); + String wrapper = (String) wrappers.get(type); + + if (wrapper != null) { + return true; + } + } + return false; + } + /** * Returns whether the parameter's value is equal to the specfied value *************** *** 461,465 **** * * @param template the template ! * @param tagName the tag-name * @param superclasses indicates whether the superclasses of the current class should also be searched * @param forClass indicates whether the template should be excuted for class level tags --- 504,508 ---- * * @param template the template ! * @param attributes the attriubtes * @param superclasses indicates whether the superclasses of the current class should also be searched * @param forClass indicates whether the template should be excuted for class level tags *************** *** 468,474 **** * @throws XDocletException if an error occures */ ! private void forTagsInternal(String template, String tagName, boolean superclasses, boolean forClass, boolean forMethod, boolean forField) throws XDocletException { // class level tags if (forClass) { --- 511,521 ---- * @throws XDocletException if an error occures */ ! private void forTagsInternal(String template, Properties attributes, boolean superclasses, boolean forClass, boolean forMethod, boolean forField) throws XDocletException { + String tagName = attributes.getProperty("tagName"); + String paramName = attributes.getProperty("paramName"); + String paramValue = attributes.getProperty("paramValue"); + // class level tags if (forClass) { *************** *** 479,486 **** for (Iterator it = tags.iterator(); it.hasNext(); ) { currentTag = (XTag) it.next(); ! setCurrentClassTag(currentTag); ! currentMember = null; ! doGenerate(template); ! setCurrentClassTag(null); } } --- 526,535 ---- for (Iterator it = tags.iterator(); it.hasNext(); ) { currentTag = (XTag) it.next(); ! if (tagMatches(currentTag, paramName, paramValue)) { ! setCurrentClassTag(currentTag); ! currentMember = null; ! doGenerate(template); ! setCurrentClassTag(null); ! } } } *************** *** 501,508 **** for (Iterator it2 = tags.iterator(); it2.hasNext(); ) { currentTag = (XTag) it2.next(); ! setCurrentMethodTag(currentTag); ! currentMember = method; ! doGenerate(template); ! setCurrentMethodTag(null); } setCurrentMethod(null); --- 550,559 ---- for (Iterator it2 = tags.iterator(); it2.hasNext(); ) { currentTag = (XTag) it2.next(); ! if (tagMatches(currentTag, paramName, paramValue)) { ! setCurrentMethodTag(currentTag); ! currentMember = method; ! doGenerate(template); ! setCurrentMethodTag(null); ! } } setCurrentMethod(null); *************** *** 525,532 **** for (Iterator it2 = tags.iterator(); it2.hasNext(); ) { currentTag = (XTag) it2.next(); ! setCurrentFieldTag(currentTag); ! currentMember = field; ! doGenerate(template); ! setCurrentFieldTag(null); } setCurrentField(null); --- 576,585 ---- for (Iterator it2 = tags.iterator(); it2.hasNext(); ) { currentTag = (XTag) it2.next(); ! if (tagMatches(currentTag, paramName, paramValue)) { ! setCurrentFieldTag(currentTag); ! currentMember = field; ! doGenerate(template); ! setCurrentFieldTag(null); ! } } setCurrentField(null); *************** *** 538,558 **** /** ! * Returns whether the passed Collection of Members has at least one of the tags for which a value is bound in the ! * java componenet environement jndi namespace * ! * @param members a <code>Collection</code> o [EMAIL PROTECTED] XMember} ! * @return <code>true</code> if the passed Collection of Members has at least one of the tags for which a * value is bound in the java componenet environement jndi namespace */ ! private boolean hasMemberWithEnvTag(Collection members) { for (Iterator it = members.iterator(); it.hasNext(); ) { XMember member = (XMember) it.next(); ! for (int i = 0; i < ENV_TAGS.length; i++) { ! Collection tags = member.getDoc().getTags(ENV_TAGS[i]); if (tags.size() > 0) { ! return true; } } --- 591,649 ---- /** ! * Returns whether the passed tag matches for the passed parameter name and value * ! * @param tag the tag ! * @param paramName the parameter name or <code>null</code> for no parameter restriction ! * @param paramValue the value for the parameter <code>paramName</code> or <code>null</code> for no parameter value ! * restriction ! * @return <code>true</code> it the tag matches ! */ ! private boolean tagMatches(XTag tag, String paramName, String paramValue) ! { ! if (paramName == null) { ! return true; ! } ! ! String value = tag.getAttributeValue(paramName); ! ! return value != null && (paramValue == null || value.equals(paramValue)); ! } ! ! /** ! * Returns whether the passed Collection of Members has at least one the passed tags for which a value is bound in ! * the java componenet environement jndi namespace ! * ! * @param members a <code>Collection</code> o [EMAIL PROTECTED] XMember} ! * @param tagNames the tag names ! * @param paramName the required parameter or <code>null</code> ! * @param paramValue the required value of the parameter <code>paramName</code> or <code>null</code> ! * @return <code>true</code> if the passed Collection of Members has at least one of the tags for which a * value is bound in the java componenet environement jndi namespace */ ! private boolean hasMemberWithTag(Collection members, String tagNames, String paramName, String paramValue) { + for (Iterator it = members.iterator(); it.hasNext(); ) { XMember member = (XMember) it.next(); ! StringTokenizer st = new StringTokenizer(tagNames, ","); ! ! while (st.hasMoreTokens()) { ! Collection tags = member.getDoc().getTags(st.nextToken()); if (tags.size() > 0) { ! if (paramName == null) { ! return true; ! } ! else { ! for (Iterator it2 = tags.iterator(); it2.hasNext(); ) { ! XTag tag = (XTag) it2.next(); ! String value = tag.getAttributeValue(paramName); ! ! if (value != null && (paramValue == null || paramValue.equals(value))) { ! return true; ! } ! } ! } } } ------------------------------------------------------- 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://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click _______________________________________________ xdoclet-devel mailing list xdoclet-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/xdoclet-devel