1 5 package xdoclet.modules.ejb.lookup; 6 7 import java.text.MessageFormat ; 8 import java.util.Properties ; 9 import org.apache.commons.logging.Log; 10 11 import xjavadoc.XClass; 12 import xdoclet.DocletContext; 13 import xdoclet.DocletTask; 14 import xdoclet.XDocletException; 15 import xdoclet.modules.ejb.EjbTagsHandler; 16 17 import xdoclet.modules.ejb.lookup.LookupObjectSubTask; 18 import xdoclet.util.LogUtil; 19 20 26 public class LookupUtilTagsHandler extends EjbTagsHandler 27 { 28 48 public static String getUtilClassFor(XClass clazz) 49 { 50 Log log = LogUtil.getLog(LookupUtilTagsHandler.class, "utilClassName"); 51 52 String fileName = clazz.getContainingPackage().getName(); 53 String utilPattern = null; 54 55 if (log.isDebugEnabled()) { 56 log.debug("utility object for " + clazz.getQualifiedName()); 57 } 58 59 utilPattern = getUtilClassPattern(); 60 61 String ejbName = null; 62 String packagePattern = null; 63 64 if (utilPattern.indexOf("{0}") != -1) { 65 ejbName = MessageFormat.format(utilPattern, new Object []{getShortEjbNameFor(clazz)}); 66 } 67 else { 68 ejbName = utilPattern; 69 } 70 71 fileName = choosePackage(fileName, packagePattern, DocletTask.getSubTaskName(LookupObjectSubTask.class)); 73 fileName += '.' + ejbName; 74 75 return fileName; 76 } 77 78 83 protected static String getUtilClassPattern() 84 { 85 LookupObjectSubTask utilSubtask = ((LookupObjectSubTask) DocletContext.getInstance().getSubTaskBy(DocletTask.getSubTaskName(LookupObjectSubTask.class))); 86 87 if (utilSubtask != null) { 88 return utilSubtask.getUtilClassPattern(); 89 } 90 else { 91 return LookupObjectSubTask.DEFAULT_UTIL_CLASS_PATTERN; 92 } 93 } 94 95 101 public String lookupKind() throws XDocletException 102 { 103 String kind = getTagValue( 104 FOR_CLASS, 105 getCurrentClass().getDoc(), 106 "ejb:util", 107 "generate", 108 "physical,logical", 109 null, 110 true, 111 false 112 ); 113 114 if (kind == null) { 116 kind = (String ) getDocletContext().getConfigParam(DocletTask.getSubTaskName(LookupObjectSubTask.class) + ".kind"); 117 } 118 119 if (kind.equals("physical")) { 120 return "JNDI_NAME"; 121 } 122 else { 123 return "COMP_NAME"; 124 } 125 } 126 127 135 public String utilClass(Properties attributes) throws XDocletException 136 { 137 return getUtilClassFor(getCurrentClass()); 138 } 139 140 } 141 142 | Popular Tags |