1 21 package oracle.toplink.essentials.querykeys; 23 24 import java.security.AccessController ; 25 import java.security.PrivilegedActionException ; 26 27 import oracle.toplink.essentials.expressions.*; 28 import oracle.toplink.essentials.exceptions.ValidationException; 29 import oracle.toplink.essentials.internal.security.PrivilegedAccessHelper; 30 import oracle.toplink.essentials.internal.security.PrivilegedClassForName; 31 32 41 public class ForeignReferenceQueryKey extends QueryKey { 42 protected Class referenceClass; 43 protected String referenceClassName; 44 protected Expression joinCriteria; 45 46 52 public void convertClassNamesToClasses(ClassLoader classLoader){ 53 Class referenceClass = null; 54 try{ 55 if (referenceClassName != null){ 56 if (PrivilegedAccessHelper.shouldUsePrivilegedAccess()){ 57 try { 58 referenceClass = (Class )AccessController.doPrivileged(new PrivilegedClassForName(referenceClassName, true, classLoader)); 59 } catch (PrivilegedActionException exception) { 60 throw ValidationException.classNotFoundWhileConvertingClassNames(referenceClassName, exception.getException()); 61 } 62 } else { 63 referenceClass = oracle.toplink.essentials.internal.security.PrivilegedAccessHelper.getClassForName(referenceClassName, true, classLoader); 64 } 65 } 66 setReferenceClass(referenceClass); 67 } catch (ClassNotFoundException exc){ 68 throw ValidationException.classNotFoundWhileConvertingClassNames(referenceClassName, exc); 69 } 70 } 71 72 76 public Expression getJoinCriteria() { 77 return joinCriteria; 78 } 79 80 84 public Class getReferenceClass() { 85 return referenceClass; 86 } 87 88 92 public String getReferenceClassName() { 93 if (referenceClassName == null && referenceClass != null){ 94 referenceClassName = referenceClass.getName(); 95 } 96 return referenceClassName; 97 } 98 99 104 public boolean isForeignReferenceQueryKey() { 105 return true; 106 } 107 108 116 public void setJoinCriteria(Expression joinCriteria) { 117 this.joinCriteria = joinCriteria; 118 } 119 120 125 public void setReferenceClass(Class referenceClass) { 126 this.referenceClass = referenceClass; 127 } 128 129 135 public void setReferenceClassName(String referenceClassName) { 136 this.referenceClassName = referenceClassName; 137 } 138 } 139 | Popular Tags |