1 23 24 29 30 package com.sun.jdo.spi.persistence.support.ejb.ejbc; 31 32 import java.util.*; 33 import java.lang.reflect.Method ; 34 35 import com.sun.enterprise.deployment.*; 36 37 42 abstract public class AbstractMethodHelper 43 { 44 45 public static final int LOCAL_RETURN = 0; 46 47 48 public static final int REMOTE_RETURN = 1; 49 50 51 public static final int NO_RETURN = 2; 52 53 private EjbCMPEntityDescriptor _cmpDescriptor; 54 private List finders = new ArrayList(); 55 private List selectors = new ArrayList(); 56 private List createMethods = new ArrayList(); 58 private Map methodNames = new HashMap(); 59 60 64 public AbstractMethodHelper (EjbCMPEntityDescriptor descriptor) 65 { 66 _cmpDescriptor = descriptor; 67 categorizeMethods(); } 69 70 75 protected EjbCMPEntityDescriptor getDescriptor() { return _cmpDescriptor; } 76 77 81 protected void categorizeMethods () 82 { 83 EjbCMPEntityDescriptor descriptor = getDescriptor(); 84 Iterator iterator = descriptor.getMethodDescriptors().iterator(); 85 86 while (iterator.hasNext()) 87 { 88 MethodDescriptor methodDescriptor = 89 (MethodDescriptor)iterator.next(); 90 Method method = methodDescriptor.getMethod(descriptor); 91 String methodName = methodDescriptor.getName(); 92 93 96 if (methodName.startsWith(CMPTemplateFormatter.find_)) 97 finders.add(method); 98 else if (methodName.startsWith(CMPTemplateFormatter.ejbSelect_)) 99 selectors.add(method); 100 else if (methodName.startsWith(CMPTemplateFormatter.create_)) 101 createMethods.add(method); 102 else if (methodName.startsWith(CMPTemplateFormatter.get_) || 103 methodName.startsWith(CMPTemplateFormatter.set_)) 104 { 105 ; } 107 110 methodNames.put(methodName, method); 113 } 114 } 115 116 120 public List getFinders () { return finders; } 121 122 protected void setFinders (List finderList) 124 { 125 finders = finderList; 126 } 127 128 132 public List getSelectors () { return selectors; } 133 134 protected void setSelectors (List selectorList) 136 { 137 selectors = selectorList; 138 } 139 140 144 public List getCreateMethods () { return createMethods; } 145 146 149 155 public Map getMethodNames () { return methodNames; } 156 157 160 public String getLocalHome () 161 { 162 return getDescriptor().getLocalHomeClassName(); 163 } 164 165 168 public String getRemoteHome () 169 { 170 return getDescriptor().getHomeClassName(); 171 } 172 173 180 protected QueryDescriptor getQueryDescriptor (Method method) 181 { 182 PersistenceDescriptor persistenceDescriptor = 183 getDescriptor().getPersistenceDescriptor(); 184 return persistenceDescriptor.getQueryFor(method); 185 } 186 187 193 public String getQueryString (Method method) 194 { 195 QueryDescriptor queryDescriptor = getQueryDescriptor(method); 196 197 return ((queryDescriptor != null) ? queryDescriptor.getQuery() : null); 198 } 199 200 208 public int getQueryReturnType (Method method) 209 { 210 QueryDescriptor queryDescriptor = getQueryDescriptor(method); 211 212 if (queryDescriptor != null) 213 { 214 if (queryDescriptor.getHasLocalReturnTypeMapping()) 215 return LOCAL_RETURN; 216 if (queryDescriptor.getHasRemoteReturnTypeMapping()) 217 return REMOTE_RETURN; 218 } 219 220 return NO_RETURN; 221 } 222 223 229 abstract public boolean isQueryPrefetchEnabled (Method method); 230 231 238 abstract public String getJDOFilterExpression (Method method); 239 240 247 abstract public String getJDOParameterDeclaration (Method method); 248 249 256 abstract public String getJDOVariableDeclaration (Method method); 257 258 265 abstract public String getJDOOrderingSpecification (Method method); 266 } 267 | Popular Tags |