1 23 24 29 30 package com.sun.jdo.spi.persistence.support.ejb.ejbc; 31 32 import java.util.ArrayList ; 33 import java.util.Collection ; 34 import java.util.ResourceBundle ; 35 import java.lang.reflect.Method ; 36 37 import com.sun.enterprise.deployment.runtime.IASEjbCMPFinder; 38 import com.sun.enterprise.deployment.runtime.PrefetchDisabledDescriptor; 39 import com.sun.enterprise.deployment.IASEjbCMPEntityDescriptor; 40 import com.sun.enterprise.deployment.MethodDescriptor; 41 import com.sun.enterprise.deployment.QueryDescriptor; 42 43 import com.sun.jdo.spi.persistence.utility.I18NHelper; 44 import com.sun.jdo.spi.persistence.utility.generator.JavaClassWriterHelper; 45 46 52 public class MethodHelper extends AbstractMethodHelper 53 { 54 55 private final static ResourceBundle messages = I18NHelper.loadBundle( 56 MethodHelper.class); 57 58 62 public MethodHelper (IASEjbCMPEntityDescriptor descriptor) 63 { 64 super(descriptor); 65 } 66 67 71 protected void categorizeMethods () 72 { 73 IASEjbCMPEntityDescriptor cmpDescriptor = 74 (IASEjbCMPEntityDescriptor)getDescriptor(); 75 76 super.categorizeMethods(); 77 78 setFinders(getListForCollection(cmpDescriptor.getFinders())); 80 setSelectors(getListForCollection(cmpDescriptor.getSelectors())); 81 } 82 83 private static ArrayList getListForCollection (Collection aCollection) 85 { 86 return ((aCollection != null) ? 87 new ArrayList (aCollection) : new ArrayList ()); 88 } 89 90 96 public boolean isQueryPrefetchEnabled (Method method) 97 { 98 boolean enabled = true; 99 QueryDescriptor queryDescriptor = getQueryDescriptor(method); 100 101 if (queryDescriptor != null) 102 { 103 IASEjbCMPEntityDescriptor cmpDescriptor = 104 (IASEjbCMPEntityDescriptor)getDescriptor(); 105 PrefetchDisabledDescriptor pdDescriptor = 106 cmpDescriptor.getPrefetchDisabledDescriptor(); 107 108 if (pdDescriptor != null) 109 { 110 MethodDescriptor methodDescriptor = 111 queryDescriptor.getQueryMethodDescriptor(); 112 113 enabled = !pdDescriptor.isPrefetchDisabledFor( 114 methodDescriptor); 115 } 116 } 117 118 return enabled; 119 } 120 121 128 public String getJDOFilterExpression (Method method) 129 { 130 IASEjbCMPFinder cmpFinder = getFinder(method); 131 132 return ((cmpFinder != null) ? cmpFinder.getQueryFilter() : null); 133 } 134 135 142 public String getJDOParameterDeclaration (Method method) 143 { 144 IASEjbCMPFinder cmpFinder = getFinder(method); 145 146 return ((cmpFinder != null) ? 147 cmpFinder.getQueryParameterDeclaration() : null); 148 } 149 150 157 public String getJDOVariableDeclaration (Method method) 158 { 159 IASEjbCMPFinder cmpFinder = getFinder(method); 160 161 return ((cmpFinder != null) ? cmpFinder.getQueryVariables() : null); 162 } 163 164 171 public String getJDOOrderingSpecification (Method method) 172 { 173 IASEjbCMPFinder cmpFinder = getFinder(method); 174 175 return ((cmpFinder != null) ? cmpFinder.getQueryOrdering() : null); 176 } 177 178 179 private IASEjbCMPFinder getFinder (Method method) 180 { 181 IASEjbCMPEntityDescriptor cmpDescriptor = 182 (IASEjbCMPEntityDescriptor)getDescriptor(); 183 IASEjbCMPFinder finder = cmpDescriptor.getIASEjbCMPFinder(method); 184 185 if (finder == null) { 186 String methodSignature = cmpDescriptor.getName() + '.' + 187 method.getName() + 188 JavaClassWriterHelper.parenleft_ + 189 JavaClassWriterHelper.getParameterTypesList(method) + 190 JavaClassWriterHelper.parenright_ ; 191 String msg = I18NHelper.getMessage(messages, 192 "EXC_MissingCMP11Finder", methodSignature); throw new RuntimeException (msg); 194 } 195 196 return finder; 197 } 198 } 199 | Popular Tags |